% plt_flt.m - to plot flight data
% this one for sampling casts

set(0,'defaultaxesfontsize',12)
mat_path = './';

cast = input('Enter cast number: ');
if cast < 10
  fn = ['SAM_00',int2str(cast)];
elseif cast < 100
  fn = ['SAM_0',int2str(cast)];
else
  fn = ['SAM_',int2str(cast)];
end

blue = [.2 .2 1];
eval(['load ',mat_path,fn,'_fl'])

figure

ind=find(sampl==1);

%%%% SIGMA0

subplot(5,1,1)
hold off
plot(yearday,sigma0,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),sigma0(ind),'linewidth',.1,'color','blue')
set(gca,'ydir','reverse','xticklabel',' ')

ylabel('\sigma_\theta (kg/m^3)')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(sigma0) nanmax(sigma0)])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
	26.24 nanmax(sigma0) ])
elseif cast == 3
  axis([yearday(1) yearday(length(yearday)) ...
	26.245 26.27 ])
elseif cast == 4
  axis([yearday(1) yearday(length(yearday)) ...
	26.24 26.275 ])
elseif cast == 6
  axis([yearday(1) yearday(length(yearday)) ...
	26.25 26.27 ])
elseif cast == 7
  axis([yearday(1) yearday(length(yearday)) ...
	26.24 26.275 ])
elseif cast == 8
  axis([yearday(1) yearday(length(yearday)) ...
	26.245 nanmax(sigma0) ])
elseif cast == 9
  axis([yearday(1) yearday(length(yearday)) ...
	26.2 26.3])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(sigma0) nanmax(sigma0) ])
end
grid

%%%% TEMPERATURE
mint = nanmin([temp0; temp1]);
maxt = nanmax([temp0; temp1;]);

subplot(5,1,2)
hold off
plot(yearday,temp0,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),temp0(ind),'linewidth',.1,'color','blue')
plot(yearday(ind),temp1(ind),'linewidth',.5,'color',[0 1 0])

ylabel(['Temp. (^o C)'])
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) mint maxt])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) mint 19.35])
else
  axis([yearday(1) yearday(length(yearday)) mint maxt])
end
set(gca,'xticklabel',' ')
grid

%%%% SALINITY

subplot(5,1,3)
hold off
plot(yearday,sal0,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),sal0(ind),'linewidth',.1,'color','blue')
ylabel('Salinity (PSU)')
ax = axis;
set(gca,'xticklabel',' ')
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) ...
	36.7 nanmax(sal0)])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
	36.695 36.715])
elseif cast == 3
  axis([yearday(1) yearday(length(yearday)) ...
	36.695 36.708])
elseif cast == 4
  axis([yearday(1) yearday(length(yearday)) ...
	36.695  nanmax(sal0)])
elseif cast == 6
  axis([yearday(1) yearday(length(yearday)) ...
	36.685  36.71])
elseif cast == 7
  axis([yearday(1) yearday(length(yearday)) ...
	36.698  36.71])
elseif cast == 8
  axis([yearday(1) yearday(length(yearday)) ...
	36.69 nanmax(sal0)])
elseif cast == 9
  axis([yearday(1) yearday(length(yearday)) ...
	36.69 36.725])
elseif cast == 10
  axis([yearday(1) yearday(length(yearday)) ...
	36.7 nanmax(sal0)])
elseif cast == 11
  axis([yearday(1) yearday(length(yearday)) ...
	36.695 nanmax(sal0)])
elseif cast == 13
  axis([yearday(1) yearday(length(yearday)) ...
	36.7 nanmax(sal0)])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(sal0) nanmax(sal0)])
end
grid

%%%% PRESSURE

subplot(5,1,5)
hold off
plot(yearday,press,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),press(ind),'linewidth',.1,'color','blue')
ylabel('Pressure (db)')
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
	70 nanmax(press)])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(press) nanmax(press)])
end
grid

set(gca,'ydir','reverse')
orient landscape
xlabel('Yearday 2005')
wysiwyg

%%%% Chlorophyll
subplot(5,1,4)
hold off
plot(yearday,fl,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),fl(ind),'linewidth',.1,'color','blue')
ylabel('Chlor. (\mug/l)')
ax = axis;
set(gca,'xticklabel',' ')
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) ...
	0 2])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 2])
elseif cast == 6
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 6])
elseif cast == 7
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 6])
elseif cast == 8
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 2])
elseif cast == 9
  axis([yearday(1) yearday(length(yearday)) ...
      0 5])
elseif cast == 10
  axis([yearday(1) yearday(length(yearday)) ...
      0 1.5])
elseif cast == 11
  axis([yearday(1) yearday(length(yearday)) ...
      0 1.5])
elseif cast == 13
  axis([yearday(1) yearday(length(yearday)) ...
      0 1.5])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(fl) nanmax(fl)])
end
grid
%orient landscape
wysiwyg
orient portrait
eval(['print -dpng ',fn,'_timeseries_fl.png'])
orient landscape

%%%%%%%%%% now plot'em by themselves %%%%%%%%%%%%

