From 608eae889293977ff6b4ea108f4e84ecf5698e9c Mon Sep 17 00:00:00 2001
From: Yves Gouriou <yves.gouriou@ird.fr>
Date: Mon, 17 Mar 2008 12:51:21 +0000
Subject: [PATCH] =?UTF-8?q?Finalis=C3=A9=20les=20modules=20pour=20le=20cho?=
 =?UTF-8?q?ix=20du=20param=C3=A8tre.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Je n'utilise plus tsg_moveaverage car les calculs
effectués par cette fonction prenent du temps.
La moyenne des données TSG est maintenant uniquement
effectué à la position de séchnatilonns (WS et EXT)
---
 tsg_util/diffTsgSample.m      |  17 ++-
 tsg_util/plot_Correction.m    |   2 +-
 tsg_util/plot_Validation.m    |  32 +++---
 tsg_util/tsg_average.m        |  85 ++++++++++++++
 tsg_util/tsg_initialisation.m |   4 +-
 tsg_util/tsg_mergesample.m    |   2 +-
 tsg_util/tsg_moveaverage.m    |  16 ++-
 tsgqc_GUI.m                   | 206 +++++++++++++++++++++++++++-------
 8 files changed, 296 insertions(+), 68 deletions(-)
 create mode 100644 tsg_util/tsg_average.m

diff --git a/tsg_util/diffTsgSample.m b/tsg_util/diffTsgSample.m
index 11bae56..0ad8f7a 100644
--- a/tsg_util/diffTsgSample.m
+++ b/tsg_util/diffTsgSample.m
@@ -34,12 +34,17 @@ for i= 1 : m
 
     % Keep the smooth TSG value
     % -------------------------
-    if  timeDiff(indMin) < tsg.cst.TSG_WS_TIMEDIFF && ...
-        ~isnan(tsg.ssps_smooth(indMin))
-
-      tsg.([PARA '_SPL_SMOOTH'])(i)  = tsg.ssps_smooth(indMin);
-
-    end
+    smooth = tsg_average(hTsgGUI, PARA, indMin);
+    if  timeDiff(indMin) < tsg.cst.TSG_WS_TIMEDIFF && ~isnan(smooth)
+      
+      % The smooth TSG time series (tsg_moveaverage) is
+      % no more computed : too long
+      % We now computed a smooth value only at the position of the sample
+      % -----------------------------------------------------------------
+      %tsg.([PARA '_SPL_SMOOTH'])(i)  = tsg.ssps_smooth(indMin);
+      tsg.([PARA '_SPL_SMOOTH'])(i)  = smooth;
+
+    end 
 end
 
 % Salinity difference : Sample minus smoothed TSG
diff --git a/tsg_util/plot_Correction.m b/tsg_util/plot_Correction.m
index 5b27631..87e5e2d 100644
--- a/tsg_util/plot_Correction.m
+++ b/tsg_util/plot_Correction.m
@@ -64,7 +64,7 @@ if iERR ~= 0
 end
 
 % **************************** AXE 2 ***********************************
-        
+
 % Plot SSPS and SAMPLE, with code color, on axe 2
 % ------------------------------------------------
 plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.(PARA), tsg.([PARA '_QC']),...
diff --git a/tsg_util/plot_Validation.m b/tsg_util/plot_Validation.m
index 1ec8413..bcf46d8 100644
--- a/tsg_util/plot_Validation.m
+++ b/tsg_util/plot_Validation.m
@@ -10,10 +10,6 @@ switch nPlot
   case 1
     
     erase_Line( hPlotAxes, 1 );
-%     if ~isempty( tsg.ssps_smooth )
-%       plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD, tsg.ssps_smooth, [],...
-%                 'SSPS_SMOOTH','k','-','*',2);
-%     end
 
     if ~isempty( tsg.(PARA) )
       plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD, tsg.(PARA), tsg.([PARA '_QC']),...
@@ -22,18 +18,22 @@ switch nPlot
 
     % Plot Salinity bucket
     % --------------------
