%  plot_ship_8 panel - plot  shipboard data
%%%% get some (all?) user-supplied params

title2='VOS: black';

addpath([matlabroot '/work']);

%%%% get all the data first
% truncate as you load, for better auto-axis ranges
%
load( 'vos1hr.mat');
    
iidx=find(voa.yday > (pmaxx - daystoplot));
% fprintf('vos: %d cut to %d\n', length(vos.yday),...
%     length(iidx));
vos=structtrunc(vos,iidx);

load('data/hourly/baro.mat');
iidx=find(baro.yday > (pmaxx - daystoplot));
% fprintf('baro: %d cut to %d\n', length(baro.yday),...
%     length(iidx));
baro=structtrunc(baro,iidx);

load('data/hourly/sst.mat');
iidx=find(sst.yday > (pmaxx - daystoplot));
% fprintf('sst: %d cut to %d\n', length(sst.yday),...
%     length(iidx));
sst=structtrunc(sst,iidx);

load('data/hourly/tsg.mat');
iidx=find(tsg.yday > (pmaxx - daystoplot));
% fprintf('tsg: %d cut to %d\n', length(tsg.yday),...
%     length(iidx));
tsg=structtrunc(tsg,iidx);

load('data/hourly/wind.mat');
iidx=find(wind.yday > (pmaxx - daystoplot));
% fprintf('wind: %d cut to %d\n', length(wind.yday),...
%     length(iidx));
wind=structtrunc(wind,iidx);

load('data/hourly/rain.mat');
iidx=find(rain.yday > (pmaxx - daystoplot));
% fprintf('rain: %d cut to %d\n', length(rain.yday),...
%     length(iidx));
rain=structtrunc(rain,iidx);

%%%% Now plot the whole mess
%%% add editing clauses as needed
%
figure(1);  clf

subplot(4,2,1);    %atmp
line(vos.yday,vos.atmp,'Color','black','LineStyle','--')
ylabel('atmp');
hold on
title(titlemain);
%       if exist('vosH','var'),
%          line(vosH.yday,vosH.atmp,'r.'); end
ax=axis;
axis([ pminx pmaxx ax(3:4) ]);
% %   axis([ pminx pmaxx 5 27 ]);

subplot(4,2,2);   %sst
line(sst.yday,sst.sst,'Color','yellow','LineStyle',':');
hold on
title(title2);
%      if exist('sstH','var'),
%         line(sstH.yday,sstH.sst,'r.'); end
line(tsg.yday,tsg.stmp,'Color','black','LineStyle','--');
%      if exist('tsgH','var'),
%         line(tsgH.yday,tsgH.stmp,'r.'); end
ylabel('sst (tsg)');
 ax=axis;
 axis([ pminx pmaxx ax(3:4)]);
% maxty=max(tsg.stmp(find(tsg.stmp < 50)));
% minty=min(tsg.stmp(find(tsg.stmp> 10)));
% axis([ pminx pmaxx minty maxty ]);
hold on

subplot(4,2,3); %bpr
%line(baro.yday,baro.bpr,'Color','yellow','LineStyle',':');
line(baro.yday,baro.bpr_cor,'Color','black','LineStyle','--');
ylabel('bpr');
hold on
 ax=axis;
 axis([ pminx pmaxx ax(3:4)]);
% axis([ pminx pmaxx 1005 1025]);

subplot(4,2,4);  %hrh
line(vos.yday,vos.hrh,'Color','black',...
    'LineStyle','--')
ylabel('hrh');
hold on
ax=axis;
axis([ pminx pmaxx ax(3:4)]);
% minty=min(vos.hrh(find(vos.hrh > 30))) -5;
% maxty=max(vos.hrh(find(vos.hrh < 110))) +5;
% axis([ pminx pmaxx minty maxty ]);

subplot(4,2,5);  % swr
line(vos.yday,vos.swr,'Color','black', 'LineStyle',...
    '--');
ylabel('swr')
hold on
ax=axis;
axis([ pminx pmaxx ax(3:4)]);
% axis([ pminx pmaxx -5 1050 ]);

subplot(4,2,6);    % lwr
line(vos.yday,vos.lwr,'Color','black','LineStyle','--');
% ,...     'Marker','.','MarkerSize',2);
ylabel('lwr')
hold on
ax=axis;
axis([ pminx pmaxx ax(3) ax(4)]);
% minty=min(vos.lwr(find(vos.lwr > 90))) -40;
%      axis([ pminx pmaxx 320 450 ]);

subplot(4,2,7);    % rain
gr=find(rain.imet_rain < 60);

line(rain.yday(gr(2:end)),diff(rain.imet_rain(gr)),'Color','black',...
    'LineStyle','--');
if isfield(rain,'hrainrate')
  line(rain.yday, rain.hrainrate,'Color','yellow',...
      'LineStyle',':');
end
ylabel('rain');
hold on
%      if exist('rainH','var'),
%         line(rainH.yday,rainH.imet_rain,'r.'); end
ax=axis;
axis([ pminx pmaxx -1 ax(4)]);
% %  axis([ pminx pmaxx -1 2]);

subplot(4,2,8);  %sal
gsal=find(tsg.sal > 20);
line(tsg.yday(gsal),tsg.sal(gsal),'Color','black','LineStyle',...
    '--');
ylabel('sal');
hold on
%      if exist('tsgH','var'),
%         line(tsgH.yday,tsgH.sal,'r.'); end
ax=axis;
axis([ pminx pmaxx ax(3:4)]);


% 
% subplot(4,2,1);   % wspd
% line(wind.yday,wind.wspd,'Color','black','LineStyle','--');
% ylabel('WSPD');
% hold on
% %      if exist('windH','var'),
% %         line(windH.yday,windH.rwspd,'r.'); end
% title(titlemain);
% % ax=axis;
% % axis([ pminx pmaxx ax(3:4)]);
% % axis([ pminx pmaxx -1 2]);
% subplot(4,2,2);  %wdir
% line(wind.yday,wind.wdir,'Color','black','LineStyle','--');
% ylabel('WDIR');
% hold on
% %      if exist('windH','var'),
% %         line(windH.yday,windH.rwdir,'r.'); end
% title(title2);
% % ax=axis;
% % axis([ pminx pmaxx ax(3:4)]);
% % % axis([ pminx pmaxx -5 365 ]);
% 


