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

ajout de commentaires et nettoyage de code

parent 8f54a485
No related branches found
No related tags found
No related merge requests found
function [error] = readTsgDataNetCDF( hMainFig, filename) function [error] = readTsgDataNetCDF( hMainFig, filename)
% Function to read the TSG data. Should be a NetCDF file % Function to read the TSG data. Should be a NetCDF file
% GOSUD data format TSG V1.4 % GOSUD data format TSG V1.6
% %
% Input % Input
% ----- % -----
% hMainFig ............ Handel to the main user interface % hMainFig ............ Handle to the main user interface
% filename ........... Data filename % filename ............ Data filename
% %
% Output % Output
% ------ % ------
...@@ -13,6 +13,9 @@ function [error] = readTsgDataNetCDF( hMainFig, filename) ...@@ -13,6 +13,9 @@ function [error] = readTsgDataNetCDF( hMainFig, filename)
% %
% The data are store using setappdata - Variable name : 'tsg_data' % The data are store using setappdata - Variable name : 'tsg_data'
% %
% DAYD, DAYD_WS and DAYD_EXT in tsg structure use Matlab datenum, they
% should be converted from julian days using 1950 reference in NetCDF file
%
% $Id$ % $Id$
%% Check Netcdf library version %% Check Netcdf library version
...@@ -173,8 +176,9 @@ automaticQC( hMainFig ) ...@@ -173,8 +176,9 @@ automaticQC( hMainFig )
var = char(key); var = char(key);
tsg.(var) = nc.VARIABLES.(var).data__; tsg.(var) = nc.VARIABLES.(var).data__;
% transforme julian days variables to Matlab datenum % when variable is julian days from 1950 reference, transform to
% -------------------------------------------------- % Matlab datenum
% --------------------------------------------------------------
if strmatch('DAYD', var) if strmatch('DAYD', var)
tsg.(var) = julianToDatenum(tsg.(var)); tsg.(var) = julianToDatenum(tsg.(var));
end end
......
function [error] = writeTSGDataNetCDF( hTsgGUI, filename) function [error] = writeTSGDataNetCDF( hTsgGUI, filename)
% [error] = writeTSGDataNetCDF( hTsgGUI, filename) % [error] = writeTSGDataNetCDF( hTsgGUI, filename)
% Function to write TSG data in NetCDF file. % Function to write TSG data in NetCDF file to GOSUD format 1.6.
% %
% Input % Input
% ----- % -----
...@@ -14,9 +14,8 @@ function [error] = writeTSGDataNetCDF( hTsgGUI, filename) ...@@ -14,9 +14,8 @@ function [error] = writeTSGDataNetCDF( hTsgGUI, filename)
% %
% The data are store using setappdata - Variable name : 'tsg_data' % The data are store using setappdata - Variable name : 'tsg_data'
% %
% Actually, with DAYD, DAYD_WS and DAT_EXT dimensions defined: 61 variables % DAYD, DAYD_WS and DAYD_EXT in tsg structure use Matlab datenum, they
% DAYD, DAYD_WS dimensions defined: 57 variables % should be converted to julian days using 1950 reference in NetCDF file
% DAYD only dimension defined: 53 variables
% %
% $Id$ % $Id$
...@@ -323,7 +322,7 @@ end ...@@ -323,7 +322,7 @@ end
end end
end end % end of loop over variables keys
% Close waitbar % Close waitbar
% ------------- % -------------
...@@ -360,24 +359,17 @@ end ...@@ -360,24 +359,17 @@ end
% ----------------------------------------------------------------- % -----------------------------------------------------------------
for key = keys(nc.VARIABLES) for key = keys(nc.VARIABLES)
var = char(key); var = char(key);
% Convert Matlab julian days (datenum) to 1950 reference
% ------------------------------------------------------
if strmatch('DAYD', var) if strmatch('DAYD', var)
nc.VARIABLES.(var).data__ = datenumToJulian(tsg.(var)); nc.VARIABLES.(var).data__ = datenumToJulian(tsg.(var));
else else
nc.VARIABLES.(var).data__ = tsg.(var); nc.VARIABLES.(var).data__ = tsg.(var);
end end
end end
% % Convert Matlab julian days (datenum) to 1950 reference
% % ------------------------------------------------------
% ncv_keys = keys(nc.VARIABLES);
% d = strmatch('DAYD', ncv_keys);
% for i=1:numel(d)
% tsg.(ncv_keys{d(i)}) = datenumToJulian(tsg.(ncv_keys{d(i)}));
% end
% loop over all global attributes and get associated value in tsg
% loop over all global attributes and get associated value in tsg
% structure % structure
% ----------------------------------------------------------------- % -----------------------------------------------------------------
for key = keys(nc.ATTRIBUTES) for key = keys(nc.ATTRIBUTES)
...@@ -385,8 +377,6 @@ end ...@@ -385,8 +377,6 @@ end
nc.ATTRIBUTES.(att).data__ = tsg.(att); nc.ATTRIBUTES.(att).data__ = tsg.(att);
end end
% try
% write netcdf file with and display waibar (boolean) % write netcdf file with and display waibar (boolean)
% --------------------------------------------------- % ---------------------------------------------------
write( nc, filename, 'NC_CLOBBER', true ); write( nc, filename, 'NC_CLOBBER', true );
...@@ -394,9 +384,6 @@ end ...@@ -394,9 +384,6 @@ end
% Everything OK % Everything OK
% ------------- % -------------
error = 1; error = 1;
% catch
% error = -1;
% end
end end
......
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