-%     if ~isempty( tsg.SSPS_SPL )
-%       ind = find( tsg.SSPS_SPL_TYPE == 1 );
-%       if ~isempty(ind)
-%         plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(ind), tsg.SSPS_SPL(ind),...
-%                   tsg.SSPS_SPL_QC(ind),'SSPS_SPL_1','','none','square',5);
-%       end
-%       ind = find( tsg.SSPS_SPL_TYPE > 1 );
-%       if ~isempty(ind)
-%         plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(ind), tsg.SSPS_SPL(ind),...
-%                   tsg.SSPS_SPL_QC(ind),'SSPS_SPL_2','','none','o',5);
-%       end
-%     end
+    if ~isempty( tsg.([PARA '_SPL']) )
+      ind = find( tsg.([PARA '_SPL_TYPE']) == 1 );
+      if ~isempty(ind)
+        plot_Tsg( hMainFig, hPlotAxes, 1,...
+                  tsg.DAYD_SPL(ind), tsg.([PARA '_SPL'])(ind),...
+                  tsg.([PARA '_SPL_QC'])(ind), ...
+                  [PARA '_SPL_1'],'','none','square',5);
+      end
+      ind = find( tsg.([PARA '_SPL_TYPE']) > 1 );
+      if ~isempty(ind)
+        plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(ind),...
+                  tsg.([PARA '_SPL'])(ind),...
+                  tsg.([PARA '_SPL_QC'])(ind),...
+                  [PARA '_SPL_2'],'','none','o',5);
+      end
+    end
 
   % ---------------------------------------------------------------------
   case 2
diff --git a/tsg_util/tsg_average.m b/tsg_util/tsg_average.m
new file mode 100644
index 0000000..e8aed6a
--- /dev/null
+++ b/tsg_util/tsg_average.m
@@ -0,0 +1,85 @@
+function [smooth] = tsg_average(hTsgGUI, PARA, iTsg)
+% Perform the average of a time series at the position of a WS sample
+%
+% The average is made over a period equal to 'tsg.cst.TSG_DT_SMOOTH'
+% Data exceeding the average over that period by 'tsg.cst.TSG_STDMAX'
+% are not taken into account.
+%
+% Input
+% hTsgGUI ............ Handle to the main user interface
+%
+% No computation : NaN
+%
+
+% Get the tsg structure from the application
+% ------------------------------------------
+tsg = getappdata( hTsgGUI, 'tsg_data');
+
+% Memory allocation - nval only used for debug
+% --------------------------------------------
+% smooth = zeros( size(tsg.(PARA)) );
+% nval   = zeros( size(tsg.(PARA)) );
+
+% Loop over the tsg.SSPS time series
+% -----------------------------------
+%h = waitbar(0,'Please wait. Compute a smooth time series ....');
+%iEnd = length(tsg.(PARA));
+%for i = 1:iEnd
+  
+  % Display a wait bar
+  % ------------------
+%  waitbar(i/iEnd);
+  
+  % Select the param data over 'tsg.cst.TSG_DT_SMOOTH' time interval
+  % ind1 : indices of tsg.SSPS in the 'tsg.cst.TSG_DT_SMOOTH' time interval
+  % ind2 : indices of 'good' tsg.SSPS in the 'tsg.cst.TSG_DT_SMOOTH' time
+  %        interval
+  % --------------------------------------------------
+  ind1 = find( tsg.DAYD >= tsg.DAYD(iTsg) - tsg.cst.TSG_DT_SMOOTH/2 & ...
+               tsg.DAYD <= tsg.DAYD(iTsg) + tsg.cst.TSG_DT_SMOOTH/2 );
+	ind2 = ind1;
+  
+  if ~isempty(ind2)
+    
+    currentStd  = Inf;
+    previousStd = 0;
+    
+    % Compare Standard Deviation to the MAX acceptable STD
+    % ----------------------------------------------------
+    while currentStd > tsg.([PARA '_STDMAX']) && currentStd ~= previousStd
+      
+      previousStd = currentStd;
+      
+      % Standard deviation and average over timeInterval
+      % ------------------------------------------------
+			currentStd = nanstd(  tsg.(PARA)(ind2) );
+      meanParam  = nanmean( tsg.(PARA)(ind2) );
+            
+			% Indices of 'good' values of Param
+      % ---------------------------------
+      ind2 = ind1( tsg.(PARA)(ind1) >= meanParam - currentStd & ...
+                   tsg.(PARA)(ind1) <= meanParam + currentStd );
+    end
+    
+    smooth = nanmean( tsg.(PARA)(ind2) );
+    
+  else
+    smooth = NaN;
+  end
+  
+  % nval only used for debug
+  % ------------------------
+  % nval( i ) = length( ind2 );
+  
+%end 
+%close(h)
+
+% Transfer the smooth timeseries to the TSG structure
+% nval only used for debug
+% ---------------------------------------------------
+%tsg.ssps_smooth      = smooth;
+%tsg.ssps_smooth_nval = nval;
+
+% Update the tsg structure in the application
+% --------------------------------------------
+%setappdata( hTsgGUI, 'tsg_data', tsg);
\ No newline at end of file
diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m
index 0364bf9..5f5f8f3 100644
--- a/tsg_util/tsg_initialisation.m
+++ b/tsg_util/tsg_initialisation.m
@@ -58,8 +58,10 @@ tsg.file.type    = [];
 % -------------------------------------------------------------------------
 %%              Smooth TSG time serie fields
 % -------------------------------------------------------------------------
