
PTHFILE=['../fcast_archives/FCAST_1.1B1/EN302_FC1/CRUISE_Q4.1/DRIFTERS']

%Cisco's script

b=loadgrid('../MESH/bank150/bank150');
[la,lo]=xy2ll(b.x,b.y);
b.x=lo;b.y=la;

PFCS=read_pth(PTHFILE,4);
%Convert to lo/la
[la,lo]=xy2ll(PFCS.pth(:,1),PFCS.pth(:,2));
PFCS.pth(:,1)=lo;PFCS.pth(:,2)=la;

%
% Drifter 89
%

tstart =[130.0];
titlestr{1}=('Drifter 9 (1m) - Starting 0000UTC May 11 (Day 130.0)');

idrog=1;
lons=PFCS.pth(idrog:PFCS.ndrog:length(PFCS.pth),1);
lats=PFCS.pth(idrog:PFCS.ndrog:length(PFCS.pth),2);
timesec=PFCS.pth(idrog:PFCS.ndrog:length(PFCS.pth),4);
idx=find(diff(lons)~=0);
istart=[idx(1)];
idx=istart:length(lons);
lons=lons(idx);
lats=lats(idx);
timesec=timesec(idx)-timesec(idx(1));

figure
hb=plotbnd(b);
axis('tight')
set(hb,'LineWidth',2)
hc=lcontour(b,'z',[30 45 60 75 90 120]);
set(hc,'LineWidth',.25)
h=plotdrog(PFCS.pth(:,1),PFCS.pth(:,2),PFCS.ndrog,{idrog},{idrog});
set(h,'Color','g','Marker','s','MarkerSize',8,'LineStyle','none')
h=plotdrog(PFCS.pth(:,1),PFCS.pth(:,2),PFCS.ndrog,{PFCS.ndts},{idrog});
set(h,'Color','r','Marker','.','MarkerSize',18,'LineStyle','none')
h=plotdrog(PFCS.pth(:,1),PFCS.pth(:,2),PFCS.ndrog,1,{idrog});
set(h,'Color','k')
title(titlestr{idrog},'FontSize',17)
set(gcf,'Number','off')
axis([-67.538 -67.2328  40.951  41.199])

%     JD SHIFT   UCT SHIFT TO EDT
%   |     |
%         \/     \/
%        yr  m d      h  m    s
% DJM
% add 1 to tstart to make gmt 0.5  Jan 1, 1999
% subtract 4 hrs to convert from UTC to EST (local time)
dates=datenum(1999,1,tstart+1,-4,0,timesec);
mtrack(lons,lats,dates,'ticks',60,'times',60*3,'dates',12,'color','k',...
'fontsize',11,'fontweight','bold','FontName','helvetica','LineWidth',2);

labcont
grid


%
% Drifter 393
%

tstart =[130.0];
titlestr{6}=('Drifter 6 (1m) - Starting 0000UTC May 11 (Day 130.0)');

idrog=6;
lons=PFCS.pth(idrog:PFCS.ndrog:length(PFCS.pth),1);
lats=PFCS.pth(idrog:PFCS.ndrog:length(PFCS.pth),2);
timesec=PFCS.pth(idrog:PFCS.ndrog:length(PFCS.pth),4);
idx=find(diff(lons)~=0);
istart=[idx(1)];
idx=istart:length(lons);
lons=lons(idx);
lats=lats(idx);
timesec=timesec(idx)-timesec(idx(1));

figure
hb=plotbnd(b);
axis('tight')
set(hb,'LineWidth',2)
hc=lcontour(b,'z',[30 45 60 75 90 120]);
set(hc,'LineWidth',.25)
h=plotdrog(PFCS.pth(:,1),PFCS.pth(:,2),PFCS.ndrog,{idrog},{idrog});
set(h,'Color','g','Marker','s','MarkerSize',8,'LineStyle','none')
h=plotdrog(PFCS.pth(:,1),PFCS.pth(:,2),PFCS.ndrog,{PFCS.ndts},{idrog});
set(h,'Color','r','Marker','.','MarkerSize',18,'LineStyle','none')
h=plotdrog(PFCS.pth(:,1),PFCS.pth(:,2),PFCS.ndrog,1,{idrog});
set(h,'Color','k')
title(titlestr{idrog},'FontSize',17)
set(gcf,'Number','off')
axis([-67.778 -67.261  40.780  41.0678])

%     JD SHIFT   UCT SHIFT TO EDT
%   |     |
%         \/     \/
%        yr  m d      h  m    s
dates=datenum(1999,1,tstart+1,-4,0,timesec);
mtrack(lons,lats,dates,'ticks',60,'times',60*3,'dates',12,'color','k',...
'fontsize',11,'fontweight','bold','FontName','helvetica','LineWidth',2);

labcont
grid
