Skip to content
Snippets Groups Projects
Commit 8a76f84c authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

Move fucntions read_Climatology.m and plot_Climatology.m in tsg_util directory

Set uimenu Climatology to annual at startup
warning waitbar display on windows stay, need correction:
Unable to interpret TeX string "\svn\oceano\lib\matlab\woa01_seasonal_surf.nc  
parent 825eb397
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,19 @@ nc = netcdf(which(file),'nowrite');
% Initialise la waitbar de chargement du fichier netCDF
% -----------------------------------------------------
wb = waitbar(0,['Loading file: ' file ' Please wait...']);
wb = waitbar(0,'');
% We cannot change title property to 'none' (default set as 'tex') inside
% waitbar function (line 81), see
% http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/115725
% -----------------------------------------------------------------------
hchild = get(wb,'children');
htitle = get(hchild,'title');
set(htitle,'Interpreter','None');
% update waitbar title with Tex mode disable
% ------------------------------------------
waitbar(wb, ['Loading file: ' file ' Please wait...']);
% loop for every variable
% -----------------------
......
function plot_Climatology(hMainFig, hPlotAxes)
% Function to plot mean climatology and standard deviation
%
% Input
% -----
% hTsgGUI ............ Handel to the main user interface
% hPlotAxes .......... Handels to the 3 graphic axes
%
% Output
% ------
% none
%
% $Id$
% Get data
% -----------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get line handles
% ----------------
hLine1 = get( hPlotAxes(1), 'UserData');
hLine2 = get( hPlotAxes(2), 'UserData');
% Read surface climatology (annual, seasonal or monthly)
% ------------------------------------------------------
read_climatology(hMainFig, tsg.levitus.type);
% select time dimension for climatology
dim_time = tsg.levitus.time;
% round positive latitude and Longitude toward zero
% -------------------------------------------------
ind = find(tsg.LATX > 0);
lat(ind) = fix(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONX > 0);
lon(ind) = fix(tsg.LONX(ind)) + 0.5;
% rounds negative latitude and Longitudeto the nearest lowest integers
% ---------------------------------------------------------------------
ind = find(tsg.LATX <= 0);
lat(ind) = floor(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONX <= 0);
lon(ind) = floor(tsg.LONX(ind)) + 0.5;
% Calculates differences between adjacent elements of X.
% 0 if adajacent latitude or longitude are equal
% - 1 or -1 otherwise
% ------------------------------------------------------------
lat_diff = [diff( lat )'; 0];
lon_diff = [diff( lon )'; 0];
% Select latitude and longitude
% -----------------------------
ind = find(abs(lat_diff) == 1 | abs(lon_diff == 1));
lat2 = lat( ind );
lon2 = lon( ind );
dayd = tsg.DAYD( ind );
ssjt = tsg.SSJT( ind );
ssps = tsg.SSPS( ind );
% Get Climatology
% LATX(80) = -0.5 et LATX(81) = 0.5
% LONX(180) = -0.5 et LONX(181) = 0.5
% ----------------
axes( hPlotAxes(1) );
mean_sstp = zeros(size(ind));
mean_ssps = zeros(size(ind));
std_sstp = zeros(size(ind));
std_ssps = zeros(size(ind));
for ii=1:length(ind)
ilat = find(tsg.levitus.data.WOA01_LATX == lat2(ii));
ilon = find(tsg.levitus.data.WOA01_LONX == lon2(ii));
mean_sstp(ii) = tsg.levitus.data.WOA01_MEAN_SSTP(dim_time,1,ilat,ilon);
mean_ssps(ii) = tsg.levitus.data.WOA01_MEAN_SSPS(dim_time,1,ilat,ilon);
std_sstp(ii) = tsg.levitus.data.WOA01_STD_SSTP(dim_time,1,ilat,ilon);
std_ssps(ii) = tsg.levitus.data.WOA01_STD_SSPS(dim_time,1,ilat,ilon);
end
% Plot mean salinity climatology
% ------------------------------
hLine1.meanClim = line( ...
dayd, mean_ssps,'Linestyle', '-', 'Color','k');
% Plot with 3 standard deviation
% ------------------------------
hLine1.stdClimPlus = line( ...
dayd, mean_ssps + 3 * std_ssps ,'Linestyle', '-', 'Color','r');
hLine1.stdClimMinus = line( ...
dayd, mean_ssps - 3 * std_ssps ,'Linestyle', '-', 'Color','r');
% Plot mean temperature climatology
% ---------------------------------
axes( hPlotAxes(2));
hLine2.meanClim = line( ...
dayd, mean_sstp,'Linestyle', '-', 'Color','k');
hLine2.stdClimPlus = line( ...
dayd, mean_sstp + 3 * std_sstp ,'Linestyle', '-', 'Color','r');
hLine2.stdClimMinus = line( ...
dayd, mean_sstp - 3 * std_sstp ,'Linestyle', '-', 'Color','r');
% Store the handle of the bucketline
% ----------------------------------
set( hPlotAxes(1), 'UserData', hLine1 );
set( hPlotAxes(2), 'UserData', hLine2 );
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );
end
\ No newline at end of file
......@@ -9,6 +9,8 @@ function plot_SalTempVel( hTsgGUI, hAxes )
%
% Output
% ------
% none
%
% $Id$
% Retrieve named application data
......
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
\ No newline at end of file
......@@ -5,7 +5,7 @@ function [] = tsg_moveaverage(hTsgGUI)
% are not taken into account.
%
% Input
% hTsgGUI ............ Handel to the main user interface
% hTsgGUI ............ Handle to the main user interface
%
% No computation : NaN
%
......
......@@ -146,8 +146,7 @@ hClimatoMenu = uimenu(hMainFig,'Label','Climatology');
% by defautl at startup, select climatology to annual
% ---------------------------------------------------
uimenu(hClimatoMenu,'Label','Annual',...
'Checked','off',...
'CreateFcn', {@ClimatoSelectMenuCallback, 'annual', 1}, ...
'Checked','on',...
'Tag','TAG_UIMENU_CLIMATO_ANNUAL',...
'Enable', 'on',...
'Callback', {@ClimatoSelectMenuCallback, 'annual', 1});
......@@ -1545,7 +1544,7 @@ end
% plot climatology
% ----------------
plot_climatology();
plot_Climatology(hMainFig, hPlotAxes);
end
end
......@@ -1584,13 +1583,13 @@ end
% Read surface climatology (annual, seasonal or monthly)
% ------------------------------------------------------
read_climatology(climato);
read_Climatology(hMainFig,climato);
end
% plot new loaded climatology
% ---------------------------
plot_climatology();
plot_Climatology(hMainFig, hPlotAxes);
% save climatology state in tsg structure
% ---------------------------------------
......@@ -1603,157 +1602,6 @@ end
end
%% Read_climatology file
% -------------------------------------------------------------------
% nested fucntion call to read climatology
% -------------------------------------------------------------------
function read_climatology(type)
% 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
end
%% Plot_climatology data
% -------------------------------------------------------------------
% nested function call to plot climatology
% -------------------------------------------------------------------
function plot_climatology()
% Get data
% -----------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get line handles
% ----------------
hLine1 = get( hPlotAxes(1), 'UserData');
hLine2 = get( hPlotAxes(2), 'UserData');
% Read surface climatology (annual, seasonal or monthly)
% ------------------------------------------------------
read_climatology(tsg.levitus.type);
% select time dimension for climatology
dim_time = tsg.levitus.time;
% round positive latitude and Longitude toward zero
% -------------------------------------------------
ind = find(tsg.LATX > 0);
lat(ind) = fix(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONX > 0);
lon(ind) = fix(tsg.LONX(ind)) + 0.5;
% rounds negative latitude and Longitudeto the nearest lowest integers
% ---------------------------------------------------------------------
ind = find(tsg.LATX <= 0);
lat(ind) = floor(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONX <= 0);
lon(ind) = floor(tsg.LONX(ind)) + 0.5;
% Calculates differences between adjacent elements of X.
% 0 if adajacent latitude or longitude are equal
% - 1 or -1 otherwise
% ------------------------------------------------------------
lat_diff = [diff( lat )'; 0];
lon_diff = [diff( lon )'; 0];
% Select latitude and longitude
% -----------------------------
ind = find(abs(lat_diff) == 1 | abs(lon_diff == 1));
lat2 = lat( ind );
lon2 = lon( ind );
dayd = tsg.DAYD( ind );
ssjt = tsg.SSJT( ind );
ssps = tsg.SSPS( ind );
% Get Climatology
% LATX(80) = -0.5 et LATX(81) = 0.5
% LONX(180) = -0.5 et LONX(181) = 0.5
% ----------------
axes( hPlotAxes(1) );
mean_sstp = zeros(size(ind));
mean_ssps = zeros(size(ind));
std_sstp = zeros(size(ind));
std_ssps = zeros(size(ind));
for ii=1:length(ind)
ilat = find(tsg.levitus.data.WOA01_LATX == lat2(ii));
ilon = find(tsg.levitus.data.WOA01_LONX == lon2(ii));
mean_sstp(ii) = tsg.levitus.data.WOA01_MEAN_SSTP(dim_time,1,ilat,ilon);
mean_ssps(ii) = tsg.levitus.data.WOA01_MEAN_SSPS(dim_time,1,ilat,ilon);
std_sstp(ii) = tsg.levitus.data.WOA01_STD_SSTP(dim_time,1,ilat,ilon);
std_ssps(ii) = tsg.levitus.data.WOA01_STD_SSPS(dim_time,1,ilat,ilon);
end
% Plot mean salinity climatology
% ------------------------------
hLine1.meanClim = line( ...
dayd, mean_ssps,'Linestyle', '-', 'Color','k');
% Plot with 3 standard deviation
% ------------------------------
hLine1.stdClimPlus = line( ...
dayd, mean_ssps + 3 * std_ssps ,'Linestyle', '-', 'Color','r');
hLine1.stdClimMinus = line( ...
dayd, mean_ssps - 3 * std_ssps ,'Linestyle', '-', 'Color','r');
% Plot mean temperature climatology
% ---------------------------------
axes( hPlotAxes(2));
hLine2.meanClim = line( ...
dayd, mean_sstp,'Linestyle', '-', 'Color','k');
hLine2.stdClimPlus = line( ...
dayd, mean_sstp + 3 * std_sstp ,'Linestyle', '-', 'Color','r');
hLine2.stdClimMinus = line( ...
dayd, mean_sstp - 3 * std_sstp ,'Linestyle', '-', 'Color','r');
% Store the handle of the bucketline
% ----------------------------------
set( hPlotAxes(1), 'UserData', hLine1 );
set( hPlotAxes(2), 'UserData', hLine2 );
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );
end
%% HeaderMenuCallback
% -------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment