Skip to content
Snippets Groups Projects
read_Climatology.m 1.61 KiB
Newer Older
function read_Climatology(hMainFig, type)
% Function to read climatology and store result to tsg structure
%
% Input
% -----
% type    ............ String describing climatology (annual,sesonal or
%                      monthly)
%
% Output
% ------
% none
%
% $Id$

% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

% is tsg.levitus empty, climatology file is not loaded in memory
% --------------------------------------------------------------
if isempty( tsg.levitus.data) || ~strcmp(tsg.levitus.type,type)

  % construct the filename and read file
  % ------------------------------------
  file = which(['woa01_' type  '_surf.nc']);

  % open netcdf climatology file
  % ----------------------------
  levitus = read_file_woa01(file);

  % test for structure concordance
  % ------------------------------
  if ~isstruct(levitus)

    % show dialog box with help to get climatology file
    % -------------------------------------------------
    errordlg({'NetCDF climatology file :', file, ...
      'not present in you path',...
      'Check your matlab path or download it from',...
      'ftp://ftp.ifremer.fr/ifremer/ird/us191/oceano/lib/matlab/woa01_annual_surf.nc'},...
      'NetCDF climatology file access error');
    return;

    % structure is ok, save climatology & type in tsg structure
    % ---------------------------------------------------------
  else
    tsg.levitus.data = levitus;
    tsg.levitus.type = type;
  end

  % save tsg structure
  % ------------------
  setappdata( hMainFig, 'tsg_data', tsg );
end