function gb_plotH
% gb_plotH plots drifter tracks and 
% wind stress for event H.
% 4/7/01

clear
clf

% drifters used in event H
id=[140,141,142,144,154,164,175,178];
idd=[203];

% set start, stop times
dt=10;
t11=130;
t1=[t11:dt:t11+4*dt];
t2=t1+dt;

% set map domain
V=[-69.5 -67.25 40.25 41.5];

% make subplots
subplot(2,2,1)
gbmapss2(V)
axis(V);
aspect5(41);
hold on
gb_plot99trackG(id,t1(1),t2(1),V);
gb_plot99trackdG(idd,t1(1),t2(1),V);
title([yd2cd1(t1(1),1999),' - ',yd2cd1(t2(1),1999)]);
% title([int2str(t1(1)),' - ',int2str(t2(1))]);


subplot(2,2,2)
gbmapss2(V);
axis(V);
aspect5(41);
hold on
gb_plot99trackG(id,t1(2),t2(2),V);
gb_plot99trackdG(idd,t1(2),t2(2),V);
title([yd2cd1(t1(2),1999),' - ',yd2cd1(t2(2),1999)]);
% title([int2str(t1(2)),' - ',int2str(t2(2))]);


subplot(2,2,3)
axis(V)
gbmapss2(V)
aspect5(41);
hold on
gb_plot99trackG(id,t1(3),t2(3),V);
gb_plot99trackdG(idd,t1(3),t2(3),V);
title([yd2cd1(t1(3),1999),' - ',yd2cd1(t2(3),1999)]);
% title([int2str(t1(3)),' - ',int2str(t2(3))]);


subplot(2,2,4)
axis(V)
gbmapss2(V)
aspect5(41);
hold on
gb_plot99trackG(id,t1(4),t2(4),V);
gb_plot99trackdG(idd,t1(4),t2(4),V);
title([yd2cd1(t1(4),1999),' - ',yd2cd1(t2(4),1999)]);
% title([int2str(t1(4)),' - ',int2str(t2(4))]);


function gb_plot99trackG(id,tstart,tstop,V)
% gb_plot99trackG(id,tstart,tstop,V) plots the 
% tracks of drifters given in id for the time 
% between tstart and tstop during event G. 
% 4/6/01

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

%load data
load gb10mallA
% load wind stress
load windstress9599
tws=t;

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

% 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
   h=plot(x,y,'b',x1,y1,'k*');
   set(h,'linewidth',1.5,'markersize',4);
   hold on
end
% plot wind stress
   err=0.01;
   K=find(tstart-err<=tws & tws<=tstop+err);
   txm=mean(tx(K));
   tym=mean(ty(K));
   xst1=-68;yst1=41.1;
   KK=4;
   KXY=.755;
   yst2=yst1+KK.*tym;
   xst2=xst1+KK.*txm./KXY;
   h=plot([xst1 xst2],[yst1 yst2],'g',xst2,yst2,'k.');
   set(h,'linewidth',1.5);
 % plot wind stress scale
   xst1=-68;yst1=42.25;
   KK=4;
   KXY=.755;
   yst2=yst1;
   xst2=xst1+KK.*.1./KXY;
   h=plot([xst1 xst2],[yst1 yst2],'g',xst1,yst1,'g.',xst2,yst2,'g.');
   set(h,'linewidth',1.5);


function gb_plot99trackdG(id,tstart,tstop,V)
% gb_plot99trackdG(id,tstart,tstop,V) plots the tracks
% of the 40-m deep drifters given in id for the time
% between tstart and tstop during event G.
% 4/6/01

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

%load data
load gb40m99
z=zd;

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

% 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
   h=plot(x,y,'r',x1,y1,'k*');
   set(h,'linewidth',1.5,'markersize',4);
   hold on
   % text(x1,y1+.1,int2str(id(n)));
   hold on
end