-tsg.ssps_smooth  = [];
+tsg.ssps_smooth      = [];
 tsg.ssps_smooth.nval = [];
+tsg.SSTP_smooth      = [];
+tsg.SSTP_smooth.nval = [];
 
 % -------------------------------------------------------------------------
 %%              Structure used to merge WS and EXT sample
diff --git a/tsg_util/tsg_mergesample.m b/tsg_util/tsg_mergesample.m
index 635be0e..29b799c 100644
--- a/tsg_util/tsg_mergesample.m
+++ b/tsg_util/tsg_mergesample.m
@@ -18,7 +18,7 @@ tsg  = getappdata( hTsgGUI, 'tsg_data');
 
 % There are only SSTP samples. The SSJT time series should
 % be compared to the SSTP samples. To simplfies the soft we use a
-% variable SSJT sample equla to the SSTP sample structure
+% variable SSJT sample equal to the SSTP sample structure
 % ---------------------------------------------------------------
 PARA_OLD = PARA;
 if strcmp( PARA, 'SSJT' )
diff --git a/tsg_util/tsg_moveaverage.m b/tsg_util/tsg_moveaverage.m
index fd6b584..b269e25 100644
--- a/tsg_util/tsg_moveaverage.m
+++ b/tsg_util/tsg_moveaverage.m
@@ -14,10 +14,10 @@ function [] = tsg_moveaverage(hTsgGUI, PARA)
 % ------------------------------------------
 tsg = getappdata( hTsgGUI, 'tsg_data');
 
-% Memory allocation
-% -----------------
+% Memory allocation - nval only used for debug
+% --------------------------------------------
 smooth = zeros( size(tsg.(PARA)) );
-nval   = zeros( size(tsg.(PARA)) );
+%nval   = zeros( size(tsg.(PARA)) );
 
 % Loop over the tsg.SSPS time series
 % -----------------------------------
@@ -25,6 +25,8 @@ h = waitbar(0,'Please wait. Compute a smooth time series ....');
 iEnd = length(tsg.(PARA));
 for i = 1:iEnd
   
+  % Display a wait bar
+  % ------------------
   waitbar(i/iEnd);
   
   % Select the param data over 'tsg.cst.TSG_DT_SMOOTH' time interval
@@ -64,14 +66,18 @@ for i = 1:iEnd
     smooth(i) = NaN;
   end
   
