% figure(6); clf
day1=datenum(2007,1,0);
styd=datenum(2007,4,16,0,0,0) - day1;
enyd=datenum(2007,4,20,20,0,0) - day1;

% use data plot start, end
 minx=datenum(2007,4,18,20,32,0)-day1; styd=minx;
 maxx=datenum(2007,4,20,16,32,0)-day1; enyd=maxx;
 styd=minx; enyd=maxx;

addpath([matlabroot '\toolbox\local\m_map']);

% buoy positions
n6.lat=14 + 45/60;
n7.lat=14 + 49.356/60;
n6.lon=-1 * (50 + 56.6/60);
n7.lon=-1 * (51 + .615/60);

% ship positions
shp = load('data/hposit.mat');
ind1=find(shp.yday >= styd & shp.yday <= (enyd +1/24));
shp.yday=shp.yday(ind1);
shp.lat=shp.lat(ind1);shp.lon=shp.lon(ind1);

% get distance from ship to buoys
% (give 3.9 minute leeway at start with ship posits
dst6=ones(length(shp.yday),1);  dst7=dst6;
for iil=1:length(shp.yday),
    jla=[n6.lat shp.lat(iil)];
    jlo=[n6.lon shp.lon(iil)];
    dst6(iil) = m_lldist(jlo,jla);
    %fprintf('%d %s %.4f, %.4f  %.4f from NT6 ', iil, ...
    %    datestr(shp.yday(iil)+day1), shp.lat(iil), shp.lon(iil), dst6(iil));
    jla=[n7.lat shp.lat(iil)];
    jlo=[n7.lon shp.lon(iil)];
    dst7(iil) = m_lldist(jlo,jla);
    fprintf(' %.4f from NT7 \n', dst7(iil));
end
% clf
% enj=length(dst); %
% stj=enj - 6;
% stj=1;
% % plot(ydi(stj:enj)+day1,dst(stj:enj),'b',ydi(stj:enj)+day1,dst(stj:enj),'b.')
% % hold on
% % plot(ydi(stj:enj)+day1,dsti(stj:enj),'g',ydi(stj:enj)+day1,dsti(stj:enj),'g.')
% 
% plot(ydi(stj:enj),dst(stj:enj),'b',ydi(stj:enj),dst(stj:enj),'b.')
% hold on
% plot(ydi(stj:enj),dsti(stj:enj),'g',ydi(stj:enj),dsti(stj:enj),'g.')
% 
% ylabel('distance, km')
% xlabel('yearday 2007')
% title(tstr)
% 
% % datetick('x')
