Newer
Older
function tsg_initialisation(hMainFig)
%
% Input
% -----
% hMainFig ............ Handel to the main user interface
Yves Gouriou
committed
%
% disable ButtonMotion on main fig
% ---------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% init empty tsg structure
% ------------------------
tsg = [];
% -------------------------------------------------------------------------
%% Constants for NetCDF DATA FORMAT TSG
% -------------------------------------------------------------------------
% -------------------
NETCDF_FORMAT_VERSION = '1.4';
% date of reference for julian days, is 1st january 1950
% ------------------------------------------------------
REFERENCE_DATE_TIME = '19500101000000';
% get actual date
% ---------------
date = datestr(now,30);
% set default font size
% ---------------------
tsg.fontSize = 11;
% -------------------------------------------------------------------------
%% Levitus fields for climatology
% -------------------------------------------------------------------------
tsg.levitus.data = [];
tsg.levitus.type = 'none';

jacques.grelet_ird.fr
committed
tsg.levitus.time = 1;
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------
tsg.file.pathstr = [];
tsg.file.name = [];
tsg.file.ext = [];
tsg.file.versn = [];
tsg.file.type = [];
% -------------------------------------------------------------------------
%% Smooth TSG time serie fields
% -------------------------------------------------------------------------
% tsg.ssps_smooth = [];
% tsg.ssps_smooth.nval = [];
% tsg.SSTP_smooth = [];
% tsg.SSTP_smooth.nval = [];
% -------------------------------------------------------------------------
%% Variable used for the report
% -------------------------------------------------------------------------
tsg.report.tsgfile = ''; % Name of the TSG file
tsg.report.wsfile = ''; % Name of the Water sample file
tsg.report.extfile = ''; % Name of the External sample file
tsg.report.nodate = 0; % Records deleted because they have no date
tsg.report.sortdate = 0; % Records deleted because date is not increasing
tsg.report.badvelocity = 0; % Records deleted because of bad velocity
% (> 50 knots - test in shipVelocity)
% -------------------------------------------------------------------------
%% Structure used to merge WS and EXT sample
% need to be intialise (isempty test performed on tsg.SSPS_SPL
% -------------------------------------------------------------------------
% tsg.DAYD_SPL = [];
% tsg.LATX_SPL = [];
% tsg.LONX_SPL = [];
% tsg.SSPS_SPL = [];
% tsg.SSPS_SPL_QC = [];
% tsg.SSPS_SPL_TYPE = [];
% tsg.SSTP_SPL = [];
% tsg.SSTP_SPL_QC = [];
% tsg.SSTP_SPL_TYPE = [];
% tsg.SSJT_SPL = [];
% tsg.SSJT_SPL_QC = [];
% tsg.SSJT_SPL_TYPE = [];
%
% -------------------------------------------------------------------------
%% Constants for the quality control procedure
% -------------------------------------------------------------------------
% Quality flags reference table, see GOSUD, DATA FORMAT TSG V1.4, table 4
% -----------------------------------------------------------------------
% Code Meaning
%
% 0 No QC was performed
% 1 Good data
% 2 Probably good data
% 3 Bad data that are potentially correctable
% 4 Bad data
% 5 Value changed
% 6 Data acquired in harbour
% 7 Not used
% 8 Interpolated value
% 9 Missing value
% Quality definition, we use a hashtable with a definition file

jacques.grelet_ird.fr
committed
% located in @tsg_nc/tsg_quality.csv,
% use this file if you want add or modify quality context menu
% -------------------------------------------------------------

jacques.grelet_ird.fr
committed
tsg.qc.hash = tsg_nc('tsg_quality.csv');
% set default code at startup
% ---------------------------
tsg.qc.active.Code = get(tsg.qc.hash, 'NO_CONTROL', 'code');
tsg.qc.active.Color = get(tsg.qc.hash, 'NO_CONTROL', 'color');
% set empty queue (use for undo/redo)
% -----------------------------------
tsg.queue = queue;
% -------------------------------------------------------------------------
%% Constants for the Correction procedure
% -------------------------------------------------------------------------
% Smoothing of tsg time series over 1 hour interval
% 1 hour interval expressed in MATLAB serial Number
% -------------------------------------------------
tsg.cst.TSG_DT_SMOOTH = datenum(0, 0, 0, 1, 0 , 0);
% Smoothing of tsg time series :
% Salinity, in 1 hour interval, should not depart the average for more
% than SAL_STD_MAX standard deviation
% --------------------------------------------------------------------
tsg.SSPS_STDMAX = 0.1;
tsg.SSJT_STDMAX = 1.0;
tsg.SSTP_STDMAX = 1.0;
% Correction is estimated by computing the median value of X tsg-sample
% differences
% Time window in days used to compute the correction
% ---------------------------------------------------------------------
tsg.cst.COR_TIME_WINDOWS = 10;
% Maximum time difference between tsg data and water sample used to
% compute the difference : 5 minutes.
% -----------------------------------------------------------------
tsg.cst.TSG_WS_TIMEDIFF = datenum(0, 0, 0, 0, 5, 0);
Yves Gouriou
committed
% -------------------------------------------------------------------------
%% CLASS tsg_nc
% --------------------------------------------------------------------
% Get variables list codes from class tsg_nc with file 'tsg_ncvar.csv'
% --------------------------------------------------------------------
ncv = tsg_nc('tsg_ncvar.csv');
ncv_keys = keys(ncv);
% Get global attributes list from class tsg_nc with file 'tsg_ncattr.csv'
% -----------------------------------------------------------------------
nca = tsg_nc('tsg_ncattr.csv');
nca_keys = keys(nca);
% store tsg NetCDF data structure
% -------------------------------
% dimensions
% ----------
tsg.DAYD = [];
tsg.DAYD_WS = [];
tsg.DAYD_EXT = [];
% initialise tsg structure from tsg_nc objects
% --------------------------------------------
% assign empty matrix to all variables
% ------------------------------------
for i=1:numel(ncv_keys)
variable = ncv_keys{i};
tsg.(variable) = [];
end
% assign empty string to all globals attributes
% ---------------------------------------------
for i=1:numel(nca_keys)
global_att = nca_keys{i};
tsg.(global_att) = '';
end
% set some fields
% ---------------
tsg.FORMAT_VERSION = NETCDF_FORMAT_VERSION;
tsg.DATE_CREATION = [date(1:8) date(10:15)];
tsg.DATE_UPDATE = tsg.DATE_CREATION;
tsg.REFERENCE_DATE_TIME = REFERENCE_DATE_TIME;

jacques.grelet_ird.fr
committed
% init tsg preference to default values
% -------------------------------------
tsg.preference.autoload = 'off';
% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);