-  nval( i ) = length( ind2 );
+  % nval only used for debug
+  % ------------------------
+  % nval( i ) = length( ind2 );
+  
 end 
 close(h)
 
 % Transfer the smooth timeseries to the TSG structure
+% nval only used for debug
 % ---------------------------------------------------
 tsg.ssps_smooth      = smooth;
-tsg.ssps_smooth_nval = nval;
+%tsg.ssps_smooth_nval = nval;
 
 % Update the tsg structure in the application
 % --------------------------------------------
diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m
index 1d0860b..c329d96 100644
--- a/tsgqc_GUI.m
+++ b/tsgqc_GUI.m
@@ -571,7 +571,7 @@ hPlotAxes(4) = axes(...     % the axes for plotting ship track map
   'HandleVisibility','on', ...
   'Position',[.05, .05, .9, .9]);
 
-%% Quality Control Button Group panel
+%% uipanel for Quality Control Buttons - uibutton group 
 %   -----------------------------------------------------------------------
 hbgQc = uibuttongroup(...
   'Parent', hMainFig, ...
@@ -579,9 +579,9 @@ hbgQc = uibuttongroup(...
   'FontSize', tsg.fontSize-1, 'Fontweight', 'bold', ...
   'tag', 'TAG_QC_DISPLAY_PANEL',...
   'HandleVisibility','on',...
-  'Visible', 'on',...
+  'Visible', 'off',...
   'BorderType', 'etchedin',...
-  'Position', [.0, .71, .15, .25]);
+  'Units', 'normalized', 'Position', [.0, .71, .15, .25]);
 
 % Initialize CallBack for button group properties
 % ----------------------------------------------- 
@@ -631,28 +631,24 @@ for i=1:numel(qc_list)
     uicontrol(...
       'Parent', hbgQc,...
       'Style', 'radiobutton',...
-      'Units', 'normalized', ...
-      'Fontsize', tsg.fontSize-1, ...
+      'Fontsize', tsg.fontSize-1, 'ForegroundColor', color,...
       'HorizontalAlignment', 'left', ...
       'HandleVisibility','on', ...
       'String', label,...
       'Tag', ['TAG_QC_RADIO_' key], ...
-      'ForegroundColor', color,...
-      'Position', [.01, .85-count*.12, .6, 0.09]);
+      'Units', 'normalized', 'Position', [.01, .85-count*.12, .6, 0.09]);
     
     % add text QC display statistic on hQcPanel
     % -----------------------------------------
     uicontrol(...
       'Parent', hbgQc,...
       'Style', 'text',...
-      'Units', 'normalized', ...
-      'Fontsize', tsg.fontSize-1, ...
+      'Fontsize', tsg.fontSize-1, 'ForegroundColor', color,...
       'HorizontalAlignment', 'right', ...
       'HandleVisibility','on', ...
       'String', 'N/A ',...
-      'ForegroundColor', color,...
       'Tag', ['TAG_QC_TEXT_' key],...
-      'Position', [.61, .85-count*.12, .37, 0.09]);
+      'Units', 'normalized', 'Position', [.61, .85-count*.12, .37, 0.09]);
     
     % increment count
     % ---------------
@@ -660,6 +656,43 @@ for i=1:numel(qc_list)
   end
 end
 
