load gps1h.mat
if ~exist('nextwin','var')
    nextwin=6;
    day1=datenum(2011,1,0);
end
%  figure(nextwin); close(nextwin);  figure(nextwin);
% set(gcf,'Name','GPS');
addpath([matlabroot '/toolbox/local/m_map'])

% % Lon and Lat limits for the map:
s11_lat=-19 -(41.4783/60); s11_lon=-85 -(34.0093/60);
gpstart=gps.mday(end)-2.0;

% anchor over, stratus 11
if exist('minx','var')
    %  % add approach before  minx (97.9)
    gpstart=minx + day1 - .125; 
else
  gpstart=datenum(2011,4,7,21,30,00);
end
if exist('maxx','var')
    % add departure to maxx (99.5)
    gpsend=maxx + day1 + .125;
else
  gpsend=datenum(2011,4,9,10,30,00);
end
gps=structtrunc(gps,find(gps.mday > gpstart));
ln = [(floor(min([gps.lon; s11_lon] ) -1)) ...
    (ceil(max([gps.lon; s11_lon])+1))];
lt = [(floor(min([gps.lat; s11_lat]) -1))...
    (ceil(max([gps.lat; s11_lat])+1))];

% m_proj('mercator','lon',ln,'lat',lt);
% %m_proj('Miller Cylindrical','lon',ln,'lat',lt);  %good in tropics
% m_coast('patch',[.9 .9 .9],'edgecolor','k');
% m_grid('linestyle',':','box','fancy')
% m_track(gps.lon,gps.lat,gps.mday,'ticks',360,'times',720);
% fprintf('adding s11_ mark at %.3f %.3f\n',s11_lat,s11_lon);
% fprintf('plot bounds ');
% fprintf('lon bounds: %.2f %.2f lat %.2f %.2f\n ',ln,lt);
% m_line(s11_lon,s11_lat,'marker','x','markersize',8,'color','r');
% 
% % 3.7 nm ring
% rangekm = 3.7 * 1.852 / 2. ; % convert to km, get radius
% rangekm=rangekm(1);   % get spurious multiple rings without 
% m_range_ring(s11_lon,s11_lat,rangekm, 'color','b','linewidth',2);
% title('Stratus 2011 Track');

figure(nextwin)
set(gcf,'Name','Distance');
% get distance from stratus 11, plot
dist_km=ones(length(gps.mday),1);
for iil=1:length(gps.mday),
    jla=[s11_lat gps.lat(iil)];
    jlo=[s11_lon gps.lon(iil)];
    dist_km(iil) = m_lldist(jlo,jla);
end

shl=line((gps.mday-day1), dist_km,'Color','k','LineStyle','-', 'Marker','^');
ylabel('Distance (km)')
ldtxt='Ship to Stratus 11';
% ax=axis; axis([minx maxx 1 (ax(4) + .25)]);
% set(gca,'XTick',xticks);
lh6=legend(shl , ldtxt,'Location','Best');
% lh6=legend([shl ], ldtxt,'Location','NorthWest');
%set(lh6,'Box','off', 'FontSize',8)
set(lh6, 'FontSize',8);


