Code covered by the BSD License  

Highlights from
DESOS

image thumbnail
from DESOS by Ugo Pattacini
Simulation tool for payload data volume and downlink latency estimation in a LEO scenario

PlotTimeline(Type,Contacts,PT,Simout,TOrbit,EnSz)
function PlotTimeline(Type,Contacts,PT,Simout,TOrbit,EnSz)
% Script used by DESOS to present results
%
% Author: Ugo Pattacini

if isempty(Simout.time)
    warndlg('Nothing to plot.');
    return;
end

plotflag={false false false false};
plotqty=0;

if strcmpi(Type{1},'all')
    plotflag={true true true true};
    plotqty=4;    
else
    for i=1:length(Type)
        switch lower(Type{i})
            case 'contacts'
                plotflag{1}=true;
                plotqty=plotqty+1;
            case 'data'
                plotflag{2}=true;
                plotqty=plotqty+1;
            case 'volume'
                plotflag{3}=true;
                plotqty=plotqty+1;
            case 'latency'
                plotflag{4}=true;
                plotqty=plotqty+1;                
            otherwise
                errordlg('Unknown type.');
                return;
        end
    end
end

global ha;

figure('Color','w');
j=1;

% contacts
if plotflag{1}
    subplot(plotqty,1,j);
    IdxEnd=find(Contacts(:,1)<Simout.time(end),1,'last');
    Contacts(:,2)=max(Contacts(:,2),0);
    hg(1)=stairs([Contacts(1:IdxEnd,1); Simout.time(end)],[Contacts(1:IdxEnd,2); Contacts(IdxEnd,2)],'k','LineWidth',2);
    Leg{1}='Contacts';
    hold on;
    orbitX=0:TOrbit:Simout.time(end);
    L=length(orbitX);
    for i=1:L    
        hg(2)=plot([orbitX(i) orbitX(i)],[-.1 1.1],'r--','LineWidth',2);
    end
    Leg{2}='Orbit Division';
    ylim([-.5 1.5]);
    if length(PT{1})>2
        IdxEnd1=find(PT{1}(:,1)<Simout.time(end),1,'last');
        IdxEnd2=find(PT{2}(:,1)<Simout.time(end),1,'last');
        hg(3)=stairs([PT{1}(1:IdxEnd1,1); Simout.time(end)], [PT{1}(1:IdxEnd1,2); PT{1}(IdxEnd1,2)]-1.5,'b','LineWidth',2);
        hg(4)=stairs([PT{2}(1:IdxEnd2,1); Simout.time(end)], [PT{2}(1:IdxEnd2,2); PT{2}(IdxEnd2,2)]-1.5,'g--','LineWidth',2);
        Leg{3}='PT Pol_1';
        Leg{4}='PT Pol_2';
        ylim([-2 1.5]);
    end
    legend(hg,Leg),legend('boxoff');
    grid;
    ha{j}=gca;
    set(zoom,'ActionPostCallback',@mypostcallback);
    set(pan,'ActionPostCallback',@mypostcallback);
    j=j+1;
end

% data
if plotflag{2}
    subplot(plotqty,1,j);
    stairs(Simout.time,EnSz*[Simout.signals.values(:,1) Simout.signals.values(:,3)],'LineWidth',2);
    legend('SAR Data','Downlinked Data'),legend('boxoff');
    ylabel('[MB]');
    grid;
    ha{j}=gca;
    set(zoom,'ActionPostCallback',@mypostcallback);
    set(pan,'ActionPostCallback',@mypostcallback);
    j=j+1;
end

% volume
if plotflag{3}
    Simout.signals.values(:,2)=Simout.signals.values(:,2)*8/2^10*EnSz;
    subplot(plotqty,1,j);
    stairs(Simout.time,Simout.signals.values(:,2),'b','LineWidth',2);
    hold on;
    legend('Stored Data'),legend('boxoff');
    ylabel('[Gbit]');
    grid;
    ha{j}=gca;
    set(zoom,'ActionPostCallback',@mypostcallback);
    set(pan,'ActionPostCallback',@mypostcallback);
    j=j+1;
end

% latency
if plotflag{4}
    subplot(plotqty,1,j);
    stairs(Simout.time,Simout.signals.values(:,4)/60,'b','LineWidth',2);    
    hold on;
    stairs(Simout.time,Simout.signals.values(:,5)/60,'g','LineWidth',1.5);
    legend('Latency','Latency (avg)'),legend('boxoff');
    TOrbit=TOrbit/60;   %min
    orbit=(TOrbit:TOrbit:max(Simout.signals.values(:,4)/60));
    for i=orbit
        stairs([Simout.time(1) Simout.time(end)],[i i],'r--');
    end    
    xlabel('Time [s]');
    ylabel('[min]');
    grid;
    ha{j}=gca;
    set(zoom,'ActionPostCallback',@mypostcallback);
    set(pan,'ActionPostCallback',@mypostcallback);
end



%--------------------------------------------------------------------------
function mypostcallback(obj,evd) %#ok<INUSL>

global ha;

newLim=get(evd.Axes,'XLim');

for i=1:length(ha)
    xlim(ha{i},newLim);
end



Contact us at files@mathworks.com