% plot_Argos_panels
% plot argos in separate plots
if strcmp(argostype,'none') == 0
    load Argos.mat
    stpt=find(sys1.cond > 4, 1,'first');
    atitle=' ';
    fprintf('argos plot: pminx pmaxx %.2f %.2f ',pminx,pmaxx);
    % this tells other routines what plot window they can use:
    nextwin=6;
    if exist('sys1','var'),
        fprintf(' truncating sys1 %d pts %s to %s ',...
            length(sys1.mday), datestr(sys1.mday(1)), ...
            datestr(sys1.mday(end)));
        sys1=structtrunc(sys1, find(sys1.yday >= pminx));
        sys1=struct_gap_nan(sys1,3);
        fprintf('to %d pts %s to %s\n',...
            length(sys1.mday), datestr(sys1.mday(1)), ...
            datestr(sys1.mday(end)));
        atitle=[atitle 'sys1:blue '];
        ydmax(1)=max(sys1.yday);
    else
        fprintf('no sys1 in Argos.mat!\n');
    end
    if exist('sys2','var'),
        fprintf('truncating sys2 %d pts %s to %s ',...
            length(sys2.mday), datestr(sys2.mday(1)), ...
            datestr(sys2.mday(end)));
        sys2=structtrunc(sys2, find(sys2.yday >= pminx));
        sys2=struct_gap_nan(sys2,3);
        fprintf('to %d pts %s to %s\n',...
            length(sys2.mday), datestr(sys2.mday(1)), ...
            datestr(sys2.mday(end)));
        atitle=[atitle 'sys2:green '];
        ydmax(2)=max(sys2.yday);
    else
        fprintf('no sys2 in Argos.mat!\n');
    end

    if exist('sys3','var')
        if isstruct(sys3)
            sys3=structtrunc(sys3, find(sys3.yday > pminx));
        else
            clear sys3
        end
    end
    if exist('sys4','var')
        if isstruct(sys4)
            sys4=structtrunc(sys4, find(sys4.yday > pminx));
        else
            clear sys4
        end
    end
    pmaxx=max([pmaxx ydmax] + (1/48));  % add half hour
    fprintf('pmaxx %.2f \n',pmaxx);
    %% now plot
    figure(1); clf;  % atmp, hrh
    set(gcf,'Name','AT_RH');
    subplot(2,1,1);    %atmp
    hold on
    if exist('sys1','var'), line(sys1.yday,sys1.atmp,...
            'Color','blue');
    end
    if exist('sys2','var'), line(sys2.yday,sys2.atmp,...
            'Color','green');
    end
    ax=axis;
    ax(4) =max( [max(sys1.atmp),max(sys2.atmp)])+.2;
    axis([ pminx pmaxx ax(3:4)])
    %axis([ pminx pmaxx 12 21 ])
    hold on
    ylabel('atmp');
    title([titlemain atitle]);

    subplot(2,1,2);  %hrh
    hold on
    if exist('sys1','var'), line(sys1.yday,sys1.hrh,...
            'Color','blue'); end
    if exist('sys2','var'), line(sys2.yday,sys2.hrh,...
            'Color','green'); end
    if exist('sys3','var'), line(sys3.yday,sys3.hrh,...
            'Color','yellow'); end
    if exist('sys4','var'), line(sys4.yday,sys4.hrh,...
            'Color','red'); end
    ax=axis;
    axis([ pminx pmaxx ax(3:4)]);
    %axis([ pminx pmaxx 62 98 ])
    ylabel('hrh');
    hold on

    %%
    figure(2); clf; % sst & sal
    set(gcf,'Name','SST SSS');
    subplot(2,1,1);   %sst
    title([titlemain atitle]);
    if exist('sys1','var'), line(sys1.yday,sys1.sst,...
            'Color','blue'); end
    if exist('sys2','var'), line(sys2.yday,sys2.sst,...
            'Color','green'); end
    hold on;
    ylabel('sst');
    ax=axis;
    ax(4) =max( [max(sys1.sst),max(sys2.sst)])+.2;
    axis([pminx pmaxx ax(3:4)])
    %axis([ pminx pmaxx 15 27 ])

    subplot(2,1,2);  %sal

    %  salinity
    % 2011/04 removing the check on sal to accomodate gaps,
    % which are being plotted as solid line
    % gv1=find(sys1.sal > 30.); gv2=find(sys2.sal > 30.);
    gv1=1:length(sys1.sal); gv2=1:length(sys2.sal);
    if exist('sys1','var'), line(sys1.yday(gv1),real(sys1.sal(gv1)),...
            'Color','blue'); end
    if exist('sys2','var'), line(sys2.yday(gv2),real(sys2.sal(gv2)),...
            'Color','green'); end
    if exist('sys3','var'), line(sys3.yday,real(sys3.sal),...
            'Color','yellow'); end
    if exist('sys4','var'), line(sys4.yday,real(sys4.sal),...
            'Color','red'); end
    ax=axis;
    axis([pminx pmaxx ax(3:4)]);
    ylabel('sal');
    hold on;



    %%
    figure(3); clf; % bpr & prc
    set(gcf,'Name','BPR PRC');
    subplot(2,1,1); %bpr
    if exist('sys1','var'), line(sys1.yday,sys1.bpr,...
            'Color','blue'); end
    if exist('sys2','var'), line(sys2.yday,sys2.bpr,...
            'Color','green'); end
    ax=axis;
    ax(4)=max([ax(4) sys1.bpr sys2.bpr]) +.25;
    axis([ pminx pmaxx ax(3:4)]);
    ylabel('bpr'); title([titlemain atitle]);
    hold on

    subplot(2,1,2);    % rain
    if exist('sys1','var'), line(sys1.yday,sys1.rainr,...
            'Color','blue'); end
    if exist('sys2','var'), line(sys2.yday,sys2.rainr,...
            'Color','green'); end
    if exist('sys3','var'), line(sys3.yday,sys3.rainr,...
            'Color','yellow'); end
    if exist('sys4','var'), line(sys4.yday,sys4.rainr,...
            'Color','red'); end
    ax=axis;
    axis([pminx pmaxx ax(3) ax(4) ]);
    ylabel('rain rate');
    hold on

    %%
    figure(4); clf; % swr, lwr
    set(gcf,'Name','SWR LWR');
    subplot(2,1,1);  % swr
    if exist('sys1','var'), swrl1=line(sys1.yday,sys1.swr,...
            'Color','blue'); end
    if exist('sys2','var'), swrl2=line(sys2.yday,sys2.swr,...
            'Color','green');
    end
    if exist('sys3','var'), line(sys3.yday,sys3.swr,...
            'Color','yellow'); end
    if exist('sys4','var'), line(sys4.yday,sys4.swr,...
            'Color','red'); end
    ax=axis;
    axis([ pminx pmaxx ax(3:4) ]);
    ylabel('swr')
    title([titlemain atitle]);
    hold on

    subplot(2,1,2); % lwr
    if exist('sys1','var'), line(sys1.yday,sys1.lwr,...
            'Color','blue'); end
    if exist('sys2','var'), line(sys2.yday,sys2.lwr,...
            'Color','green'); end
    if exist('sys3','var'), line(sys3.yday,sys3.lwr,...
            'Color','yellow'); end
    if exist('sys4','var'), line(sys4.yday,sys4.lwr,...
            'Color','red'); end
    ax=axis;
    axis([ pminx pmaxx ax(3:4)]);
    ylabel('lwr');
    hold on

    %%
    figure(5); clf; % wind spd & dir
    set(gcf,'Name','Wind');
    subplot(2,1,1);   % wspd
    if exist('sys1','var'), plot(sys1.yday,sys1.wnds,...
            'Color','blue'); end
    if exist('sys2','var'), plot(sys2.yday,sys2.wnds,...
            'Color','green'); end
    ax=axis;
    axis([pminx pmaxx ax(3:4)])
    ylabel('WSPD');
    hold on
    title([titlemain atitle]);
    %
    subplot(2,1,2);   %wndd
    if exist('sys1','var'), line(sys1.yday,sys1.wndd,...
            'Color','blue');

    end
    if exist('sys2','var'), line(sys2.yday,sys2.wndd,...
            'Color','green');
    else
        fprintf('no sys 2\n');
    end
    ax=axis;
    axis([pminx pmaxx ax(3:4)])
    ylabel('WDIR');
    hold on
end