%%%% sigma
figure
plot(yearday,sigma0,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),sigma0(ind),'linewidth',.1,'color','blue')
ylabel('Sigma0 (kg/m^3)')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(sigma0) nanmax(sigma0)])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
	26.24 nanmax(sigma0) ])
elseif cast == 3
  axis([yearday(1) yearday(length(yearday)) ...
	26.245 26.27 ])
elseif cast == 4
  axis([yearday(1) yearday(length(yearday)) ...
	26.24 26.275 ])
elseif cast == 6
  axis([yearday(1) yearday(length(yearday)) ...
	26.25 26.27 ])
elseif cast == 7
  axis([yearday(1) yearday(length(yearday)) ...
	26.24 26.275 ])
elseif cast == 8
  axis([yearday(1) yearday(length(yearday)) ...
	26.245 nanmax(sigma0) ])
elseif cast == 9
  axis([yearday(1) yearday(length(yearday)) ...
	26.2 26.3])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(sigma0) nanmax(sigma0)])
end
grid
set(gca,'ydir','reverse')
xlabel('Yearday 2005')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
orient portrait
eval(['print -dpng ',fn,'_ts_sig.png'])
orient landscape
wysiwyg

%%%%% temperature
tf = figure;
plot(yearday,temp0,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),temp0(ind),'linewidth',.1,'color','blue')
plot(yearday(ind),temp1(ind),'linewidth',.1,'color',[0 .5 0])

ylabel(['Temperature (^o C)'])
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) mint maxt])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) mint 19.35])
else
  axis([yearday(1) yearday(length(yearday)) mint maxt])
end
grid
xlabel('Yearday 2005')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
orient portrait
eval(['print -dpng ',fn,'_time_temp.png'])
orient landscape
wysiwyg

%%%% Salinity
figure
hold off
plot(yearday,sal0,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),sal0(ind),'linewidth',.1,'color','blue')
ylabel('Salinity (PSU)')
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) ...
	36.7 nanmax(sal0)])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
	36.695 36.715])
elseif cast == 3
  axis([yearday(1) yearday(length(yearday)) ...
	36.695 36.708])
elseif cast == 4
  axis([yearday(1) yearday(length(yearday)) ...
	36.695  nanmax(sal0)])
elseif cast == 6
  axis([yearday(1) yearday(length(yearday)) ...
	36.685  36.71])
elseif cast == 7
  axis([yearday(1) yearday(length(yearday)) ...
	36.698  36.71])
elseif cast == 8
  axis([yearday(1) yearday(length(yearday)) ...
	36.69 nanmax(sal0)])
elseif cast == 9
  axis([yearday(1) yearday(length(yearday)) ...
	36.69 36.725])
elseif cast == 10
  axis([yearday(1) yearday(length(yearday)) ...
	36.7 nanmax(sal0)])
elseif cast == 11
  axis([yearday(1) yearday(length(yearday)) ...
	36.695 nanmax(sal0)])
elseif cast == 13
  axis([yearday(1) yearday(length(yearday)) ...
	36.7 nanmax(sal0)])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(sal0) nanmax(sal0)])
end
grid
xlabel('Yearday 2005')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
orient portrait
eval(['print -dpng ',fn,'_time_sal.png'])
orient landscape
wysiwyg

%%%% Chlorophyll
figure
hold off
plot(yearday,fl,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),fl(ind),'linewidth',.1,'color','blue')
ylabel('Chlorophyll (\mug/l')
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 1
  axis([yearday(1) yearday(length(yearday)) ...
	0 2])
elseif cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 2])
elseif cast == 6
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 6])
elseif cast == 7
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 6])
elseif cast == 8
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) 2])
elseif cast == 9
  axis([yearday(1) yearday(length(yearday)) ...
      0 5])
elseif cast == 10
  axis([yearday(1) yearday(length(yearday)) ...
      0 1.5])
elseif cast == 11
  axis([yearday(1) yearday(length(yearday)) ...
      0 1.5])
elseif cast == 13
  axis([yearday(1) yearday(length(yearday)) ...
      0 1.5])
else
  axis([yearday(1) yearday(length(yearday)) ...
      nanmin(fl) nanmax(fl)])
end
grid
xlabel('Yearday 2005')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
orient portrait
eval(['print -dpng ',fn,'_time_chl.png'])
orient landscape
wysiwyg

%%%% Pressure
figure
plot(yearday,press,'linewidth',.1,'color','k')
hold on
plot(yearday(ind),press(ind),'linewidth',.1,'color','blue')
ylabel('Pressure (dbar)')
ax = axis;
%axis([yearday(1) yearday(length(yearday)) ax(3:4)])
if cast == 2
  axis([yearday(1) yearday(length(yearday)) ...
	70 nanmax(press)])
else
  axis([yearday(1) yearday(length(yearday)) ...
	nanmin(press) nanmax(press)])
end
grid
xlabel('Yearday 2005')
title(['Cast: ',fn,' - ','Flight',' cast'],'interpreter','none')
set(gca,'ydir','reverse')
orient portrait
eval(['print -dpng ',fn,'_time_press.png'])
orient landscape
wysiwyg



