Skip to content
Snippets Groups Projects
plot_Correction.m 4.04 KiB
Newer Older
function plot_Correction( hMainFig, hPlotAxes, PARA )
%
% Input
% hMainFig ........ Handle to the main GUI : TSGQC
% hPlotAxes ....... Handle des axes
% PARA ............ Cell array
%                   PARA{1} contains the characters (SSP, SSJT, SSTP)
%                   PARA{2} contains either the cahracters (SSPS, SSJT, SSTP)
%                           or (SSPS_CAL, SSJT_CAL, SSTP_CAL)

% Reinitialise plot 1 and 3
% -------------------------
erase_Line( hPlotAxes, 1 );
erase_Line( hPlotAxes, 2 );
erase_Line( hPlotAxes, 3 );

% Get tsg application data
% ------------------------
tsg    = getappdata( hMainFig, 'tsg_data');
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
SAMPLE = tsg.plot.sample;
% Get the code for VALUE_CHANGED
% ------------------------------
VALUE_CHANGED = tsg.qc.hash.VALUE_CHANGED.code;

% **************************** AXE 1 ***********************************
% Plot the samples
% ----------------
if ~isempty( tsg.([SAMPLE '_EXT']) )
  
  % Plot bucket samples
  % -------------------
  indWS = strmatch( 'WS', tsg.([SAMPLE '_EXT_TYPE']), 'exact');
  if ~isempty(indWS)
    plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_EXT(indWS),...
              tsg.EXT_DIF(indWS), tsg.([SAMPLE '_EXT_QC'])(indWS),...
              [PARA{1} '_WS'],'','none','square',5);
  
  % Plot other (external) samples
  % -----------------------------
  indEXT = setxor(ind, indWS);
  if ~isempty(indEXT)
    plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_EXT(indEXT),...
              tsg.EXT_DIF(indEXT), tsg.([SAMPLE '_EXT_QC'])(indEXT),...
              [PARA{1} '_EXT'],'','none','o',5);
% Select the records CORRECTED 
% Records corrected have an error value
% -------------------------------------------
iERR = find( isnan(tsg.([PARA{1} '_ADJUSTED_ERROR'])) == 0);

% Plot the difference tsg.SSPS_ADJUSTED-tsg.SSPS on axe 1
% but only for records that were corrected using Water Sample
% -----------------------------------------------------------
if iERR ~= 0
  plot_Tsg( hMainFig, hPlotAxes, 1,...
            tsg.DAYD(iERR),...
            tsg.([PARA{1} '_ADJUSTED'])(iERR)-tsg.(PARA{2})(iERR),...
            [], [PARA{1} '_ADJUSTED'],'b','none','.',1);
% **************************** AXE 2 ***********************************
% Plot SAMPLE and SSPS (SSJT, SSTP) with code color, on axe 2
% -----------------------------------------------------------
if ~isempty( tsg.([SAMPLE '_EXT']) )
  indWS = strmatch( 'WS', tsg.([SAMPLE '_EXT_TYPE']), 'exact');
  if ~isempty(indWS)
    plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD_EXT(indWS),...
              tsg.([SAMPLE '_EXT'])(indWS), tsg.([SAMPLE '_EXT_QC'])(indWS),...
              [PARA{1} '_WS'],'','none','square',5);
  indEXT = setxor(ind, indWS);
  if ~isempty(indEXT)
    plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD_EXT(indEXT),...
              tsg.([SAMPLE '_EXT'])(indEXT), tsg.([SAMPLE '_EXT_QC'])(indEXT),...
              [PARA{1} '_EXT'],'','none','o',5);
plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.(PARA{2}), tsg.([PARA{1} '_QC']),...
          PARA{2},'','none','*',2);
        

% **************************** AXE 3 ***********************************

% Plot SSPS, with no code, on axe3
% --------------------------------
plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.([PARA{1} '_ADJUSTED']), [],...
          [PARA{1} '_ADJUSTED'],'r','none','*',2);
plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.(PARA{2}),...
          [],PARA{2},'k','none','*',2);

% Plot TSG_ADJUSTED + ERROR on axe 3
% -----------------------------------
  plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD(iERR),...
          tsg.([PARA{1} '_ADJUSTED'])(iERR) + tsg.([PARA{1} '_ADJUSTED_ERROR'])(iERR),...
          [], [PARA{1} '_ADJUSTED'],'g','none','*',2);
  plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD(iERR),...
          tsg.([PARA{1} '_ADJUSTED'])(iERR) - tsg.([PARA{1} '_ADJUSTED_ERROR'])(iERR),...
          [], [PARA{1} '_ADJUSTED'],'g','none','*',2);