% plot_Argos_8_panel
% plot argos over scs data on ron brown
argos=load ('Argos.mat');
% set up plot
pminx = minx - (1/24);
pmaxx=maxx + (1/24);

stpt=find(argos.sys1.cond > 4, 1,'first');

fprintf('argos plot:pminx pmaxx %.2f %.2f\n',pminx,pmaxx);

if isfield(argos,'sys1'),
    fprintf('truncating sys1 %d pts %s to %s ',...
        length(argos.sys1.mday), datestr(argos.sys1.mday(1)), ...
        datestr(argos.sys1.mday(end)));
    argos.sys1=structtrunc(argos.sys1, find(argos.sys1.yday >= pminx));
    fprintf('to %d pts %s to %s\n',...
        length(argos.sys1.mday), datestr(argos.sys1.mday(1)), ...
        datestr(argos.sys1.mday(end)));
    atitle='sys1 ';
else
    fprintf('no sys1 in Argos.mat!\n');
end
if isfield(argos,'sys2')
    fprintf('truncating sys2 %d pts %s to %s ',...
        length(argos.sys2.mday), datestr(argos.sys2.mday(1)), ...
        datestr(argos.sys2.mday(end)));
    argos.sys2=structtrunc(argos.sys2, find(argos.sys2.yday >= pminx));
    fprintf('to %d pts %s to %s\n',...
        length(argos.sys2.mday), datestr(argos.sys2.mday(1)), ...
        datestr(argos.sys2.mday(end)));
      atitle=[atitle 'sys2 '];
    else
    fprintf('no sys2 in Argos.mat!\n');
end

if isfield(argos,'sys3')
     fprintf('truncating sys3 %d pts %s to %s ',...
        length(argos.sys3.mday), datestr(argos.sys3.mday(1)), ...
        datestr(argos.sys3.mday(end)));
    argos.sys3=structtrunc(argos.sys3, find(argos.sys3.yday >= pminx));
    fprintf('to %d pts %s to %s\n',...
        length(argos.sys3.mday), datestr(argos.sys3.mday(1)), ...
        datestr(argos.sys3.mday(end)));
     atitle=[atitle 'sys3 '];
    else
    fprintf('no sys3 in Argos.mat!\n');
end

if isfield(argos,'sys4')
     fprintf('truncating sys4 %d pts %s to %s ',...
        length(argos.sys4.mday), datestr(argos.sys4.mday(1)), ...
        datestr(argos.sys4.mday(end)));
    argos.sys4=structtrunc(argos.sys4, find(argos.sys4.yday >= pminx));
    fprintf('to %d pts %s to %s\n',...
        length(argos.sys4.mday), datestr(argos.sys4.mday(1)), ...
        datestr(argos.sys4.mday(end)));
     atitle=[atitle 'sys4'];
    else
    fprintf('no sys4 in Argos.mat!\n');
end
%
%% now plot
figure(1);  clf
subplot(4,2,1);  %wnds

if isfield(argos,'sys1'), plot(argos.sys1.yday, argos.sys1.wnds,...
        'Color','blue');  hold on; end
if isfield(argos,'sys2'), plot(argos.sys2.yday, argos.sys2.wnds,...
        'Color','green');  hold on; end
ylabel('WSPD');
ax=axis;
axis([pminx pmaxx ax(3:4)])
%axis([pminx pmaxx 2 12])
%
subplot(4,2,2);   %wndd
hold on
if isfield(argos,'sys1'), line(argos.sys1.yday, argos.sys1.wndd,...
        'Color','blue');  hold on;
  
end
if isfield(argos,'sys2'), line(argos.sys2.yday, argos.sys2.wndd,...
        'Color','green');  hold on;
else
    fprintf('no sys 2\n');
end
ylabel('WDIR');
title(atitle);
ax=axis;
axis([pminx pmaxx ax(3:4)])

subplot(4,2,3); % atmp
hold on
if isfield(argos,'sys1'), line(argos.sys1.yday, argos.sys1.atmp,...
        'Color','blue');  hold on;
end
if isfield(argos,'sys2'), line(argos.sys2.yday, argos.sys2.atmp,...
        'Color','green');  hold on;
end
ylabel('atmp');
ax=axis;
axis([ pminx pmaxx ax(3:4)])
%axis([ pminx pmaxx 12 21 ])

subplot(4,2,4); % sst
hold on
if isfield(argos,'sys1'), line(argos.sys1.yday, argos.sys1.sst,...
        'Color','blue');  hold on; end
if isfield(argos,'sys2'), line(argos.sys2.yday, argos.sys2.sst,...
        'Color','green');   hold on; end
ylabel('sst');
ax=axis;
% ax(4) =max( [max(sys1.sst),max(sys2.sst),max(tsg.stmp)])+.2;
axis([pminx pmaxx ax(3:4)])
%axis([ pminx pmaxx 15 27 ])


subplot(4,2,5); % bpr
hold on
if isfield(argos,'sys1'), line(argos.sys1.yday, argos.sys1.bpr,...
        'Color','blue');  hold on; end
if isfield(argos,'sys2'), line(argos.sys2.yday, argos.sys2.bpr,...
        'Color','green');  hold on; end
ylabel('bpr');
ax=axis;
axis([ pminx pmaxx ax(3:4)])
%axis([pminx pmaxx 1012 1020])

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

subplot(4,2,7); % swr
hold on
if isfield(argos,'sys1'), swrl1=line(argos.sys1.yday, argos.sys1.swr,...
        'Color','blue');  hold on;end
if isfield(argos,'sys2'), swrl2=line(argos.sys2.yday, argos.sys2.swr,...
        'Color','green'); hold on;
end
if isfield(argos,'sys3'), line(argos.sys3.yday, argos.sys3.swr,...
        'Color','yellow');  hold on;end
if isfield(argos,'sys4'), line(argos.sys4.yday, argos.sys4.swr,...
        'Color','red');  hold on;end
ylabel('swr')
%axis([pminx pmaxx -5 1100 ])
%mymxy = max(atmos.swr(find(atmos.swr < 1300))) + 10;
ax=axis;
%axis([ pminx pmaxx ax(3) mymxy ])
axis([ pminx pmaxx ax(3:4) ])

subplot(4,2,8)   ; % lwr
hold on
if isfield(argos,'sys1'), line(argos.sys1.yday, argos.sys1.lwr,...
        'Color','blue');  hold on;end
if isfield(argos,'sys2'), line(argos.sys2.yday, argos.sys2.lwr,...
        'Color','green'); hold on; end
if isfield(argos,'sys3'), line(argos.sys3.yday, argos.sys3.lwr,...
        'Color','yellow');  hold on;end
if isfield(argos,'sys4'), line(argos.sys4.yday, argos.sys4.lwr,...
        'Color','red');  hold on;end
ylabel('lwr')
ax=axis;
% ax(3)=min(atmos.swr) - 4;
% ax(4)=max(atmos.swr) + 10;
% axis([pminx pmaxx  340 450])
% axis([ax(1:2)  max([max(sys1.lwr) max(sys2.lwr)])]);
% ax=axis;
axis([ pminx pmaxx ax(3:4)])

% subplot(4,2,9);   % rainr
% hold on
% if isfield(argos,'sys1'), line(argos.sys1.yday, argos.sys1.rainr,...
%         'Color','blue');  hold on;end
% if isfield(argos,'sys2'), line(argos.sys2.yday, argos.sys2.rainr,...
%         'Color','green');  hold on;end
% if isfield(argos,'sys3'), line(argos.sys3.yday, argos.sys3.rainr,...
%         'Color','yellow'); hold on; end
% if isfield(argos,'sys4'), line(argos.sys4.yday, argos.sys4.rainr,...
%         'Color','red');  hold on;end
% ylabel('rain');
% ax=axis;
% %axis([pminx pmaxx -1.25 1.25 ]);
% axis([pminx pmaxx ax(3) ax(4) ]);
% 
% 
% subplot(4,2,10);  %sal
% hold on
% %  salinity
% gv1=find(argos.sys1.sal > 30.); gv2=find(argos.sys2.sal > 30.);
% if isfield(argos,'sys1'), line(argos.sys1.yday(gv1),real(argos.sys1.sal(gv1)),...
%         'Color','blue'); hold on; end
% if isfield(argos,'sys2'), line(argos.sys2.yday(gv2),real(argos.sys2.sal(gv2)),...
%         'Color','green');  hold on;end
% if isfield(argos,'sys3'), line(argos.sys3.yday,real(argos.sys3.sal),...
%         'Color','yellow'); hold on; end
% if isfield(argos,'sys4'), line(argos.sys4.yday,real(argos.sys4.sal),...
%         'Color','red');  hold on;end
% ylabel('sal');
% ax=axis;
% ymx=max(max([argos.sys1.sal; ]))+.1;
% axis([pminx pmaxx ax(3) (ymx+.1)])
%axis([ pminx pmaxx ax(3:4) ])
%fprintf('pminx %.2f pmaxx %.2f  ',pminx,pmaxx);