+%% uibutton group panel - Choose the parameter (SSPS - SSTP - SSJT)
+%   -----------------------------------------------------------------------
+hbgParameter = uibuttongroup(...
+  'Parent', hMainFig, ...
+  'Title', 'TSG Parameter', ...
+  'FontSize', tsg.fontSize-1, 'Fontweight', 'bold', ...
+  'tag', 'TAG_PARA_DISPLAY_PANEL',...
+  'HandleVisibility','on',...
+  'Visible', 'off',...
+  'BorderType', 'etchedin',...
+  'Units', 'normalized', 'Position', [.0, .81, .15, .15]);
+
+para    = [ 'SSPS'; 'SSJT'; 'SSTP' ];
+strPara = [ ['Salinity ' para(1,:) '   ']; ...
+            ['Temperature ' para(2,:)]; ...
+            ['Temperature ' para(3,:)] ];  
+for i = 1:3
+
+  % add button QC to hbgParameter uibuttongroup
+  % -------------------------------------------
+  uicontrol(...
+    'Parent', hbgParameter,...
+    'Style', 'radiobutton',...
+    'Fontsize', tsg.fontSize-1, 'ForegroundColor', color,...
+    'HorizontalAlignment', 'left', ...
+    'HandleVisibility','on', ...
+    'String', strPara(i, :),...
+    'Tag', ['TAG_PARA_RADIO_' para(i,:)], ...
+    'Units', 'normalized', 'Position', [.05, .8-(i-1)*.30, .90, 0.12]);
+
+end
+
+% Initialize CallBack for button group properties
+% ----------------------------------------------- 
+set(hbgParameter,'SelectionChangeFcn',@RadiobuttonParameter);
+
+
 %% uiButtonGroup set to choose the Correction method
 % -------------------------------------------------------------------------
 
@@ -944,9 +977,12 @@ if strcmp(tsg.preference.autoload, 'on')
   % -------------------------
   PARA = tsg.preference.parameter;
   
-  % Running average of TSG time series
-  % ----------------------------------
-  tsg_moveaverage( hMainFig, PARA );
+  % The smooth TSG time series (tsg_moveaverage) is
+  % no more computed : too long
+  % We now computed a smooth value only at the position of the sample
+  % in diffTsgSample
+  % -----------------------------------------------------------------
+  %tsg_moveaverage( hMainFig, PARA );
 
   % Merge sample from different origins : WS and EXT
   % ------------------------------------------------
@@ -986,9 +1022,9 @@ end
     % Activate or desactivate uipanels
     % --------------------------------
     set( hpCalCoef,            'Visible', 'off' );
-    set( hbgQc,                'Visible', 'on'  );
     set( hpDateLimit,          'Visible', 'off' );
     set( hpInterpPos,          'Visible', 'off' );
+%    set( hbgParameter,         'Visible', 'off');
     
     % Toggle button
     % -------------
@@ -1095,6 +1131,8 @@ end
         hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_');
         set(hdl_pushtool, 'Enable', 'on');
         
+        set( hbgParameter, 'Visible', 'on');
+        
         % enable Save menu
         % ----------------
         set(hSaveMenu, 'Enable', 'on');
@@ -1107,9 +1145,12 @@ end
         % ---------------------------
         set( hInfoFileText, 'String', strcat(tsg.file.name, tsg.file.ext));
         
-        % Running average of TSG time series
-        % ----------------------------------
-        tsg_moveaverage(hMainFig, PARA);
+        % The smooth TSG time series (tsg_moveaverage) is
+        % no more computed : too long
+        % We now computed a smooth value only at the position of the sample
+        % in diffTsgSample
+        % -----------------------------------------------------------------
+        %tsg_moveaverage(hMainFig, PARA);
         
         % The callback to detect the mouse motion can be set to on
         % --------------------------------------------------------
@@ -1161,9 +1202,9 @@ end
     % Activate or desactivate uipanels
     % --------------------------------
     set( hpCalCoef,            'Visible', 'off' );
-    set( hbgQc,                'Visible', 'off' );
     set( hpDateLimit,          'Visible', 'on' );
-    set( hpInterpPos,          'Visible',  'on' );
+    set( hpInterpPos,          'Visible', 'on' );
+    set( hbgParameter,         'Visible', 'off');
     
     % Toggle button
     % -------------
@@ -1176,6 +1217,17 @@ end
     set( hZoomToggletool,      'state', 'off', 'enable', 'on' );
     
     set( hHeaderPushtool,      'enable', 'off' );
+    
+    % Get application data TSG
+    % ------------------------
+    tsg = getappdata( hMainFig, 'tsg_data');
+    
+    % Get the information on time limits of the time series
+    % Write them in the uipanel
+    % -----------------------------------------------------
+    noNaN = tsg.DAYD(~isnan( tsg.DAYD ));
+    set( hetDateMin, 'String', datestr(noNaN(1), 31));
+    set( hetDateMax, 'String', datestr(noNaN(end), 31));
    
     % Draw the 3 plots of the interpolation figure 
     % --------------------------------------------
