% mk_mat_pod.m
% temperature sensors: 10983 10984 10986 11177
% pressure sensors: 9791 9792

if sam == 1
  % for deployment 1 - hardwired start time 7/26(yd=206) 2100Z
  st_time=206+21/24;
  dt=5/60/60/24;
  % position on wire (from 'wireout' reading)
  h11177 = 25;
  h10984 = 35;
  h10986 = 15;
  % sled at 45-50?
  h9792  = 30; % beyond sled
  h9791 = nan; % not on the wire
  h10983 = nan; % not on wire
  tow_start =207.0102;
  tow_end = 207.0177;
elseif sam == 2
  % for deployment 2 - hardwired start time 7/27(yd=207) 2300Z
  st_time=207+23/24;
  dt=5/60/60/24;
  dt11177=dt*3;
  % height:
  h10983 = -18.2;
  h10984 = -10.2;
  % sled at 0
  h10986 = 9.;
  h9792  = 13;
  h11177 = nan;
  h9791  = 24;
  tow_start = 208.0225;
  tow_end = 208.5013;
elseif sam == 3
  disp('no data for sample cast 3')
  keyboard
elseif sam == 4
  % for deployment 4 - hardwired start time 7/29(yd=209) 2300Z
  st_time=209+23/24;
  dt=5/60/60/24;
  % height:
  h10983 = -22.2;
  h10984 = -10.2;
  % sled at 0
  h10986 = 9.;
  h9791  = 13;
  h11177 = 21;
  h9792  = 25;
  tow_start = 210.0166;
  tow_end = 210.5011;
elseif sam == 5
  % for deployment 5 - hardwired start time 7/30(yd=210) 2300Z
  st_time=210+23/24;
  dt=5/60/60/24;
  % height:
  h10984 = -19.2;
  h10983 = -10.2;
  % sled at 0
  h10986 = 9.;
  h9791  = 12;
  h11177 = 18;
  h9792  = 21;
  tow_start = 211.0235;
  tow_end = 211.501;
elseif sam == 6
  % for deployment 6 - hardwired start time 7/31(yd=211) 2300Z
  st_time=211+23/24;
  dt=5/60/60/24;
  % height:
  h10984 = 999; % get this info!
  h10983 = 999; % get this info!
  % sled at 0
  h10986 = 18;
  h9791  = 12;
  h11177 = 9;
  h9792  = 21;
  tow_start = 211.9858;
  tow_end = 212.4699;
elseif sam == 7
  % for deployment 7 - hardwired start time 8/1(yd=212) 2300Z
  st_time=212+23/24;
  dt=5/60/60/24;
  % height:
  h10984 = -20.2;
  h10983 = -10.2;
  % sled at 0
  h10986 = 12.6;
  h9791  = 15.6;
  h11177 = 23.6;
  h9792  = 27.6;
  tow_start = 213.0412;
  tow_end = 213.5244;
end

figure(1)
clf
clear h
% RBR DR-1050  3.50 009791
% get start time and interval

% this produces a vector of data
eval(['!tail +15 s',int2str(sam),'_009791.dat >xxx'])
load xxx
ttt=[0:length(xxx)-1]*dt+st_time;

pr9791=xxx;
ti9791=ttt;

eval(['save s',int2str(sam),'_009791 pr9791 ti9791 h9791'])  

aa=find(ttt >= tow_start & ttt <= tow_end);
h(1)=plot(ttt(aa),xxx(aa),'b');
if sam == 1
  h1_str=['9791 ',int2str(h9791),'m beyond sled'];
else
  h1_str=['9791 ',int2str(h9791),'m'];
end
hold on

%%%%%%%%%%%%%%%
% RBR DR-1050  3.50 009792 
% get start time and interval

% this produces a vector of data
eval(['!tail +15 s',int2str(sam),'_009792.dat >xxx'])
load xxx
ttt=[0:length(xxx)-1]*dt+st_time;

pr9792=xxx;
ti9792=ttt;
eval(['save s',int2str(sam),'_009792 pr9792 ti9792 h9792'])

aa=find(ttt >= tow_start & ttt <= tow_end);
h(2)=plot(ttt(aa),xxx(aa),'g');

if sam == 1
  h2_str=['9792 ',int2str(h9792),'m beyond sled'];
else
  h2_str=['9792 ',int2str(h9792),'m'];
end
s_str='sled at 0m';
legend(h,h1_str,h2_str,s_str)

xlabel('Yearday 2005')
ylabel('Pressure (dbar)')
title(['RBR DR-1050 data from Sample Tow: ',int2str(sam)])
axis ij

eval(['print -dpng sam',int2str(sam),'_p'])

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

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

% this produces a vector of data
eval(['!tail +15 s',int2str(sam),'_010983.dat >xxx'])
load xxx
ttt=[0:length(xxx)-1]*dt+st_time;

te10983=xxx;
ti10983=ttt;
eval(['save s',int2str(sam),'_010983 te10983 ti10983 h10983'])

aa=find(ttt >= tow_start & ttt <= tow_end);
h(1)=plot(ttt(aa),xxx(aa),'b');
if sam == 1
  h1_str=['10983 ',int2str(h10983),'m'];
else
  h1_str=['10983 ',int2str(h10983),'m'];
end
hold on

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

% this produces a vector of data
eval(['!tail +15 s',int2str(sam),'_010984.dat >xxx'])
load xxx
ttt=[0:length(xxx)-1]*dt+st_time;

te10984=xxx;
ti10984=ttt;
eval(['save s',int2str(sam),'_010984 te10984 ti10984 h10984'])

aa=find(ttt >= tow_start & ttt <= tow_end);
h(2)=plot(ttt(aa),xxx(aa),'g');
if sam == 1
  h2_str=['10984 ',int2str(h10984),'m'];
else
  h2_str=['10984 ',int2str(h10984),'m'];
end

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

% this produces a vector of data
eval(['!tail +15 s',int2str(sam),'_010986.dat >xxx'])
load xxx
ttt=[0:length(xxx)-1]*dt+st_time;

te10986=xxx;
ti10986=ttt;
eval(['save s',int2str(sam),'_010986 te10986 ti10986 h10986'])

aa=find(ttt >= tow_start & ttt <= tow_end);
h(3)=plot(ttt(aa),xxx(aa),'r');
if sam == 1
  h3_str=['10986 ',int2str(h10986),'m'];
else
  h3_str=['10986 ',int2str(h10986),'m'];
end


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

% this produces a vector of data
eval(['!tail +15 s',int2str(sam),'_011177.dat >xxx'])
load xxx
ttt=[0:length(xxx)-1]*dt+st_time;

if sam == 2
  te11177=xxx*nan; % this instrument was not set for this cast - has
		   % old data
  xxx=xxx*nan;		 
else
  te11177=xxx;
end

ti11177=ttt;
eval(['save s',int2str(sam),'_011177 te11177 ti11177 h11177'])

aa=find(ttt >= tow_start & ttt <= tow_end);
h(4)=plot(ttt(aa),xxx(aa),'c');
if sam == 1
  h4_str=['11177 ',int2str(h11177),'m'];
else
  h4_str=['11177 ',int2str(h11177),'m'];
end

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('Temperature (^oC)')
title(['RBR-TR-1050 data from Sample Tow: ',int2str(sam)])

eval(['print -dpng sam',int2str(sam),'_t'])








