diff --git a/tsg_data/Touc0702.nc b/tsg_data/Touc0702.nc index 161cae8d1fcfb87da51e0eebe00b70d25b15b537..8b5e83a8445daf2e006efa62427caaa23ee65661 100644 Binary files a/tsg_data/Touc0702.nc and b/tsg_data/Touc0702.nc differ diff --git a/tsg_util/corTsgLinear.m b/tsg_util/corTsgLinear.m index ea3b29614f1c24e762780c43a68d8c5716aeb504..ced166f2bcf4a8abca15ed6b8f4eed15bde07c9d 100644 --- a/tsg_util/corTsgLinear.m +++ b/tsg_util/corTsgLinear.m @@ -15,13 +15,7 @@ function [error] = corTsgLinear(hMainFig, PARA, dateMin, dateMax) % Get application data % -------------------- tsg = getappdata( hMainFig, 'tsg_data'); - -% No sample for 'SSJT' only for 'SSPS' and 'SSPT' -% ---------------------------------------------- -SAMPLE = PARA; -if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; -end +SAMPLE = tsg.preference.sample; % ------------------------------------------------------------------------- % Get from the checkbox the QC code on which the correction will be applied diff --git a/tsg_util/corTsgMedian.m b/tsg_util/corTsgMedian.m index df23a498e341c6def0e71fc5dd68193d60fc86c3..15a688095465e43ac533d855301fc357f245fccb 100644 --- a/tsg_util/corTsgMedian.m +++ b/tsg_util/corTsgMedian.m @@ -18,13 +18,7 @@ function [error] = corTsgMedian(hMainFig, PARA, dateMin, dateMax) % Get application data % -------------------- tsg = getappdata( hMainFig, 'tsg_data'); - -% No sample for 'SSJT' only for 'SSPS' and 'SSPT' -% ---------------------------------------------- -SAMPLE = PARA; -if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; -end +SAMPLE = tsg.preference.sample; % Shorten the variable name % ------------------------- @@ -172,6 +166,18 @@ if dateMax > dateMin cor.ERROR = [cor.ERROR cor.ERROR(end)]; cor.NVALUE = [cor.NVALUE cor.NVALUE(end)]; end + + % Test if the date are strictly increasing otherwise interp1 + % cannot be used + % ---------------------------------------------------------- + if ~isempty( find(diff(cor.DAYD) == 0) ) + msgbox( {'Function corTsgMedian'; ' '; ... + 'At least 2 samples have the same date';... + 'The soft cannot make the interpolation'},... + 'Correction Method', 'warn'); + error = -1; + return + end % The correction is applied to the TSG between dateMin and dateMax using % a linear interpolation only on measurements with keptCode @@ -205,6 +211,10 @@ else % DateMax <= DateMin % ------------------ + msgbox( {'Function corTsgMedian'; ' '; ... + 'Date limits are not correct' },... + 'Correction Method', 'warn', 'modal'); + error = -1; end diff --git a/tsg_util/initParameterChoice.m b/tsg_util/initParameterChoice.m index 01c6345cf882c00b400417c4f0711cbf2dba0411..60178541eadeba59d5d2645d3f09e91fe5a8d35d 100644 --- a/tsg_util/initParameterChoice.m +++ b/tsg_util/initParameterChoice.m @@ -72,6 +72,15 @@ else tsg.preference.parameter{3} = 'NONE'; end +% Initialise tsg.preference.sample +% We need this variable because the validation of SSJT can only be +% made with SSTP sample. +% ---------------------------------------------------------------- +tsg.preference.sample = pop1{1}; +if strcmp( tsg.preference.sample, 'SSJT' ) + tsg.preference.sample = 'SSTP'; +end + % Save the tsg structure % --------------------- setappdata( hMainFig, 'tsg_data', tsg); diff --git a/tsg_util/plot_Correction.m b/tsg_util/plot_Correction.m index 6e4f0f5157c44225ce82e4106f226bd81de4b9ea..837f75842afb5387e95203bc4b948f563e7844ca 100644 --- a/tsg_util/plot_Correction.m +++ b/tsg_util/plot_Correction.m @@ -1,12 +1,5 @@ function plot_Correction( hMainFig, hPlotAxes, PARA ) -% IF PARA = 'SSJT' use 'SSTP' to get the samples -% ---------------------------------------------- -SAMPLE = PARA; -if strcmp( SAMPLE, 'SSJT') - SAMPLE = 'SSTP'; -end - % Reinitialise plot 1 and 3 % ------------------------- erase_Line( hPlotAxes, 1 ); @@ -15,7 +8,8 @@ erase_Line( hPlotAxes, 3 ); % Get tsg application data % ------------------------ -tsg = getappdata( hMainFig, 'tsg_data'); +tsg = getappdata( hMainFig, 'tsg_data'); +SAMPLE = tsg.preference.sample; % Get the code for VALUE_CHANGED % ------------------------------ diff --git a/tsg_util/plot_Validation.m b/tsg_util/plot_Validation.m index 4427e213be890777ca5ecc8136935693826af112..0c5380f460e9334ebc7ce031984f0a45d93c2193 100644 --- a/tsg_util/plot_Validation.m +++ b/tsg_util/plot_Validation.m @@ -2,7 +2,8 @@ function plot_Validation( hMainFig, hPlotAxes, nPlot, PARA ) % Get tsg application data % ------------------------ -tsg = getappdata( hMainFig, 'tsg_data'); +tsg = getappdata( hMainFig, 'tsg_data'); +SAMPLE = tsg.preference.sample; switch nPlot @@ -15,25 +16,18 @@ switch nPlot plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD, tsg.(PARA), tsg.([PARA '_QC']),... PARA,'','none','*',2); end - - % Plot PARA External data (WS, CTD, etc) - % there are only _EXT data for SSPS and SSTP variable - % --------------------------------------------------- - if strcmp( PARA, 'SSJT' ) - PARA = 'SSTP'; - end - if ~isempty( tsg.([PARA '_EXT']) ) + if ~isempty( tsg.([SAMPLE '_EXT']) ) % Plot circle for WS data % ----------------------- - ind = 1: length( tsg.([PARA '_EXT_TYPE'])); - indWS = strmatch( 'WS', tsg.([PARA '_EXT_TYPE']), 'exact'); + ind = 1: length( tsg.([SAMPLE '_EXT_TYPE'])); + indWS = strmatch( 'WS', tsg.([SAMPLE '_EXT_TYPE']), 'exact'); if ~isempty(ind) plot_Tsg( hMainFig, hPlotAxes, 1,... - tsg.DAYD_EXT(indWS), tsg.([PARA '_EXT'])(indWS),... - tsg.([PARA '_EXT_QC'])(indWS), ... - [PARA '_EXT_1'],'','none','square',5); + tsg.DAYD_EXT(indWS), tsg.([SAMPLE '_EXT'])(indWS),... + tsg.([SAMPLE '_EXT_QC'])(indWS), ... + [SAMPLE '_EXT_1'],'','none','square',5); end % Plot squares for CTD, ARGO, etc. data @@ -41,9 +35,9 @@ switch nPlot indEXT = setxor(ind, indWS); if ~isempty(indEXT) plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_EXT(indEXT),... - tsg.([PARA '_EXT'])(indEXT),... - tsg.([PARA '_EXT_QC'])(indEXT),... - [PARA '_EXT_2'],'','none','o',5); + tsg.([SAMPLE '_EXT'])(indEXT),... + tsg.([SAMPLE '_EXT_QC'])(indEXT),... + [SAMPLE '_EXT_2'],'','none','o',5); end end diff --git a/tsgqc.m b/tsgqc.m index 8f4ac2c282595397d4732c1a8172644df1a6f16b..a23629c17c02c32f6da11f70f4bb29526f247ac2 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -1313,37 +1313,40 @@ end end %if errTsg > 0 - % Draw the 3 plots of the validation figure - % The plots need to be re-initialize because of a bug with - % the zoom function. When you open a new TSG file and you - % have used the zoom funtion with the preceding file. - % The zoom function keep the X and Y limits of the preceding file - % --------------------------------------------------------------- - delete( hPlotAxes(1) ); - delete( hPlotAxes(2) ); - delete( hPlotAxes(3) ); - - hPlotAxes(1) = axes( 'Parent', hPlotsPanel, 'Visible', 'off', ... - 'box', 'on', 'Units', 'normalized','Tag', 'TAG_AXES_1', ... - 'HandleVisibility','on', 'Position',[.05, .64, .93, .35]); - hPlotAxes(2) = axes( 'Parent', hPlotsPanel, 'Visible', 'off',... - 'box', 'on', 'Units', 'normalized', 'Tag', 'TAG_AXES_2', ... - 'HandleVisibility','on', 'Position',[.05, .33, .93, .27]); - hPlotAxes(3) = axes('Parent', hPlotsPanel, 'Visible', 'off',... - 'box', 'on', 'Units', 'normalized', 'Tag', 'TAG_AXES_3', ... - 'HandleVisibility','on', 'Position',[.05, .02, .93, .27]); - - resetAxes( hMainFig, hPlotAxes ) - - plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter{1} ); - plot_Validation( hMainFig, hPlotAxes, 2, tsg.preference.parameter{2} ); - plot_Validation( hMainFig, hPlotAxes, 3, tsg.preference.parameter{3} ); - - % Pointer reset to arrow - % ---------------------- - set( hMainFig, 'Pointer', 'arrow' ); + if errTsg == 1 || errSpl == 1 + + % Draw the 3 plots of the validation figure + % The plots need to be re-initialize because of a bug with + % the zoom function. When you open a new TSG file and you + % have used the zoom funtion with the preceding file. + % The zoom function keep the X and Y limits of the preceding file + % --------------------------------------------------------------- + delete( hPlotAxes(1) ); + delete( hPlotAxes(2) ); + delete( hPlotAxes(3) ); + + hPlotAxes(1) = axes( 'Parent', hPlotsPanel, 'Visible', 'off', ... + 'box', 'on', 'Units', 'normalized','Tag', 'TAG_AXES_1', ... + 'HandleVisibility','on', 'Position',[.05, .64, .93, .35]); + hPlotAxes(2) = axes( 'Parent', hPlotsPanel, 'Visible', 'off',... + 'box', 'on', 'Units', 'normalized', 'Tag', 'TAG_AXES_2', ... + 'HandleVisibility','on', 'Position',[.05, .33, .93, .27]); + hPlotAxes(3) = axes('Parent', hPlotsPanel, 'Visible', 'off',... + 'box', 'on', 'Units', 'normalized', 'Tag', 'TAG_AXES_3', ... + 'HandleVisibility','on', 'Position',[.05, .02, .93, .27]); + + resetAxes( hMainFig, hPlotAxes ) + + plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter{1} ); + plot_Validation( hMainFig, hPlotAxes, 2, tsg.preference.parameter{2} ); + plot_Validation( hMainFig, hPlotAxes, 3, tsg.preference.parameter{3} ); + end end % if ~isequal(fileName, 0) + + % Pointer reset to arrow + % ---------------------- + set( hMainFig, 'Pointer', 'arrow' ); end @@ -1827,14 +1830,8 @@ end % ------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); - PARA = tsg.preference.parameter{1}; - - % No sample for 'SSJT' only for 'SSPS' and 'SSPT' - % ---------------------------------------------- - SAMPLE = PARA; - if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; - end + PARA = tsg.preference.parameter{1}; + SAMPLE = tsg.preference.sample; % Activate right clic context menu on first axes (salinity) % --------------------------------------------------------- @@ -2013,13 +2010,7 @@ end % Get the parameter (SSPS, SSJT or SSTP) % -------------------------------------- PARA = tsg.preference.parameter{1}; - - % No sample for 'SSJT' only for 'SSPS' and 'SSPT' - % ---------------------------------------------- - SAMPLE = PARA; - if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; - end + SAMPLE = tsg.preference.sample; % get key and some values in hashtable % ------------------------------------ @@ -2309,8 +2300,9 @@ end % Get the parameter we are working on (SSPS, SSJT, SSTP) % ------------------------------------------------------ - PARA = tsg.preference.parameter{1}; - + PARA = tsg.preference.parameter{1}; + SAMPLE = tsg.preference.sample; + % Switch somme buttons % -------------------- set( hQCToggletool, 'state', 'off' ); @@ -2329,13 +2321,6 @@ end set( hCorPanel, 'Visible', 'on' ); set( hbgParameter, 'Visible', 'off'); set( hbgQc, 'Visible', 'off'); - - % No sample for 'SSJT' only for 'SSPS' and 'SSPT' - % ---------------------------------------------- - SAMPLE = PARA; - if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; - end if ~isempty( tsg.([SAMPLE '_EXT']) ) @@ -2467,15 +2452,9 @@ end % Get the parameter (SSPS, SSJT, or SSTP) % --------------------------------------- - tsg = getappdata(hMainFig, 'tsg_data'); - PARA = tsg.preference.parameter{1}; - - % No sample for 'SSJT' only for 'SSPS' and 'SSPT' - % ---------------------------------------------- - SAMPLE = PARA; - if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; - end + tsg = getappdata(hMainFig, 'tsg_data'); + PARA = tsg.preference.parameter{1}; + SAMPLE = tsg.preference.sample; if ~isempty( tsg.([SAMPLE '_EXT']) ) @@ -2522,15 +2501,9 @@ end % Get the parameter (SSPS, SSJT, or SSTP) % --------------------------------------- - tsg = getappdata(hMainFig, 'tsg_data'); - PARA = tsg.preference.parameter{1}; - - % No sample for 'SSJT' only for 'SSPS' and 'SSPT' - % ---------------------------------------------- - SAMPLE = PARA; - if strcmp( SAMPLE, 'SSJT' ) - SAMPLE = 'SSTP'; - end + tsg = getappdata(hMainFig, 'tsg_data'); + PARA = tsg.preference.parameter{1}; + SAMPLE = tsg.preference.sample; if ~isempty( tsg.([SAMPLE '_EXT']) ) @@ -2550,9 +2523,9 @@ end % ------------------ plot_Correction( hMainFig, hPlotAxes, PARA ); - case -1 - msgbox( 'Date limits are not correct',... - 'Correction module', 'warn', 'modal'); + otherwise + + % Nothing is done - Error msg within the corTsgMedian function end end @@ -2576,6 +2549,12 @@ end % Get the default parameter % ------------------------- tsg.preference.parameter{nplot} = selected_string; + if nplot == 1 + tsg.preference.sample = selected_string; + if strcmp( tsg.preference.sample, 'SSJT' ) + tsg.preference.sample = 'SSTP'; + end + end % Save application data % -------------------- @@ -2601,7 +2580,7 @@ end % ---------------------------------------------- if plotClim set( hClimToggletool, 'state', 'on' ); - plot_ClimatologyB(hMainFig, hPlotAxes); + plot_Climatology(hMainFig, hPlotAxes); end end @@ -2859,7 +2838,6 @@ end end - %% ReportMenuCallback % ------------------------------------------------------------------- % Callback function run when the Report tool bar item is selected