%get data, flag it, display it.  This is just a wrapper for aplotit which plots 
% (1) absolute u, 
% (2) absolute v, 
% (3) percent good, 
% (4) - ship speed (m/s) in green, axes on the right
%     - difference between measured ship's speed  (original gps) and ship's 
%        speed from smoothed navigation (comes from the reference layer used 
%        in adcpsect and subsequent run of smoothr).  this is in gray
%     -  in red, running standard deviation of  d(measured velocity)/dt.  
%        This is an indication of how bad the measured velocities are in the 
%        reference layer.  This is plotted in red and can be used to exclude 
%        profiles.  This is what the "jitter" criterion applies to.


% Jules 2000/11/27

if (~exist('refl_sm_ylim', 'var'))  %ylim on gps - smoothr ship speed: try 5*std dev 
   junk =  abs(data.clmps - data.smmps);
   [junk_m, junk_s] = mstdgap(junk);
   refl_sm_ylim = min(2*pfc.cfg.jitter_cutoff*.01, 5*junk_s); 
end


subtitle_comment = config.comment;
config.comment = '';


%plot velocities
whitebg(gcf,'w');clf
config.xlim = [config.start_dd config.start_dd+config.ddrange];
cfg =aplotit(data, config, 'cur_ax', subplot(411), 'fn', 'uabs_sm',...
             'var_range',[-60 60]);
cfg =aplotit(data, config, 'cur_ax', subplot(412), 'fn', 'vabs_sm',...
             'var_range',[-60 60]);
cfg =aplotit(data, config, 'cur_ax', subplot(413), 'fn', 'pg')'  ;    


%(1) plot jitter screening limits
ax = subplot(414);
h=plot([data.dday(1) data.dday(end)]', pfc.cfg.jitter_cutoff*[.01 .01]', 'k');
set(h, 'linewidth', 2, 'color', .8*[1 1 1])
hold on
h=plot([data.dday(1) data.dday(end)]', -pfc.cfg.jitter_cutoff*[.01 .01]', 'k');
set(h, 'linewidth', 2, 'color', .8*[1 1 1])

h=plot(data.dday, data.clmps - data.smmps,'k');
set(h, 'linewidth', .5, 'color', .5*[1 1 1]);
h=plot(data.dday, data.ref_std/100, 'r', 'linewidth', 2); 
plot(data.dday, 0*data.ref_std, 'r', 'linewidth', .1)
set(ax, 'ylim', [-refl_sm_ylim  refl_sm_ylim])
set(gca,'xlim',[config.start_dd config.start_dd+config.ddrange]);
set(ax,'YColor', 'r', 'box', 'off')
ylabel('jitter: m/s')
matchbox(ax, cfg.cur_ax, 'width');
%(2) plot ship's speed
ax1 = axes('pos',get(ax,'pos'));
h=plot([min(data.dday) max(data.dday)]', [0 0]','k');
set(h, 'linewidth', 3, 'color', .9*[1 1 1]);
hold on
plot(data.dday, data.clmps, 'g', 'linewidth', 2);hold on
plot(data.dday, data.smmps, 'k', 'linewidth', 1);
set(ax1,'XColor','k','YColor', [0 .5 0]);
set(ax1,'xlim',get(ax,'xlim'), 'xtick', [] );
ylabel('ship speed (m/s)');
set(ax1, 'ylim', [0 7], 'box', 'off','YAxisLocation', 'right');
set(ax1,'color','none');
matchbox(ax1, ax, 'all');


date_it

subtitle_comment = sprintf('%s (dday %3.1f - %3.1f)',...
                           subtitle_comment, min(data.dday), max(data.dday));
subtitle(subtitle_comment)
