Skip to content
Snippets Groups Projects
plot_Correction.m 3.55 KiB
Newer Older
function plot_Correction( hMainFig, hPlotAxes, PARA )


% 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');
% Get the code for VALUE_CHANGED
% ------------------------------
VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code');

% **************************** AXE 1 ***********************************
% Plot the samples
% ----------------
if ~isempty( tsg.([PARA '_SPL']) )
  
  % Plot bucket samples
  % -------------------
  iWS = find( tsg.([PARA '_SPL_TYPE']) == 1 );
  if ~isempty(iWS)
    plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(iWS),...
              tsg.([PARA '_SPL_DIF'])(iWS), tsg.([PARA '_SPL_QC'])(iWS),...
              [PARA '_SPL_1'],'','none','square',5);
  
  % Plot other (external) samples
  % -----------------------------
  iEXT = find( tsg.([PARA '_SPL_TYPE']) > 1 );
  if ~isempty(iEXT)
    plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(iEXT),...
              tsg.([PARA '_SPL_DIF'])(iEXT), tsg.([PARA '_SPL_QC'])(iEXT),...
              [PARA '_SPL_2'],'','none','o',5);
% Select the records CORRECTED 
% Records corrected have an error value
% -------------------------------------------
iERR = find( isnan(tsg.([PARA '_ADJUSTED_ERROR'])) == 0);

% Plot the difference tsg.SSPS_ADJUSTED-tsg.SSPS on axe 1
% but only for records that were corrected using Water Sample
% and but not corrected with the calibration coefficients.
% -----------------------------------------------------------
if iERR ~= 0
  plot_Tsg( hMainFig, hPlotAxes, 1,...
            tsg.DAYD(iERR),...
            tsg.([PARA '_ADJUSTED'])(iERR)-tsg.(PARA)(iERR),...
            [], [PARA '_ADJUSTED'],'b','none','.',1);
% **************************** AXE 2 ***********************************
% Plot SSPS and SAMPLE, with code color, on axe 2
% ------------------------------------------------
plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.(PARA), tsg.([PARA '_QC']),...
          PARA,'','none','*',2);
if ~isempty( tsg.([PARA '_SPL']) )
  ind = find( tsg.([PARA '_SPL_TYPE']) == 1 );
  if ~isempty(ind)
    plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD_SPL(ind),...
              tsg.([PARA '_SPL'])(ind), tsg.([PARA '_SPL_QC'])(ind),...
              [PARA '_SPL_1'],'','none','square',5);
  ind = find( tsg.([PARA '_SPL_TYPE']) > 1 );
  if ~isempty(ind)
    plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD_SPL(ind),...
              tsg.([PARA '_SPL'])(ind), tsg.([PARA '_SPL_QC'])(ind),...
              [PARA '_SPL_2'],'','none','o',5);
% **************************** AXE 3 ***********************************

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

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