function app(fignum)
% app(fignum)
% plot two vertical panel-plots with various data from getmat 
% fignum is optional: defaults to figures 5 and 6; otherwise starts 
% with fignum



% Jules 2000/11/27


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if (~exist('fignum','var'))
  fignum = 5;
end
 

[data, config] = agetmat;
config.cmap = mk_cmap(35,'jet');


      
figure(fignum);whitebg(fignum, 'w'); clf
xlim = [config.start_dd config.start_dd+config.ddrange];
cfg =aplotit(data, config, 'cur_ax', subplot(411), 'fn', 'uabs_sm',...
	'var_range',[-100 100], 'xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')

cfg =aplotit(data, config, 'cur_ax', subplot(412), 'fn', 'vabs_sm',...
	'var_range',[-100 100], 'xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')

cfg =aplotit(data, config, 'cur_ax', subplot(413), 'fn', 'fabs_sm',...
	'var_range',[-100 100], 'xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')

cfg =aplotit(data, config, 'cur_ax', subplot(414), 'fn', 'pg', 'xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')
      

figure(fignum+1);whitebg(fignum+1, 'w');clf
config.cmap = mk_cmap(35,'jet');
cfg =aplotit(data, config, 'cur_ax', subplot(411), 'fn', 'e', 'xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')

if (~isemptys(data.sw))  
   cfg =aplotit(data, config, 'cur_ax', subplot(412), ...
                'fn', 'sw', 'xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')
end

cfg =aplotit(data, config, 'cur_ax', subplot(413), 'fn', 'amp','xlim', xlim);
   pos = get(cfg.cur_ax, 'pos');
   set(cfg.cur_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.box_ax, 'pos', pos + [0 -.03 0 .05]);
   set(cfg.cur_ax, 'xtick', [])
   set(get(cfg.cur_ax, 'xlabel'), 'string', '')


ax = subplot(414);
plot(data.dday, data.clmps, 'g', 'linewidth', 1);hold on
plot(data.dday, data.smmps, 'k', 'linewidth', .1);
ylabel('ship speed')
set(gca,'xlim', xlim, 'tickdir', 'out');
set(ax, 'ylim', [0 7], 'box', 'off','YAxisLocation', 'right')
ax1 = axes('pos',get(ax,'pos'));
plot(data.dday, data.clmps - data.smmps,'r', 'linewidth', .5);
set(ax1,'xlim',get(ax,'xlim'), 'xtick', [] )
set(ax1, 'ylim', [-1 1], 'box', 'off')
ylabel('gps - smoothr ship speed')
set(ax1,'color','none')
%[left, bottom, width, height]
ax1pos = get(ax1,'pos');
boxpos = get(cfg.box_ax,'pos');
set(ax,'pos',[ax1pos([1 2]), boxpos(3) ax1pos(4)])
set(ax1,'pos',[ax1pos([1 2]), boxpos(3) ax1pos(4)])
