% go.m for stratus 2011, moana wave
% load argplot file, vos (autoimet) and maybe etl data
% 
% overplot all
% see set_up.m for details that change per cruise
% anchor over 2011/04/06 at 19:28

addpath( [matlabroot '/work']);
% file information is set here:
set_up;

% loop on getting & plotting ship (aka scs or elg) data
% and at intervals get etl and buoy data
for iloop=1:300
    set_up
    myds=datestr(now);    fprintf('%s\n',myds);
    % for mw go_ship just loads vos (local copy)
    %get_ship
 
    % now update the AO (buoy) data
    % different routine called by getargos (see set_up) 
    % skipping argos reload, it's finished 2011/4/10
    %get_argos
    
    % esrl/etl/psd/
    go_etl
    
    % now plot
    pmaxx=datenum(now) - day1 + .25;
    pminx=minx;
    if (pmaxx - pminx) > daystoplot
      pminx = pmaxx-daystoplot;
    end
    
    tdv=datevec(now);
    titlemain=sprintf('%s %d/%d %d:%d ',titlemain, tdv(2),tdv(3),tdv(4),tdv(5));
    fprintf('go:minx maxx %.2f %.2f\n',minx,maxx);
    %plot_argos_panels
    %overplot_ship_panels
    overplot_etl_flux_panels

    % now update the gps files
    go_gps
    figure(1); figure(3); figure(4);
    fprintf('\ndone at %s\n', datestr(now));
    % wait (nominally 1 hour: actually get as
    % close to the top of the hour as you can
    dvnow=datevec(now);
    n2w=60;
    if dvnow(5) < 59
        n2w = 59 - dvnow(5);
    end
    disp([ 'waiting ' num2str(n2w) ' minutes']);
    % wait 1 minute at a time
    for islp=1:n2w
        pause(60);
        dvnow=datevec(now);
        if ~rem(dvnow(5),5)
          fprintf('%d ',dvnow(5));
        end
    end
    fprintf('\n');
    datestr(now)
    clear set_up nowait plot_Argos_panels  overplot_ship_panels 
    clear go_gps  overplot_etl_flux_panels
end


