
% routine to overlay mocness haul positions on drifter tracks

% First, put down drifter tracks
sumplt
hold on;

load /data5/jmanning/ship/oc303/ship
sh=d;
clear d;

%Second, assuming events.wb2 printed out sorted file of instruments
load /home3/ocn/jmanning/gbs97/text/o303sort.txt
d=o303sort;

% define instrument of taste
% where:  zpn  pump m1/4  M1 drift bongo
%       = 1    2    3    4    5    6
% in a file with:
% lat lon sta haul day hhmm code s/e(0/1)
%  1   2  3   4    5   6    7    8
inst=4;
id=find(d(:,7)==inst);


% plot this instruments start & stop
half=length(id)/2
vec=input('Enter vector of sequential tows wanted: ')
kk=0;
for k=vec;
  kk=kk+1;
  for i=1:half;
    if d(id(i),4)==k;
      cl=rem(i,10)+1;
%      plot([d(id(i),2) d(id(i)+half,2)],[d(id(i),1) d(id(i)+half,1)],...
%       'linewidth',1,'color',['c',num2str(cl)]);
      text(d(id(i),2),d(id(i),1),num2str(d(id(i),4)),...
       'color',['c',num2str(cl)]);
%     put a dot on drifter track
      jd1=julian(5,d(id(i),5),97,d(id(i),6));
      jd2=julian(5,d(id(i)+half,5),97,d(id(i)+half,6));
%     note: we need to add four hours to Moc's time
      idd=find(yy(:,1)>=jd1+4/24&yy(:,1)<=jd2+4/24);
      ids=find(sh(:,4)>=jd1+4/24&sh(:,4)<=jd2+4/24);
%      pltdrft(yy(idd,3),yy(idd,2),cl,0,97,yy(idd,1));  
      plot(yy(idd,2),yy(idd,3),...  
         'color',['c',num2str(cl)],'linewidth',6);
      plot(sh(ids,5),sh(ids,6),'-',...
        'color',['c',num2str(cl)],'linewidth',3);
    end;
  end;
  myd(kk)=(jd2+jd1)/2+4/24;
end;

y=[myd;vec];
fploopy(y','/home3/ocn/jmanning/gbs97/moc/s154.pre','o');

