if (~exist('uv_lim', 'var'))
   uv_lim = [-60,60];
end



subtitle_comment = config.comment;
config.comment = '';
config.markbinrange = [2 3];
config.markcolor = 'k';
config.markindex = okosi;

%plot velocities
config.comment = '';

for ii=1:6
   eval(sprintf('ax%d = subplot(6,1,%d);', ii, ii))
   pos = get(gca, 'pos');
   set(gca, 'pos', pos + [0 0 0 .03]);
   if (ii <= 5)
      set(gca, 'xtick', [])
   end
end

%%%% uabs from gps
cfg =aplotit(data, config, 'cur_ax', ax1, 'fn', 'uabs_g',...
             'var_range',uv_lim);
axes(cfg.cur_ax)
ord = data.bins' * ones(size(data.dday));

%%%% vabs from gps
cfg =aplotit(data, config, 'cur_ax', ax2, 'fn', 'vabs_g',...
             'var_range',uv_lim);
axes(cfg.cur_ax)
ord = data.bins' * ones(size(data.dday));

%%%% AGC
cfg =aplotit(data, config, 'cur_ax', ax3, 'fn', 'amp',...
             'var_range',[20 160], 'comment', ...
             sprintf('reflayer: %d to %d', config.rl_range(1), config.rl_range(2)));

%%% reference layer with onstation 
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.uabs_refl_g, 'm', 'linewidth', 1);hold on
plot(data.dday(okosi), data.uabs_refl_g(okosi), 'r.')
plot(data.dday, data.vabs_refl_g, 'g', 'linewidth', 1);hold on
plot(data.dday(okosi), data.vabs_refl_g(okosi), 'b.')
text(mean(data.dday), 40, 'u_refl_g', 'fontweight', 'bold', 'color','r')
text(mean(data.dday), 20, 'v_refl_g', 'fontweight', 'bold', 'color','b')
text(mean(data.dday), -20, 'okosi','fontweight', 'bold', 'color','k')
yl(uv_lim)
set(ax4, 'xtick',[])
ax4pos = get(ax4,'pos');
boxpos = get(cfg.box_ax,'pos');
set(ax4,'pos',[ax4pos([1 2]), boxpos(3) ax4pos(4)])


%%% reference layer with good refl and smoothr agreement
axes(ax5)
ucolor = .5*[1 0 1];
vcolor = .5*[0 1 0];
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.uabs_refl_g, 'm', 'linewidth', 1);hold on
plot(data.dday(closei), data.uabs_refl_g(closei), '.', 'color', ucolor)
plot(data.dday, data.vabs_refl_g, 'g', 'linewidth', 1);hold on
plot(data.dday(closei), data.vabs_refl_g(closei), '.', 'color', vcolor)
text(mean(data.dday), 40, 'u_refl_g', 'fontweight', 'bold', 'color', ucolor)
text(mean(data.dday), 20, 'v_refl_g', 'fontweight', 'bold', 'color', vcolor)
text(mean(data.dday), -20, 'closei','fontweight', 'bold', 'color',ucolor)
yl(uv_lim)
set(ax5, 'xtick',[])
ax5pos = get(ax5,'pos');
boxpos = get(cfg.box_ax,'pos');
set(ax5,'pos',[ax5pos([1 2]), boxpos(3) ax5pos(4)])


axes(ax6);
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(ax6, 'ylim', [0 7], 'box', 'off','YAxisLocation', 'right')
set(ax6,'YColor', [0 .5 0])


aax6 = axes('pos',get(ax6,'pos'))
plot([min(data.dday) max(data.dday)]', 2*[jitter_cutoff jitter_cutoff]','k')
hold on
plot(data.dday, data.ref_std(ddayi),  'r', 'linewidth', .5); %in m/s

set(aax6,'xlim',get(ax6,'xlim'), 'xtick', [] )
set(aax6, 'ylim', [0 jitter_scale], 'box', 'off')
set(aax6,'YColor', 'r')
ylabel('gps - smoothr ship speed')
set(aax6,'color','none')
%[left, bottom, width, height]
aax6pos = get(aax6,'pos');
boxpos = get(cfg.box_ax,'pos');
set(ax6,'pos',[aax6pos([1 2]), boxpos(3) aax6pos(4)])
set(aax6,'pos',[aax6pos([1 2]), boxpos(3) aax6pos(4)])

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

subtitle(subtitle_comment)

