% mk_mat_pod.m
% temperature sensors: 10983 10984 10986 11177
% pressure sensors: 9791 9792
%%%%%%%%%%% need positions for sam1 and sam2 for tracer 2

if sam == 1
  % for deployment 1 - hardwired start time 8/30(yd=241) 2300Z
  st_time=241+23/24;
  dt=5/60/60/24;
  % position on wire 
  h11177 = -28;
  h10986 = -16;
  % sled at 0
  h10983 = 16;% above sled
  h9792  = 20; 
  h9791 = 28;
  h10984 = 33;
  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;
  % height:
  h11177 = -30;
  h10986 = -15;
  % sled at 0
  h10983 = 15;
  h9792  = 20;
  h10984 = 30;
  h9791  = 35;
  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;
  % height:
  h11177 = -30;
  h10984 = -15;
  % sled at 0
  h10983 = 15;
  h9792  = 20;
  h10986 = 30;
  h9791  = 35;
  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;
  % height:
  h11177 = -30;
  h10986 = -15;
  % sled at 0
  h10983 = 15;
  h9791  = 20;
  h10984 = 30;
  h9792  = 35;
  tow_start = 245.0417;
  tow_end = 245.5004;
elseif sam == 5
  % for deployment 5 - hardwired start time 9/2(yd=245) 1900Z
  st_time=245+19/24;
  dt=5/60/60/24;
  % height:
  h11177 = 0;
  h10986 = 0;
  % sled at 0
  h10983 = 0;
  h9791  = 0;
  h10984 = 0;
  h9792  = 0;
  tow_start = 245.8440;
  tow_end = 245.8819;
  sam=6
else
  error('fill in values for this cast')
  keyboard
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');
h1_str=['9791 ',num2str(h9791),'m'];
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');

h2_str=['9792 ',num2str(h9792),'m'];

% CTD
eval(['load ../sled/SAM_00',int2str(sam),'_fl'])
bb=find(sampl==1);
h(3)=plot(yearday(bb),press(bb),'m');
s_str='sled at 0m';

ax=axis;
axis([tow_start tow_end ax(3:4)])

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

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

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

%%%%%%%%%%%%%%%
if 0
% 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');
h1_str=['10983 ',num2str(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');
h2_str=['10984 ',num2str(h10984),'m'];

%%%%%%%%%%%%%%%
% 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');
h3_str=['10986 ',num2str(h10986),'m'];

%%%%%%%%%%%%%%%
% 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;

te11177=xxx;
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');
h4_str=['11177 ',int2str(h11177),'m'];

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

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

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