% this one generates sig and plots it also
% temperature sensors: 10983 10984 10986 11177
% pressure sensors: 9791 9792

load cal_tpods

eval(['load s',int2str(sam),'_010983'])
eval(['load s',int2str(sam),'_010984'])
eval(['load s',int2str(sam),'_010986'])
eval(['load s',int2str(sam),'_011177'])

if sam == 1
  % for deployment 1 - hardwired start time 8/30(yd=241) 2300Z
  st_time=241+23/24;
  dt=5/60/60/24;
  tow_start = 242.0414;
  tow_end = 242.5280;
elseif sam == 2
  % for deployment 2 - hardwired start time 8/31(yd=242) 2300Z
  st_time=242+23/24;
  dt=5/60/60/24;
  tow_start = 243.0413;
  tow_end = 243.5064;
elseif sam == 3
  % for deployment 3 - hardwired start time 9/1(yd=243) 1900Z
  st_time=243+19/24;
  dt=5/60/60/24;
  tow_start = 244.0420;
  tow_end = 244.5012;
elseif sam == 4
  % for deployment 4 - hardwired start time 9/2(yd=244) 1900Z
  st_time=244+19/24;
  dt=5/60/60/24;
  tow_start = 245.0417;
  tow_end = 245.5004;
elseif sam == 6
  % for deployment 6 - hardwired start time 9/3(yd=245) 1900Z
  st_time=245+19/24;
  dt=5/60/60/24;
  tow_start = 245.9987;
  tow_end = 246.4701;
  
elseif sam == 7
  % for deployment 7 - hardwired start time 9/4(yd=246) 2300Z
  st_time=246+23/24;
  dt=5/60/60/24;
  tow_start = 247.0450;
  tow_end = 247.50;
  
elseif sam == 8
  % for deployment 8 - hardwired start time 9/5(yd=247) 2300Z
  st_time=247+23/24;
  dt=5/60/60/24;
  tow_start = 248.0218;
  tow_end = 248.4787;
  
elseif sam == 9
  % for deployment 9 - hardwired start time 9/7(yd=249) 2300Z
  st_time=249+23/24;
  dt=5/60/60/24;
  tow_start = 250.1003;
  tow_end = 250.5638;
  
elseif sam == 10
  % for deployment 10 - hardwired start time 9/8(yd=250) 2300Z
  st_time=250+23/24;
  dt=5/60/60/24;
  tow_start = 251.0066;
  tow_end = 251.5036;
  
elseif sam == 11
  % for deployment 11 - hardwired start time 9/8(yd=250) 2300Z
  st_time=250+23/24;
  dt=5/60/60/24;
  tow_start = 251.0066;
  tow_end = 251.5036;
  
elseif sam == 13
  % for deployment 13 - hardwired start time 9/8(yd=250) 2300Z
  st_time=252+23/24;
  dt=5/60/60/24;
  tow_start = 253.0362;
  tow_end = 253.5237;
  
else
  error('fill in values for this cast')
  keyboard
end

figure(1)
clf
clear h
%%%%%%%%%%%%%%%

% CTD
if sam < 10
  eval(['load ../sled/SAM_00',int2str(sam),'_fl'])
else
  eval(['load ../sled/SAM_0',int2str(sam),'_fl'])
end
bb=find(sampl==1);
s_str='sled at 0m';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Temp.
figure(2)
clf
clear h

%%%%%%%%%%%%%%%

% RBR TR-1050  3.50 010983 (Windows: 5.14)
% get start time and interval

aa=find(ti10983 >= tow_start & ti10983 <= tow_end);
h(1)=plot(ti10983(aa),sig10983(aa),'b');
h1_str=['10983 ',num2str(h10983),'m'];

hold on

%%%%%%%%%%%%%%%
% RBR TR-1050  3.50 010984
% get start time and interval

aa=find(ti10984 >= tow_start & ti10984 <= tow_end);
h(2)=plot(ti10984(aa),sig10984(aa),'g');
h2_str=['10984 ',num2str(h10984),'m'];

%%%%%%%%%%%%%%%
% RBR TR-1050  3.50 010986
% get start time and interval

aa=find(ti10986 >= tow_start & ti10986 <= tow_end);
h(3)=plot(ti10986(aa),sig10986(aa),'r');
h3_str=['10986 ',num2str(h10986),'m'];

%%%%%%%%%%%%%%%
% RBR TR-1050  3.50 011177
% get start time and interval

aa=find(ti11177 >= tow_start & ti11177 <= tow_end);
h(4)=plot(ti11177(aa),sig11177(aa),'c');
h4_str=['11177 ',int2str(h11177),'m'];

% CTD
h(5)=plot(yearday(bb),sigma0(bb),'m');
s_str='sled at 0m';
ax=axis;
axis([tow_start tow_end ax(3:4)])
axis ij

legend(h,h1_str,h2_str,s_str)

legend(h,'10983','10984','10986','11177')
s_str='sled at 0m';
legend(h,h1_str,h2_str,h3_str,h4_str,s_str)

xlabel('Yearday 2005')
ylabel('\sigma_\theta')
if sam < 6
  title(['Computed Sigma from Tpods for Sample Tow: ',int2str(sam)])
else
  title(['Computed Sigma from Tpods for Sample Tow: ',int2str(sam-1)])
end

%if sam == 4
%  ax=axis;
%  axis([ax(1:2)  18.9 22.5])  
%end

orient portrait
eval(['print -dpng sam',int2str(sam),'_sig'])
orient landscape