@@ -1194,9 +1246,9 @@ end
     % Activate or desactivate uipanels
     % --------------------------------
     set( hpCalCoef,            'Visible', 'off' );
-    set( hbgQc,                'Visible', 'on');
     set( hpDateLimit,          'Visible', 'off' );
     set( hpInterpPos,          'Visible', 'off' );
+    set( hbgParameter,         'Visible', 'on'  );
     
     % Enable Pushbuttons
     % ------------------
@@ -1310,8 +1362,8 @@ end
    
     % Activate or desactivate uipanels
     % --------------------------------
-    set( hpCalCoef, 'Visible', 'on' );
-    set( hbgQc,     'Visible', 'off');
+    set( hpCalCoef,         'Visible', 'on' );
+    set( hbgParameter,      'Visible', 'off');
     
     % Pushbutton
     % ----------
@@ -1341,8 +1393,6 @@ end
     set( hetCalCNDCOffset, 'String', num2str(tsg.CNDC_LINCOEF(2)));
     set( hetCalSSJTSlope,  'String', num2str(tsg.SSJT_LINCOEF(1)));
     set( hetCalSSJTOffset, 'String', num2str(tsg.SSJT_LINCOEF(2)));
-    set( hetCalSSTPSlope,  'String', '1');
-    set( hetCalSSTPOffset, 'String', '0');
     set( hetCalSSTPSlope,  'String', num2str(tsg.SSTP_LINCOEF(1)));
     set( hetCalSSTPOffset, 'String', num2str(tsg.SSTP_LINCOEF(2)));
 
@@ -1357,8 +1407,8 @@ end
   
     % Activate or desactivate uipanels
     % --------------------------------
-    set( hpCalCoef, 'Visible', 'off' );
-    set( hbgQc,     'Visible', 'on');
+    set( hpCalCoef,         'Visible', 'off' );
+    set( hbgParameter,      'Visible', 'on');
     
     % Enable Pushbuttons
     % ------------------
@@ -1592,6 +1642,11 @@ end
     
    PARA = tsg.preference.parameter;
  
+    % Make the QC code uipanel visible
+    % --------------------------------
+    set( hbgQc,                'Visible' ,'on');
+    set( hbgParameter,         'Visible', 'off');
+    
     % Desactivate toggletools.
     % ------------------------
     set( hZoomToggletool,       'state', 'off' );
@@ -1607,7 +1662,7 @@ end
     % Activate clic mouse menu on first axes (salinity) for next rbbox
     % ----------------------------------------------------------------
     set(hPlotAxes(1),'ButtonDownFcn', @QC_SelectCallback);
-    
+   
     % change cursor to crosshair aspect
     % ---------------------------------
     set( hMainFig, 'Pointer', 'crosshair');
@@ -1744,10 +1799,16 @@ end
     % ----------------------------------------------------------
     set(hPlotAxes(1),'ButtonDownFcn', []);
     
-    % Uipanel no more visible
+    % Uipanel visible or not
     % -----------------------
-    %set( hbgQc, 'Visible', 'off' );
-       
+    set( hbgQc,        'Visible', 'off' );
+    
+    % uibuttongroup uipanel used to choose a parameter is set to
+    % on only if the Correction screen (bottle toggletool) is off
+    % -----------------------------------------------------------
+    if  strcmp( get( hBottleToggletool, 'state'), 'off')
+      set( hbgParameter, 'Visible', 'on');
+    end
     % cursor back to normal
     % ---------------------
     set(hMainFig,'Pointer','arrow');
@@ -1860,6 +1921,73 @@ end
 
   end
 
