%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
%     -  in red, running standard deviation of velocity shifts
%        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

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

jitter_ylim = 2*pfc.cfg.jitter_cutoff*.01;

clf;whitebg(gcf,'w');
new_pos = [.08 NaN .92 NaN];   %(new xstart and new width)
ax1 = subplot(411);
pos = get(ax1, 'pos');
set(ax1, 'pos', [new_pos(1)  pos(2) new_pos(3) pos(4)])

ax2 = subplot(412);
pos = get(ax2, 'pos');
set(ax2, 'pos', [new_pos(1)  pos(2) new_pos(3) pos(4)])

ax3 = subplot(413);
pos = get(ax3, 'pos');
set(ax3, 'pos', [new_pos(1)  pos(2) new_pos(3) pos(4)])

ax4 = subplot(414);
pos = get(ax4, 'pos');
set(ax4, 'pos', [new_pos(1)  pos(2) new_pos(3) pos(4)])







%plot velocities
config.xlim = [config.start_dd config.start_dd+config.ddrange];
if userawnav
   cfg =aplotit(data, config, 'cur_ax', ax1, 'fn', 'uabs_rawnav',...
                'var_range', [AA.uvmin AA.uvmax],...
                'ord_name', ord_name,...
                'badrect', AA.badrect, ...
                'badpoly', AA.badpoly, ...
                'badprof', AA.badprof,...
                'mabs', AA.mabs );
   cfg =aplotit(data, config, 'cur_ax', ax2, 'fn', 'vabs_rawnav',...
                'var_range', [AA.uvmin AA.uvmax],...
                'ord_name', ord_name,...
                'badrect', AA.badrect, ...
                'badpoly', AA.badpoly, ...
                'badprof', AA.badprof,...
                'mabs', AA.mabs );
else
   cfg =aplotit(data, config, 'cur_ax', ax1, 'fn', 'uabs_sm',...
                'var_range', [AA.uvmin AA.uvmax],...
                'ord_name', ord_name,...
                'badrect', AA.badrect, ...
                'badpoly', AA.badpoly, ...
                'badprof', AA.badprof,...
                'mabs', AA.mabs );
   cfg =aplotit(data, config, 'cur_ax', ax2, 'fn', 'vabs_sm',...
                'var_range', [AA.uvmin AA.uvmax],...
                'ord_name', ord_name,...
                'badrect', AA.badrect, ...
                'badpoly', AA.badpoly, ...
                'badprof', AA.badprof,...
                'mabs', AA.mabs );
end

cfg =aplotit(data, config, 'cur_ax', ax3, ...
             'ord_name', ord_name,...
             'fn', 'pg')'  ;    


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

adjusted = data.nav.was_adjusted; adjusted(~adjusted) = NaN;
h=plot(data.dday.*adjusted, data.ref_std/100, 'r', 'linewidth', 2); 
plot(data.dday.*adjusted, 0*data.ref_std/100, 'r', 'linewidth', .1)
set(ax4, 'ylim', [-jitter_ylim  jitter_ylim])
set(gca,'xlim',[config.start_dd config.start_dd+config.ddrange]);
set(ax4,'YColor', 'r', 'box', 'off')
ylabel('jitter: m/s')
matchbox(ax4, cfg.cur_ax, 'width');
%(2) plot ship's speed
ax5 = axes('pos',get(ax4,'pos'));
h=plot([min(data.dday) max(data.dday)]', [0 0]','k');
set(h, 'linewidth', 3, 'color', .9*[1 1 1]);
hold on
h=plot(data.dday, AA.pfc.cfg.underway+0*data.dday, 'c');lw(h,.1)


if userawnav
   if (~isemptys(data.rawsmmps))
      plot(data.dday, data.rawmps, 'g', 'linewidth', 2);hold on
      plot(data.dday, data.rawmps, 'k', 'linewidth', .1);
   end
else
   if (~isemptys(data.smmps))
      plot(data.dday, data.smmps, 'g', 'linewidth', 2);hold on
      plot(data.dday, data.smmps, 'k', 'linewidth', .1);
   end
end
h=plot([data.dday(1) data.dday(end)]', AA.config.os_cutoff*[1 1]', 'g');
set(h, 'linewidth', 2, 'color', .8*[0 1 0])
set(ax5,'XColor','k','YColor', [0 .5 0]);
set(ax5,'xlim',get(ax4,'xlim'), 'xtick', [] );
ylabel('ship speed (m/s)');
set(ax5, 'ylim', [0 cfg.maxclipval.mps], 'box', 'off','YAxisLocation', 'right');
set(ax5,'color','none');
matchbox(ax5, ax4, 'all');


date_it

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