From 49192df255abdf84dacae0d6de04c1f55cc5ec12 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Wed, 13 Jan 2016 15:58:29 +0000
Subject: [PATCH] add old constant tsg.cst.TSG_WS_TIMEDIFF, tsg.SSPS_STDMAX and
 tsg.cst.TSG_DT_SMOOTH in preferenceForm

---
 tsg_util/preferencesForm.m    | 160 +++++++++++++++++++++++++++++++++-
 tsg_util/tsg_initialisation.m |  10 ---
 tsg_util/tsg_preferences.m    |  30 +++++++
 tsgqc.m                       |   6 +-
 4 files changed, 192 insertions(+), 14 deletions(-)

diff --git a/tsg_util/preferencesForm.m b/tsg_util/preferencesForm.m
index 0ad3feb..fd01d1c 100644
--- a/tsg_util/preferencesForm.m
+++ b/tsg_util/preferencesForm.m
@@ -566,6 +566,143 @@ if bottom < .1
   left = left + inc_x;
 end
 
+% goto next column
+% ----------------
+bottom = 0.95;
+left = left + inc_x;
+  
+% display DT_SMOOTH  TITLE
+% -------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize, 'FontWeight', 'bold',...
+  'HorizontalAlignment', 'Left', ...
+  'Position',[left, bottom, 2*length, height], ...
+  'String', 'Smoothing of TSG time-series');
+
+bottom = bottom - inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
+% display DT_SMOOTH in text
+% ------------------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize-1, 'HorizontalAlignment', 'left', ...
+  'Position',[left, bottom, length, height], ...
+  'TooltipString', 'value in minutes, beteewn 0 and 1339)', ...
+  'String', 'TSG DT SMOOTH (in min)');
+
+% display date format for attribute uicontrol
+% -------------------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', 'Style', 'Edit', ...
+  'Fontsize', tsg.fontSize-2, 'BackgroundColor', 'w', ...
+  'HorizontalAlignment', 'right', ...
+  'Position', [left + length, bottom, length, height], ...
+  'TooltipString', 'value in minutes, beteewn 0 and 1339)', ...
+  'String', tsg.preference.dt_smooth , ...
+  'Tag', 'PREFERENCES_DT_SMOOTH');
+
+bottom = bottom - 4 *inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
+% display MAXDIFF  TITLE
+% -------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize, 'FontWeight', 'bold',...
+  'HorizontalAlignment', 'Left', ...
+  'Position',[left, bottom, 2*length, 1.5 * height], ...
+  'String', 'Maximum time difference between tsg data and water sample used to compute the difference');
+
+bottom = bottom - inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
+% display DT_SMOOTH in text
+% ------------------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize-1, 'HorizontalAlignment', 'left', ...
+  'Position',[left, bottom, length, height], ...
+  'TooltipString', 'value in minutes, beteewn 0 and 1339, default 5)', ...
+  'String', 'WS Dime diff (in min)');
+
+% display date format for attribute uicontrol
+% -------------------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', 'Style', 'Edit', ...
+  'Fontsize', tsg.fontSize-2, 'BackgroundColor', 'w', ...
+  'HorizontalAlignment', 'right', ...
+  'Position', [left + length, bottom, length, height], ...
+  'TooltipString', 'value in minutes, beteewn 0 and 1339, default 5)', ...
+  'String', tsg.preference.ws_timediff , ...
+  'Tag', 'PREFERENCES_WS_TIMEDIFF');
+
+bottom = bottom - 4* inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
+% display STDMAX  TITLE
+% -------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize, 'FontWeight', 'bold',...
+  'HorizontalAlignment', 'Left', ...
+  'Position',[left, bottom, 2*length, 1.5*height], ...
+  'String', 'Salinity, in 1 hour interval, should not depart the average for more than SAL_STD_MAX standard deviation');
+
+bottom = bottom - inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
+% display DT_SM in text
+% ------------------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize-1, 'HorizontalAlignment', 'left', ...
+  'Position',[left, bottom, length, height], ...
+  'TooltipString', 'SSPS STD Max, default 0.1', ...
+  'String', 'SSPS STD Max');
+
+% display date format for attribute uicontrol
+% -------------------------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', 'Style', 'Edit', ...
+  'Fontsize', tsg.fontSize-2, 'BackgroundColor', 'w', ...
+  'HorizontalAlignment', 'right', ...
+  'Position', [left + length, bottom, length, height], ...
+  'TooltipString', 'SSPS STD Max, default 0.1', ...
+  'String', tsg.preference.ssps_stdmax , ...
+  'Tag', 'PREFERENCES_SSPS_STDMAX');
+
+bottom = bottom - inc_y - height;
+if bottom < .1
+  bottom = 0.95;
+  left = left + inc_x;
+end
+
 % CONTINUE PUSH BUTTON
 % --------------------
 % The Continue (valid)  button
@@ -652,7 +789,27 @@ uiwait(hPreferencesFig);
       get(prefs.PREFERENCES_SSTP_MIN, 'string');
     tsg.preference.sstp_max_string = ...
       get(prefs.PREFERENCES_SSTP_MAX, 'string');
+    tsg.preference.dt_smooth = ...
+      get(prefs.PREFERENCES_DT_SMOOTH, 'string');
+    tsg.preference.ws_timediff = ...
+      get(prefs.PREFERENCES_WS_TIMEDIFF, 'string');
+    tsg.preference.ssps_stdmax = ...
+      get(prefs.PREFERENCES_SSPS_STDMAX, 'string');
+    
+    % Smoothing of tsg time series over interval in minutes
+    % -------------------------------------------------------
+    hour = floor(str2double(tsg.preference.dt_smooth)/60);
+    min = mod(str2double(tsg.preference.dt_smooth), 60);
+    smooth = datenum(0, 0, 0, hour, min , 0);
+    tsg.cst.TSG_DT_SMOOTH = smooth;
     
+    tsg.SSPS_STDMAX = str2double(tsg.preference.ssps_stdmax);
+    
+    hour = floor(str2double(tsg.preference.ws_timediff)/60);
+    min = mod(str2double(tsg.preference.ws_timediff), 60);
+    timediff = datenum(0, 0, 0, hour, min , 0);
+    tsg.cst.TSG_WS_TIMEDIFF = timediff;
+
     % Save tsg structure
     % ------------------
     setappdata(hTsgGUI, 'tsg_data', tsg);
@@ -699,7 +856,8 @@ uiwait(hPreferencesFig);
 
   end % end of cancelCallback nested function
 
-
+  % The climatology level are not the same between WOA and ISAS
+  % -----------------------------------------------------------
   function update_climato_depth(obj, event)
     disp(get(prefs.PREFERENCES_LEVITUS_VALUE, 'value'))
     if get(prefs.PREFERENCES_LEVITUS_VALUE, 'value') == 3
diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m
index e84cac3..4439492 100644
--- a/tsg_util/tsg_initialisation.m
+++ b/tsg_util/tsg_initialisation.m
@@ -175,16 +175,11 @@ tsg.qc.active.Color  = d.QUALITY.NO_CONTROL.color;
 % -------------------------------------------------------------------------
 %%              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;
 
@@ -194,11 +189,6 @@ tsg.SSTP_STDMAX = 1.0;
 % ---------------------------------------------------------------------
 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);
-
 % Get attributes & variables list from dynaload instance
 % ------------------------------------------------------
 nca = keys(d.ATTRIBUTES);
diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m
index 8278531..0d5ea1e 100644
--- a/tsg_util/tsg_preferences.m
+++ b/tsg_util/tsg_preferences.m
@@ -103,6 +103,21 @@ tsg = getappdata( hTsgGUI, 'tsg_data');
 % -----------------------------------
 tsg.preference = preference;
 
+% Initialize some values for smoothing
+% -------------------------------------------------------
+hour = floor(str2double(tsg.preference.dt_smooth)/60);
+min = mod(str2double(tsg.preference.dt_smooth), 60);
+smooth = datenum(0, 0, 0, hour, min , 0);
+tsg.cst.TSG_DT_SMOOTH = smooth;
+tsg.SSPS_STDMAX = str2double(tsg.preference.ssps_stdmax);
+
+hour = floor(str2double(tsg.preference.ws_timediff)/60);
+min = mod(str2double(tsg.preference.ws_timediff), 60);
+timediff = datenum(0, 0, 0, hour, min , 0);
+tsg.cst.TSG_WS_TIMEDIFF = timediff;
+% tsg.cst
+% tsg.SSPS_STDMAX
+
 % Save structure tsg
 % ------------------
 setappdata( hTsgGUI, 'tsg_data', tsg);
@@ -161,6 +176,21 @@ set(hTsgGUI,'Pointer','arrow');
     preference.date_format_variable  = 'yyyymmddHHMMSS';
     preference.date_format_attribute = 'yyyymmddHHMMSS';
     
+    % use in tsg-average by tsg.cst.TSG_DT_SMOOTH
+    % this value in in minute
+    % ---------------------------------------------
+    preference.dt_smooth             = '60';
+    
+    % Salinity, in 1 hour interval, should not depart the average for more
+    % than SAL_STD_MAX standard deviation
+    % -------------------------------------
+    preference.ssps_stdmax           = '0.1';
+    % Maximum time difference between tsg data and water sample used to
+    % compute the difference : 5 minutes.
+    % ------------------------------------
+    preference.ws_timediff           = '5';
+    
+    
     % save preference struct to 'prefdir.mat' file
     % ---------------------------------------------
     save(config_file, 'preference');
diff --git a/tsgqc.m b/tsgqc.m
index 8a8d6b8..1d6cafb 100644
--- a/tsgqc.m
+++ b/tsgqc.m
@@ -38,9 +38,9 @@ global GOSUD_FORMAT_VERSION
 % version number, may be used to initialize some files when it change
 % 0.90x -> 1.0RCx
 % -------------------------------------------------------------------
-VERSION      = 1.430;  % -> 1.42
-CHAR_VERSION = '1.43';
-DATE_VERSION = '04 may 2015';
+VERSION      = 1.440;  % -> 1.44
+CHAR_VERSION = '1.44';
+DATE_VERSION = '13 jan 2016';
 
 % netcdf file version, see DATA FORMAT TSG document:
 % CORTSG_format_gosud.doc
-- 
GitLab