function fig = pgrid_new()
% This is the machine-generated representation of a Handle Graphics object
% and its children.  Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
% This problem is solved by saving the output as a FIG-file.
%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.
% 
% NOTE: certain newer features in MATLAB may not have been saved in this
% M-file due to limitations of this format, which has been superseded by
% FIG-files.  Figures which have been annotated using the plot editor tools
% are incompatible with the M-file/MAT-file format, and should be saved as
% FIG-files.

arch=computer;
  if (strcmp(arch,'PCWIN') | strcmp(arch,'MAC2'))
     win_dim=[140 0 450 540];
  else
     if (isunix)
        win_dim=[445 120 450 540];
     else
        win_dim=[140 0 450 540];
     end
  end

h0 = figure('Units','points', ...
	'Color',[0.5 0.7 0.7], ...
	'Colormap','default', ...
	'FileName','pgrid_new.m', ...
	'Name','pressure grid window', ...
	'NumberTitle','off', ...
	'PaperPosition',[18 180 576 432], ...
	'PaperUnits','points', ...
	'Position',win_dim, ...
	'Tag','pgridWindow', ...
	'ToolBar','none');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.5 0.7 0.7], ...
	'FontSize',14, ...
	'FontWeight','bold', ...
	'ListboxTop',0, ...
	'Position',[43 498 343.2 40], ...
	'String','Enter Pressure Gridding set-up parameters', ...
	'Style','text', ...
	'Tag','hdrText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.5 0.7 0.7], ...
	'FontSize',12, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[43 478 343.2 40], ...
	'String','All fields must be completed!', ...
	'Style','text', ...
	'Tag','hdr2Text');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 460.4 415 40.2], ...
	'Style','frame', ...
	'Tag','inFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 462 100 29.6], ...
	'String','INPUT file directory (use full path)', ...
	'Style','text', ...
	'Tag','inText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[135 471 285 22], ...
	'Style','edit', ...
	'Tag','inEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 413.6 415.2 43.2], ...
	'Style','frame', ...
	'Tag','outFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 416 110 32], ...
	'String','OUTPUT file directory (use full path)', ...
	'Style','text', ...
	'Tag','outText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[135 425 285 22], ...
	'Style','edit', ...
	'Tag','outEd');

%  cal infos
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 371.2 415.2 40], ...
	'Style','frame', ...
	'Tag','CcalFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 372.8 124 29.6], ...
	'String','CTD calibration file name (use full path)', ...
	'Style','text', ...
	'Tag','CcalTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[155 382 268.8 22], ...
	'Style','edit', ...
	'Tag','CcalEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 326.4 415.2 43.2], ...
	'Style','frame', ...
	'Tag','AcalFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 328 131.2 32], ...
	'String','ACM calibration file name (use full path)', ...
	'Style','text', ...
	'Tag','AcalText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[155 337 268.8 22], ...
	'Style','edit', ...
	'Tag','AcalEd');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  center section
% pressure and profile scan ranges
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 275.2 200 40], ...
	'Style','frame', ...
	'Tag','drngFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 282.4 89.6 24.8], ...
	'String','profile range limits (ie [3 10])', ...
	'Style','text', ...
	'Tag','drngText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[121.2 284 89.6 22], ...
	'Style','edit', ...
	'Tag','drngEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[234 275.2 200 40], ...
	'Style','frame', ...
	'Tag','pgrFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[238 282.4 89.6 24.8], ...
	'String','Pres_grid limits ([min step max])', ...
	'Style','text', ...
	'Tag','pgrText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[316 284 104.8 22], ...
	'Style','edit', ...
	'Tag','pgrEd');

% pressure and temperature bounds
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 230.4 200 40], ...
	'Style','frame', ...
	'Tag','drngFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 237.6 89.6 24.8], ...
	'String','pressure bounds ([min max])', ...
	'Style','text', ...
	'Tag','pbndTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[121.2 239 89.6 22], ...
	'Style','edit', ...
	'Tag','pbndEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[234 230.4 200 40], ...
	'Style','frame', ...
	'Tag','tbndFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[238 237.6 89.6 24.8], ...
	'String','Temperature bounds ([min max])', ...
	'Style','text', ...
	'Tag','tbndTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[330 239 90 22], ...
	'Style','edit', ...
	'Tag','tbndEd');

