figure(6); clf
this is not used in stratus 11
% year=2008;
% day1=datenum(year,1,0);
% styd=datenum(2008, 7, 28, 5, 0, 0) - day1;
% % first, plot a long time to see when we left the site
% enyd=datenum(2008,7,30,0,0,0) - day1;


 year=2008;
    day1=datenum(year,1,0);
    xticks=[210.25 210.5 210.75 211.00 211.25 ];
    styd=datenum(2008, 7, 28, 5, 0, 0) - day1;
    %enyd=datenum(2008,7,29,6,30,0) - day1;
    %29-Jul-2008 06:30:00
    enyd=211.5;   % last
    % for axis limits
    minx=210.208333;
    maxx=211.3333;

tstr='Distance from buoy to ship';

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

% buoy position - surveyed anchor pos
n8.lat=14 + 45.1344/60;
n8.lon=-1 * (50 + 57.175/60);

% ship positions

ship=load ('shipmet.mat');
ship.yday=ship.mday-day1;
ind1=find(ship.yday >= styd & ship.yday <= enyd );
shp.yday=ship.yday(ind1);
shp.mday=ship.mday(ind1);
shp.lat=ship.lat(ind1);shp.lon=ship.lon(ind1);

% get distance from ship to buoys
% (give some leeway at start with ship posits
dst=ones(length(shp.yday),1);  
for iil=1:length(shp.yday),
    jla=[n8.lat shp.lat(iil)];
    jlo=[n8.lon shp.lon(iil)];
    dst(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),
    %    dst(iil));
   % fprintf(' %.4f from buoy \n', dst(iil));
end
shp.dist=dst;
hshp=get_str_avg(shp);
hshp.yday=hshp.mday-day1;

 hdst=ones(length(hshp.yday),1);
for iil=1:length(hshp.yday),
    jla=[n8.lat hshp.lat(iil)];
    jlo=[n8.lon hshp.lon(iil)];
    hdst(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),
    %    dst(iil));
   % fprintf(' %.4f from buoy \n', dst(iil));
end

% enj=length(dst); 
% stj=1;

plot(shp.yday,dst,'b',hshp.yday,hshp.dist,'b.');
  set(gca,'XTick',xticks);
ax=axis;
axis([minx maxx ax(3:4)])
   

%anchor=datenum(2008,07,28,4,27,0)-day1; plot(anchor,6,'rx')
ylabel('distance, km')
xlabel('yearday year')
title(tstr)

% datetick('x')
