function gb_plotD
% plots drifter tracks and wind
% stress for event D
% 4/1/01

clear
clf

% set start, stop times
dt=5;
t0=56;
tstart=[t0 t0+dt t0+2*dt t0+3*dt];
tstop=tstart+dt;

% start outer loop
V=[-69 -65.5 40 42.5];
for plnum=1:4
   subplot(2,2,plnum)
   axis(V)
   gbmapss2(V)
   hold on
   gb_plot96(tstart(plnum),tstop(plnum));
   aspect5(41);
   hold on
end

function gb_plot96(tstart,tstop)
% gb_plot96(tstart,tstop) plots tracks of all drifters 
% on bank during the time between tstart and tstop
% 4/2/01

% convert time to drifter time
tstart=yd2dd(tstart,1996);
tstop=yd2dd(tstop,1996);

%load data
load gb10mallA
t=z(:,1);
load windstress96

% set start, stop times
dt=5;
t1=[tstart:dt:tstop-dt];
t2=t1+dt;
N=length(t1);

V=[-69 -65.5 40 42.5];

% start loop
for n=1:N
   gbmapss2(V)
   aspect5(41);
   axis(V);
   hold on
   % extract all drifter data for time window
   k=find(t>=t1(n) & t<=t2(n));
   zn=z(k,:);
   % specify which drifters NOT to plot
   RD=1;
   if RD==1;
      DP=[46,54,57];
      nDP=length(DP);
      for ndp=1:nDP
         nnn=find(zn(:,8)==DP(ndp));
         zn(nnn,:)=[];
      end
   end
   znew=reconfig1(zn);
   % plot all drifters
   kk=find(isnan(znew(:,1)));
   h=plot(znew(:,2),znew(:,3));set(h,'linewidth',2);
   plot(znew(kk-1,2),znew(kk-1,3),'r*')
   % text(znew(kk-1,2),znew(kk-1,3)+.1,int2str(znew(kk-1,8)))
   
   % label period
   pdate=[dd2cd1(t1(n)),' - ',dd2cd1(t2(n))];
   title(pdate);
     
   % plot mean wind stress
   err=0.01;
   K=find(dd2yd(t1(n))-err<=t96 & t96<=dd2yd(t2(n))+err);
   txm=mean(tx96(K));
   tym=mean(ty96(K));
   xst1=-66.75;yst1=41.75;
   KK=2;
   KXY=.755;
   yst2=yst1+KK.*tym;
   xst2=xst1+KK.*txm./KXY;
   h=plot([xst1 xst2],[yst1 yst2],'g',xst2,yst2,'g*');
   set(h,'linewidth',2);
      
   % plot wind stress scale
   xst1=-66.5;yst1=40.2;
   KK=2;
   KXY=.755;
   yst2=yst1;
   xst2=xst1+KK.*.2./KXY;
   h=plot([xst1 xst2],[yst1 yst2],'g',xst1,yst1,'g.',xst2,yst2,'g*');set(h,'linewidth',2);
end
