Newer
Older
function read_Climatology(hMainFig)

jacques.grelet_ird.fr
committed
% Function to read climatology and store result to tsg structure
%
% Input
% -----
% tsg ............ structure tsg

jacques.grelet_ird.fr
committed
% type ............ String describing climatology (annual,sesonal or
% monthly)
%
% Output
% ------
% tsg ............ updated structure tsg

jacques.grelet_ird.fr
committed
%
% $Id$
% Get data
% -----------------------
tsg = getappdata( hMainFig, 'tsg_data' );

jacques.grelet_ird.fr
committed
% get last selected climatology
% -----------------------------
s = get(findobj('Tag', 'TAG_UIMENU_CLIMATO_MAIN'), 'Userdata');
% tsg.levitus.type = 'none' or new select climatology is different, load file
% -------------------------------------------------------------------------
if strcmp( tsg.levitus.type, 'none') || ~strcmp(tsg.levitus.type, s.type)

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

jacques.grelet_ird.fr
committed
% open netcdf climatology file
% ----------------------------
levitus = read_file_woa01(file);
% test for structure concordance
% ------------------------------
if isstruct(levitus)
% ok, save last climato state in tsg.levitus structure
% ----------------------------------------------------
tsg.levitus.type = s.type;
tsg.levitus.data = levitus;
else

jacques.grelet_ird.fr
committed
% 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_' s.type '_surf.nc']},...

jacques.grelet_ird.fr
committed
'NetCDF climatology file access error');
% init tsg.levitus state
% ----------------------
tsg.levitus.data = [];
tsg.levitus.type = 'none';

jacques.grelet_ird.fr
committed
end
end

jacques.grelet_ird.fr
committed
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );