From ff253b83967f556a2c4e264f16692755b242e44e Mon Sep 17 00:00:00 2001
From: Yves Gouriou <yves.gouriou@ird.fr>
Date: Tue, 13 Jan 2009 13:57:27 +0000
Subject: [PATCH] =?UTF-8?q?Variables=20ADJUSTED=20Ces=20variables=20ne=20c?=
 =?UTF-8?q?ontiennent=20plus=20que=20des=20donn=C3=A9es=20ayant=20=C3=A9t?=
 =?UTF-8?q?=C3=A9=20corrig=C3=A9es=20via=20le=20module=20de=20correction.?=
 =?UTF-8?q?=20Les=20donn=C3=A9es=20n'ayant=20pas=20=C3=A9t=C3=A9=20corrig?=
 =?UTF-8?q?=C3=A9es=20sont=20mises=20=C3=A0=20NaN=20dans=20ces=20variables?=
 =?UTF-8?q?=20ADJUSTED?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 BUGS                     | 29 +++++++++++++++++++++++++++++
 tsg_util/corTsgLinear.m  | 21 +++++++++------------
 tsg_util/corTsgMedian.m  | 11 ++++-------
 tsg_util/diffTsgSample.m |  1 +
 tsgqc.m                  | 15 ++++++++-------
 5 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/BUGS b/BUGS
index 1fbbc38..eb35bce 100644
--- a/BUGS
+++ b/BUGS
@@ -48,4 +48,33 @@ must be the same.
 
 Error in ==> tsgqc>Cal_OffMenuCallback at 1603
     tsg.CNDC_LINCOEF(1) = str2num(get( hetCalCNDCSlope,  'String'));
+	
+9/01/2009
+---------
+The name of the directory cannot be identical to the name of the program.
+It cannot be named 'tsgqc'. Otherwise there is a problem to get the
+directory of the program. See the following lines :
+
+fulltsgqcname = mfilename('fullpath');
+DEFAULT_PATH_FILE = strrep(fulltsgqcname, tsgqcname, '') ;
+
+9/01/2009
+---------
+La touche CANCEL the calibration rend les variables _CAL
+EMPTY.
+
+En fait si à l'ouverture du fichier une vzariable CAL existe,
+que l'on veuille plusieurs tests et revenir à la variable _CAL
+intiale ce n'est pas possible. La réinitialisation est sévère !
+
+IL faut 2 boutons :
+1 - BACK -One step backward
+2 - CANCEL - Empties the varaibalbe _CAL
+
+9/01/2009
+---------
+The correction is applied on SSPS, SSJT, SSTP data but not
+on _CAL data
+
+
 
diff --git a/tsg_util/corTsgLinear.m b/tsg_util/corTsgLinear.m
index 1ac5974..1b13c90 100644
--- a/tsg_util/corTsgLinear.m
+++ b/tsg_util/corTsgLinear.m
@@ -57,17 +57,13 @@ PROBABLY_GOOD = get(tsg.qc.hash, 'PROBABLY_GOOD', 'code');
 PROBABLY_BAD  = get(tsg.qc.hash, 'PROBABLY_BAD',  'code');
 VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code');
 
-% intialisation
-% -------------
+% Intialisation
+% 01/09/2009 : intialisation to NaN
+% ---------------------------------
 if isempty( tsg.([PARA '_ADJUSTED']) )  
-  tsg.([PARA '_ADJUSTED'])       = tsg.(PARA);
-  tsg.([PARA '_ADJUSTED_QC'])    = tsg.([PARA '_QC']);
-end
-
-% If only calibration have been applied ERROR is empty
-% ---------------------------------------------------
-if isempty( tsg.([PARA '_ADJUSTED_ERROR']) )  
-  tsg.([PARA '_ADJUSTED_ERROR']) = NaN* ones(size(tsg.(PARA))); 
+  tsg.([PARA '_ADJUSTED'])       = NaN*ones(size(tsg.(PARA)));
+  tsg.([PARA '_ADJUSTED_QC'])    = NaN*ones(size(tsg.([PARA '_QC'])));
+  tsg.([PARA '_ADJUSTED_ERROR']) = NaN*ones(size(tsg.(PARA))); 
 end
 
 if dateMax > dateMin
@@ -96,8 +92,8 @@ if dateMax > dateMin
         [p, S, mu] = polyfit( X, Y, 1);
 
         % The correction is applied to the TSG between dateMin and dateMax using
-        % a linear interpolation only on measurements better than
-        % PROBABLY_BAD QC
+        % a linear interpolation only on measurements with keptCode Quality
+        % Codes
         % ----------------------------------------------------------------------
         for icode = 1 : length( keptCode )
           dtTsg = find( tsg.DAYD    >= dateMin  & tsg.DAYD <= dateMax &...
@@ -109,6 +105,7 @@ if dateMax > dateMin
                                     polyval( p, tsg.DAYD(dtTsg), S, mu);
             tsg.([PARA '_ADJUSTED'])(dtTsg) = ...
                             tsg.(PARA)(dtTsg) + tsg.([PARA '_ADJUSTED'])(dtTsg);
+            tsg.([PARA '_ADJUSTED_QC'])(dtTsg) = tsg.([PARA '_QC'])(dtTsg);
 
             % The error is maximum, equal to 1, if the median is computed with
             % less than 4 samples
diff --git a/tsg_util/corTsgMedian.m b/tsg_util/corTsgMedian.m
index f0f465a..d9e3dd5 100644
--- a/tsg_util/corTsgMedian.m
+++ b/tsg_util/corTsgMedian.m
@@ -66,13 +66,9 @@ VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code');
 % intialisation
 % -------------
 if isempty( tsg.([PARA '_ADJUSTED']) )  
-  tsg.([PARA '_ADJUSTED'])       = tsg.(PARA);
-  tsg.([PARA '_ADJUSTED_QC'])    = tsg.([PARA '_QC']);
-end
-% If only calibration have been applied ERROR is empty
-% ---------------------------------------------------
-if isempty( tsg.([PARA '_ADJUSTED_ERROR']) )  
-  tsg.([PARA '_ADJUSTED_ERROR']) = NaN* ones(size(tsg.(PARA))); 
+  tsg.([PARA '_ADJUSTED'])       = NaN*ones(size(tsg.(PARA)));
+  tsg.([PARA '_ADJUSTED_QC'])    = NaN*ones(size(tsg.([PARA '_QC'])));
+  tsg.([PARA '_ADJUSTED_ERROR']) = NaN*ones(size(tsg.(PARA))); 
 end
 
 % Create a structure with an NaN
@@ -198,6 +194,7 @@ if dateMax > dateMin
                                   interp1(cor.DAYD, cor.DIFF, tsg.DAYD(dtTsg));
       tsg.([PARA '_ADJUSTED_ERROR'])(dtTsg) = ...
                                   interp1(cor.DAYD, cor.ERROR, tsg.DAYD(dtTsg));
+      tsg.([PARA '_ADJUSTED_QC'])(dtTsg) = tsg.([PARA '_QC'])(dtTsg);
     end
         
   end
diff --git a/tsg_util/diffTsgSample.m b/tsg_util/diffTsgSample.m
index b8fd96e..b42ec7a 100644
--- a/tsg_util/diffTsgSample.m
+++ b/tsg_util/diffTsgSample.m
@@ -13,6 +13,7 @@ tsg    = getappdata( hMainFig, 'tsg_data');
 probablyGoodCode = get(tsg.qc.hash, 'PROBABLY_GOOD', 'code');
 missingValueCode = get(tsg.qc.hash, 'MISSING_VALUE', 'code');
 
+% For temperature : 
 % IF PARA = 'SSJT' use 'SSTP' to get the samples
 % ----------------------------------------------
 SAMPLE = PARA;
diff --git a/tsgqc.m b/tsgqc.m
index f137414..2c4a388 100644
--- a/tsgqc.m
+++ b/tsgqc.m
@@ -1547,8 +1547,7 @@ end
     set( hTimelimitToggletool, 'state', 'off', 'enable', 'off' );
     set( hZoomInToggletool,    'state', 'off', 'enable', 'on' );
     set( hZoomOutToggletool,   'state', 'off', 'enable', 'on' );
-
-        
+       
     % Get tsg application data
     % ------------------------
     tsg = getappdata( hMainFig, 'tsg_data' );
@@ -1647,7 +1646,7 @@ end
     
     % Update the Adjusted variables (SSPS - SSJT) with calibrated records
     % -------------------------------------------------------------------
-    updateAdjustedVariable( hMainFig );
+    % updateAdjustedVariable( hMainFig );
     
     % Refresh plot #1
     % ---------------
@@ -1682,7 +1681,7 @@ end
     
     % Update the Adjusted variables 
     % -----------------------------
-    updateAdjustedVariable( hMainFig );
+    % updateAdjustedVariable( hMainFig );
     
     % Refresh plot #1
     % ---------------
@@ -2494,9 +2493,11 @@ end
     % --------------------------------------------------
     PARA = tsg.preference.parameter{1};
 
-    % To cancel the correction set the ERROR to [] then
-    % call updateAdjustedVariable.
+    % To cancel the correction set the ADJUSTED variable
+    % to [] 
     % --------------------------------------------------
+    tsg.([PARA '_ADJUSTED']) = [];
+    tsg.([PARA '_ADJUSTED_QC']) = [];
     tsg.([PARA '_ADJUSTED_ERROR']) = [];
 
     % Save tsg data
@@ -2506,7 +2507,7 @@ end
     % Set the ADJUSTED variable either to the raw variable or to
     % the calibrated variable
     % ----------------------------------------------------------
-    updateAdjustedVariable( hMainFig );
+    % updateAdjustedVariable( hMainFig );
 
     % Plot in the 3 axes
     % ------------------
-- 
GitLab