%get data, flag it, display it.  This is just a wrapper for aplotit

% Jules 2000/11/27

figbase = gcf;
%plot the flags

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


%plot velocities
figure(figbase);whitebg(figbase,'w');clf
cfg.xlim = [config.start_dd config.start_dd+config.ddrange];
cfg =aplotit(data, config, 'cur_ax', subplot(411), 'fn', 'uabs_g',...
             'var_range',[-60 60]);
cfg =aplotit(data, config, 'cur_ax', subplot(412), 'fn', 'vabs_g',...
             'var_range',[-60 60]);
cfg =aplotit(data, config, 'cur_ax', subplot(413), 'fn', 'fabs_g',...
             'var_range',[-60 60], 'comment', ...
     sprintf('reflayer: %d to %d', config.rl_range(1), config.rl_range(2)));
cfg =aplotit(data, config, 'cur_ax', subplot(414), 'fn', 'pg')'  ;    

date_it
subtitle(subtitle_comment)


%plot other diagnostics (page 2)
figure(figbase+1); whitebg(figbase+1,'w'); clf
config.cmap = mk_cmap(35,'jet');
cfg =aplotit(data, config, 'cur_ax', subplot(411), 'fn', 'e');
cfg =aplotit(data, config, 'cur_ax', subplot(412), 'fn', 'sw',...
             'var_range',[40 150]);
cfg =aplotit(data, config, 'cur_ax', subplot(413), 'fn', 'amp',...      
             'var_range',[30 200]);


ax4 = subplot(414);
axes(ax4);
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);
ylabel('ship speed')
set(gca,'xlim',[config.start_dd config.start_dd+config.ddrange]);
set(ax4, 'ylim', [0 7], 'box', 'off','YAxisLocation', 'right')
set(ax4,'YColor', [0 .5 0])
aax4 = axes('pos',get(ax4,'pos'))


h=plot(data.dday, boxfilt(uvdiff,boxfilt_length)/5,'k');
lw(h,3);set(h,'color',.8*[1 1 1]);
hold on
h=plot(data.dday, boxfilt(uvdiff,boxfilt_length)/5,'k');
lw(h,2);set(h,'color',.4*[1 1 1]);
plot([min(data.dday) max(data.dday)]', [closediff_cutoff closediff_cutoff]/5','k')
plot(data.dday, abs(data.clmps - data.smmps),'r', 'linewidth', .5); %in m/s
hold on
h=plot(data.dday, ...   %in m/s
       abs((data.uabs_refl_g - data.uabs_refl_sm) + ...
           i*(data.vabs_refl_g - data.vabs_refl_sm))/100, 'bo');ms(h,3)
set(aax4,'xlim',get(ax4,'xlim'), 'xtick', [] )
set(aax4, 'ylim', [0 .08], 'box', 'off')
set(aax4,'YColor', 'r')
ylabel('gps - smoothr ship speed')
set(aax4,'color','none')
%[left, bottom, width, height]
aax4pos = get(aax4,'pos');
boxpos = get(cfg.box_ax,'pos');
set(ax4,'pos',[aax4pos([1 2]), boxpos(3) aax4pos(4)])
set(aax4,'pos',[aax4pos([1 2]), boxpos(3) aax4pos(4)])






date_it

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