+%% Radiobutton Parameter choice ..................... Parameter choice
+  % ---------------------------------------------------------------
+  % Callback to select CODE and COLOR QC from the RadioButton Group
+  % ---------------------------------------------------------------
+  function RadiobuttonParameter(source, eventdata)
+
+    % If the map is visible, hide it
+    % ------------------------------
+    set( hMapPanel, 'visible' ,'off' );
+    set( hMapToggletool, 'state', 'off');
+    
+    % Retrieve Default Quality Code and Color
+    % ---------------------------------------
+    tsg = getappdata( hMainFig, 'tsg_data');
+
+    % Retrieve the key from the active RadioButton
+    % --------------------------------------------
+    rbTag_Old = get(eventdata.OldValue,'Tag');
+    rbTag     = get(eventdata.NewValue,'Tag');
+    PARA = strrep(rbTag, 'TAG_PARA_RADIO_', '');
+
+    % Test if PARA exists
+    % -------------------
+    ind = find( isnan(tsg.(PARA)) == 0 );
+    if ~isempty( tsg.(PARA) ) & ~isempty (ind )
+
+      % store his handle to uibuttongroup userdata
+      % ------------------------------------------
+      set(hbgParameter,'Userdata', eventdata.NewValue);
+
+      tsg.preference.parameter = PARA;
+
+      setappdata( hMainFig, 'tsg_data', tsg );
+
+      % Get sample data
+      % ---------------
+      tsg_mergesample( hMainFig, PARA );
+
+      % The smooth TSG time series (tsg_moveaverage) is
+      % no more computed : too long
+      % We now computed a smooth value only at the position of the sample
+      % in diffTsgSample
+      % -----------------------------------------------------------------
+      %tsg_moveaverage(hMainFig, PARA);
+
+      % Draw the 3 plots of the validation figure
+      % -----------------------------------------
+      resetAxes( hMainFig, hPlotAxes )
+      plot_Validation( hMainFig, hPlotAxes, 1, PARA );
+      plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
+      plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
+
+    else
+      msgbox( ['No ' PARA ' data in the file'], 'Parameter choice', 'warn', 'modal');
+
+      % Set the old radio-button active
+      % -------------------------------
+      hbgChildren  = get(hbgParameter,'Children');        % Get the handles of the rbg
+      hbgTagCell   = get(hbgChildren, 'tag');             % get the TAG of the rbg
+      ind          = strcmp(rbTag_Old, hbgTagCell);       % Compare the TAG
+      hRadioButton = hbgChildren( ind == 1 );             % Get the handle of the button
+      set(hbgParameter, 'SelectedObject', hRadioButton);  % Make this button active
+
+    end
+
+  end
+
 %% preQcPanCallback .................................Quality Control Module
   % ---------------------------------------------------------------
   % Callback function ... to be completed
@@ -2040,10 +2168,11 @@ end
     set( hInterpToggletool,     'enable', 'off' );
     set( hTimelimitToggletool,  'enable', 'on' );
 
-    % Activate uipanels
-    % -----------------
-    set( hpDateLimit,  'Visible', 'on' );
-    set( hbgCorMethod, 'Visible', 'on' );
+    % Activate ord desactivate uipanels
+    % ---------------------------------
+    set( hpDateLimit,           'Visible', 'on' );
+    set( hbgCorMethod,          'Visible', 'on' );
+    set( hbgParameter,          'Visible', 'off');
 
     % Test if tsg and sample data have been loaded
     % --------------------------------------------
@@ -2096,10 +2225,11 @@ end
     set( hInterpToggletool,    'enable', 'on' );
     set( hTimelimitToggletool, 'enable', 'off' );
     
-    % Desactivate some toolbar buttons
+    % Activate or Desactivate uipanel
     % --------------------------------
-    set( hpDateLimit,  'Visible', 'off' );
-    set( hbgCorMethod, 'Visible', 'off' );
+    set( hpDateLimit,          'Visible', 'off' );
+    set( hbgCorMethod,         'Visible', 'off' );
+    set( hbgParameter,         'Visible', 'on');
 
     % Desactivate Click Mouse on figure
     % ---------------------------------
-- 
GitLab