% cond and vel bounds
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 186.4 200 40], ...
	'Style','frame', ...
	'Tag','cbndFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 193.6 89. 24.8], ...
	'String','Conductivity bounds ([min max])', ...
	'Style','text', ...
	'Tag','cbndTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[121.2 195.6 89.6 22], ...
	'Style','edit', ...
	'Tag','cbndEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[234 186.4 200 40], ...
	'Style','frame', ...
	'Tag','vbndFrame');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[238 193.6 89.6 24.8], ...
	'String','Velocity bounds ([min max])', ...
	'Style','text', ...
	'Tag','vbndText');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[316 195.6 104.8 22], ...
	'Style','edit', ...
	'Tag','vbndEd');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% bottom sections
%  right side - name, posn, declination
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[185 82.8 250.4 32], ...
	'Style','frame', ...
	'Tag','declFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[298.4 90.4 124.8 22], ...
	'Style','edit', ...
	'Tag','declEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[186.2 85.6 80 24], ...
	'String','magnetic deviation (degrees)', ...
	'Style','text', ...
	'Tag','declTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[185 114.8 250.4 32], ...
	'Style','frame', ...
	'Tag','posFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[293.6 121.6 124.8 22], ...
	'Style','edit', ...
	'Tag','posEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[187 119.6 120 24], ...
	'String',' Mooring Position  ([lat lon] (dd mm, dd mm))', ...
	'Style','text', ...
	'Tag','posTx');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[185 146.8 250.4 32], ...
	'Style','frame', ...
	'Tag','exnamFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[293.6 153.6 124.8 22], ...
	'Style','edit', ...
	'Tag','exnamEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[188 151.6 80 24], ...
	'String','Experiment Name', ...
	'Style','text', ...
	'Tag','exnamTxt');

% MMP, CTD & ACM ID info boxes (bottom left
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 82.8 150.4 32], ...
	'Style','frame', ...
	'Tag','ACMidFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[89 89.6 75.2 22], ...
	'Style','edit', ...
	'Tag','ACMidEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 87.6 61.6 16], ...
	'String','ACM ID', ...
	'Style','text', ...
	'Tag','ACMidTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 114.8 150.4 32], ...
	'Style','frame', ...
	'Tag','CTDidFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[89 121.6 75.2 22], ...
	'Style','edit', ...
	'Tag','CTDidEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 119.6 61.6 16], ...
	'String','CTD ID', ...
	'Style','text', ...
	'Tag','CTDidTxt');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 146.8 150.4 32], ...
	'Style','frame', ...
	'Tag','MMPidFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[89 153.6 75.2 22], ...
	'Style','edit', ...
	'Tag','MMPidEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[26 151.6 61.6 16], ...
	'String','MMP ID', ...
	'Style','text', ...
	'Tag','MMPidTxt');
%nscans at the very bottom
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[19.6 45 200.4 30], ...
	'Style','frame', ...
	'Tag','nscnFr');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[135 50 70 22], ...
	'Style','edit', ...
	'Tag','nscnEd');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.3 0.6 0.7], ...
	'ListboxTop',0, ...
	'Position',[21.6 48 80 25], ...
	'HorizontalAlignment','left',...
	'String','minimum scans for processing', ...
	'Style','text', ...
	'Tag','nscnTxt');


% buttons that actually do something
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.9 0.7 0.15], ...
	'Callback','save_params(''pgrid_params'');', ...
	'FontSize',12, ...
	'ListboxTop',0, ...
	'Position',[250 45 150 30], ...
	'String','Save current settings', ...
	'Tag','savePush');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.1 0.85 0.2], ...
	'Callback','mag_pgrid; close;', ...
	'FontSize',12, ...
	'ListboxTop',0, ...
	'Position',[75 5 200 30], ...
	'String','derive pressure gridded .mat file', ...
	'Tag','SetupPush');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[0.8 0.1 0.15], ...
	'Callback','close;', ...
	'FontSize',12, ...
	'ListboxTop',0, ...
	'Position',[290 5 80 30], ...
	'String','QUIT', ...
	'Tag','quitPush');

% now add in the default values
 if exist('pgrid_params.mat','file')
    load pgrid_params;
 else
     load def_params;
 end

 t=findobj(gcf,'Style','Edit');
   if (length(t) == length(pl))
     for ik=1:length(t)                      
      set(t(ik),'String',cellstr(params{ik}))
     end
    end
  set(t,'fontsize',14)


if nargout > 0, fig = h0; end
