function gb_plotF
% plots drifter tracks and wind 
% stress for event F.
% 4/2/01

clear
clf

% drifters used in event F
DriftF=[70,72,79,81,86,92,93,94,98,99,100,104,105,107,109];
 
% set start, stop times
dt=5;
tstart=[149 154 159 ];
tstop=tstart+dt;

% set map domain
V=[-70 -65.5 39.75 42.5];

% start outer loop
for plnum=1:3
   subplot(2,2,plnum)
   axis(V)
   gbmapss2(V)
   hold on
   gb_plot97F(tstart(plnum),tstop(plnum));
   aspect5(41);
   hold on
end

% plot tracks along southern flank
DriftFsf=[70,99,92,104,81,79];
subplot(2,2,4)
axis(V)
gbmapss2(V)
hold on
gb_plot97trackF(DriftFsf,136,162);
aspect5(41);
hold on


function gb_plot97F(tstart,tstop)
% gb_plot97(tstart,tstop) plots tracks of all drifters 
% on bank during the time between tstart and tstop
% 3/25/01; 4/1/01

% convert to 1995 drifter days
tstart=yd2dd(tstart,1997);
tstop=yd2dd(tstop,1997);

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

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

% set map domain
V=[-70 -65.5 39.75 42.5];

% DriftF=[];

% start loop
for n=1:N
   gbmapss2(V);
   aspect5(41);
   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=[90,76,86,72];
      nDP=length(DP);
      for ndp=1:nDP
         nnn=find(zn(:,8)==DP(ndp));
         zn(nnn,:)=[];
      end
   end
     
   % find all drifters inside map domain
   k=find_inside(zn,V);
   znew=reconfig1(zn(k,:));
   
   % plot all drifters
   kk=find(isnan(znew(:,1)));
   h=plot(znew(:,2),znew(:,3));set(h,'linewidth',2);
   hold on
   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)))
   %DriftF=[DriftF;znew(kk-1,8)];
   %DriftF=sort(DriftF);
   %save DriftF DriftF
   pdate=[dd2cd1(t1(n)),' - ',dd2cd1(t2(n))];
   title(pdate);
   axis(V)
   
   hold on
   
   % plot mean wind stress
   err=0.01;
   K=find(dd2yd(t1(n))-err<=t97 & t97<=dd2yd(t2(n))+err);
   txm=mean(tx97(K));
   tym=mean(ty97(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],'k',xst2,yst2,'k*');
   set(h,'linewidth',2);
   hold on
   % 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);
   hold on
end

function gb_plot97trackF(id,tstart,tstop)
% gb_plot97track(id,tstart,tstop) plots the tracks
% of drifters given in id for the time between
% tstart and tstop during 1997.
% 4/1/01

% find number of drifters to be plotted
N=length(id);

%load data
load gb10mallA

% convert to 1995 yd for drifters
tstart=yd2dd(tstart,1997);
tstop=yd2dd(tstop,1997);

% set up base map
V=[-70 -65.5 39.75 42.5];
gbmapss2(V);
aspect5(41);
hold on

% start loop
for n=1:N
   nn=find(z(:,8)==id(n));
   zz=z(nn,:);
   % find subarray
   t=zz(:,1);
   err=0.005;
   I=find(tstart-err<=t & t<=tstop+err);
   t=zz(I,1);
   x=zz(I,2);x1=zz(max(I),2);
   y=zz(I,3);y1=zz(max(I),3);
   % plot drifter
   pcol='b';
   for ppp=1:3
      numdrift=[104,81,79];
      if id(n)==numdrift(ppp)
         pcol='g';
      end
   end
   h=plot(x,y,pcol,x1,y1,'r*');set(h,'linewidth',2);
   hold on
   % text(x1,y1+.1,int2str(id(n)));
   pltime=[dd2cd1(tstart),' - ',dd2cd1(tstop)];
   title(pltime)
   axis(V)
   hold on
end

