function panel4(field, varargin)
%panel4(field, varargin)
%
% panel plot of 4 beams 
%
% field is Nbins x 4 x Nprofiles
% index is how to sample in time
% 'abc' is abcissa (if other than profile number)
% 'ord' is ordinate (if other than bin)
% 'fn' is field name
% 'newfig' is to make a new figure for this plot
% 'var_range' is used to specify color range (else autoscales)
% JH 2003/04/24

cfg.index=[];
cfg.abc=[];
cfg.ord=[];
cfg.fn = ' ';
cfg.newfig = 0;
cfg.var_range = [];

cfg=fillstruct(cfg, varargin, 0);

if isempty(cfg.index)
   cfg.index=1:length(squeeze(field(1,1,:)));
end

if isempty(cfg.abc)
   cfg.abc=1:length(squeeze(field(1,1,:)));
end

if isempty(cfg.ord)
   cfg.ord=1:length(squeeze(field(:,1,1)));
end

dd=cfg;
dd.beam1 = squeeze(field(:,1,:));
dd.beam2 = squeeze(field(:,2,:));
dd.beam3 = squeeze(field(:,3,:));
dd.beam4 = squeeze(field(:,4,:));

config.ord_name = 'ord';
config.abc_name = 'abc';
config.index = dd.index;

if (cfg.newfig)
   figure
   pos = get(gcf,'pos')
   set(gcf,'pos', [500 200 200 600], 'menubar','none','toolbar','none')
end



clf


if isempty(cfg.var_range)
   aplotit(dd, config, 'fn', 'beam1', 'comment',  ['beam 1' cfg.fn], ...
           'index', cfg.index, 'cur_ax', subplot(411));
   aplotit(dd, config, 'fn', 'beam2', 'comment',  ['beam 2' cfg.fn], ...
           'index', cfg.index, 'cur_ax', subplot(412));
   aplotit(dd, config, 'fn', 'beam3', 'comment',  ['beam 3' cfg.fn], ...
           'index', cfg.index, 'cur_ax', subplot(413));
   aplotit(dd, config, 'fn', 'beam4', 'comment',  ['beam 4' cfg.fn], ...
           'index', cfg.index, 'cur_ax', subplot(414));
else
   
   aplotit(dd, config, 'fn', 'beam1', 'comment',  ['beam 1' cfg.fn], ...
           'var_range', cfg.var_range,...
           'index', cfg.index, 'cur_ax', subplot(411));
   aplotit(dd, config, 'fn', 'beam2', 'comment',  ['beam 2' cfg.fn], ...
           'var_range', cfg.var_range,...
           'index', cfg.index, 'cur_ax', subplot(412));
   aplotit(dd, config, 'fn', 'beam3', 'comment',  ['beam 3' cfg.fn], ...
           'var_range', cfg.var_range,...
           'index', cfg.index, 'cur_ax', subplot(413));
   aplotit(dd, config, 'fn', 'beam4', 'comment',  ['beam 4' cfg.fn], ...
           'var_range', cfg.var_range,...
           'index', cfg.index, 'cur_ax', subplot(414));
end 
