diff --git a/@tsg_nc/tsg_platform_info.mat b/@tsg_nc/tsg_platform_info.mat index 5940258864c04157f815330703822359841df452..bb2adc41d88dc816da66bcb9601825f076a7d246 100644 Binary files a/@tsg_nc/tsg_platform_info.mat and b/@tsg_nc/tsg_platform_info.mat differ diff --git a/tsg_io/readTsgDataTxt.m b/tsg_io/readTsgDataTxt.m index 14b19faddb6cd6e5cdcc747138f5c9a5d59d476a..b988ade0469f2a8bc2d6990ba883ee2cd39b2523 100644 --- a/tsg_io/readTsgDataTxt.m +++ b/tsg_io/readTsgDataTxt.m @@ -62,6 +62,8 @@ tsg.SSPS_QC = tsgData(:,11); tsg.SSPS_ADJUSTED = tsgData(:,12); tsg.SSPS_ADJUSTED_ERROR = tsgData(:,13); +tsg.SSJT_QC = tsg.SSPS_QC; + % populate tsg.file structure % --------------------------- [tsg.file.pathstr, tsg.file.name, tsg.file.ext, tsg.file.versn] = ... diff --git a/tsg_util/corTsgLinear.m b/tsg_util/corTsgLinear.m index f4667961d3613b5c342533f908c7ae8fdba65fa3..bfe88cde6cf5bee806b4af129341d2e286e5de55 100644 --- a/tsg_util/corTsgLinear.m +++ b/tsg_util/corTsgLinear.m @@ -1,9 +1,10 @@ -function [error] = corTsgLinear(hMainFig, dateMin, dateMax) +function [error] = corTsgLinear(hMainFig, PARA, dateMin, dateMax) % Correct the TSG salinity time series with the Water sample. % Use a linear fit to the water sample/tsg difference % % Input % hMainFig ..... Handle to the main GUI +% PARA ......... Parameter % dateMin ...... the correction is applied between dateMin and date Max % dateMax ...... the correction is applied between dateMin and date Max % @@ -18,15 +19,15 @@ tsg = getappdata( hMainFig, 'tsg_data'); % Get PROBABLY_GOOD, PROBABLY_BAD and VALUE_CHANGED codes % ------------------------------------------------------- PROBABLY_GOOD = get(tsg.qc.hash, 'PROBABLY_GOOD', 'code'); -PROBABLY_BAD = get(tsg.qc.hash, 'PROBABLY_BAD', 'code'); +PROBABLY_BAD = get(tsg.qc.hash, 'PROBABLY_BAD', 'code'); VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code'); if dateMax > dateMin % intialisation % ------------- - if isempty( tsg.SSPS_ADJUSTED ) - msgbox( 'Variable SSPS_ADJUSTED should be initialise in updateTsgStruct',... + if isempty( tsg.([PARA '_ADJUSTED']) ) + msgbox( ['Variable ' PARA '_ADJUSTED should be initialise in updateTsgStruct'],... 'Function ''corTsgLinear''',... 'warn', 'modal'); end @@ -34,23 +35,23 @@ if dateMax > dateMin % Find samples within TIME_WINDOWS with Good and probably Good QC % --------------------------------------------------------------- ind = find( tsg.DAYD_SPL >= dateMin & tsg.DAYD_SPL <= dateMax &... - tsg.SSPS_SPL_QC <= PROBABLY_GOOD); + tsg.([PARA '_SPL_QC']) <= PROBABLY_GOOD); if ~isempty(ind) % detect NaN in sample.SSPS_DIF due to bad QC code for tsg.SSPS % ------------------------------------------------------------- - ind2 = find(~isnan(tsg.SSPS_SPL_DIF(ind))); + ind2 = find(~isnan(tsg.([PARA '_SPL_DIF'])(ind))); % Compute linear fit of the TSG/SAMPLE difference % ----------------------------------------------- if ~isempty(ind2) - if ~isempty(tsg.SSPS_SPL_DIF(ind(ind2))) + if ~isempty(tsg.([PARA '_SPL_DIF'])(ind(ind2))) % Linear fit applied to the difference tsg-sample % ----------------------------------------------- X = tsg.DAYD_SPL(ind(ind2)); - Y = tsg.SSPS_SPL_DIF(ind(ind2)); + Y = tsg.([PARA '_SPL_DIF'])(ind(ind2)); [p, S, mu] = polyfit( X, Y, 1); @@ -59,22 +60,23 @@ if dateMax > dateMin % PROBABLY_GOOD QC % ---------------------------------------------------------------------- dtTsg = find( tsg.DAYD >= dateMin & tsg.DAYD <= dateMax &... - tsg.SSPS_QC <= PROBABLY_GOOD); + tsg.([PARA '_QC']) <= PROBABLY_GOOD); - [tsg.SSPS_ADJUSTED(dtTsg), tsg.SSPS_ADJUSTED_ERROR(dtTsg)] =... - polyval( p, tsg.DAYD(dtTsg), S, mu); - tsg.SSPS_ADJUSTED(dtTsg) = tsg.SSPS(dtTsg) + tsg.SSPS_ADJUSTED(dtTsg); + [tsg.([PARA '_ADJUSTED'])(dtTsg), tsg.([PARA '_ADJUSTED_ERROR'])(dtTsg)] =... + polyval( p, tsg.DAYD(dtTsg), S, mu); + tsg.([PARA '_ADJUSTED'])(dtTsg) = ... + tsg.(PARA)(dtTsg) + tsg.([PARA '_ADJUSTED'])(dtTsg); % VALUE_CHANGED code % ------------------ - tsg.SSPS_ADJUSTED_QC(dtTsg) = VALUE_CHANGED; + tsg.([PARA '_ADJUSTED_QC'])(dtTsg) = VALUE_CHANGED; end end end % Update the QC sample Code % ------------------------- - updateSampleQC( hMainFig ); + updateSampleQC( hMainFig, PARA ); % Update tsg application data % --------------------------- diff --git a/tsg_util/corTsgMedian.m b/tsg_util/corTsgMedian.m index 316feb0a36e326ce1a2efdde064aa1e511ebebb7..42e6c0d3c31e5f15245020acfa8154815b9fd3a6 100644 --- a/tsg_util/corTsgMedian.m +++ b/tsg_util/corTsgMedian.m @@ -1,4 +1,4 @@ -function [error] = corTsgMedian(hMainFig, dateMin, dateMax) +function [error] = corTsgMedian(hMainFig, PARA, dateMin, dateMax) % % Correct the TSG salinity time series with the Water sample. % Use the median value of TIME_WINDOWS water sample to compute the @@ -6,6 +6,7 @@ function [error] = corTsgMedian(hMainFig, dateMin, dateMax) % % Input % hMainFig ..... Handle to the main GUI +% PARA ......... Parameter (SSPS, SSJT, SSTP) % dateMin ...... the correction is applied between dateMin and date Max % dateMax ...... the correction is applied between dateMin and date Max % @@ -23,6 +24,10 @@ function [error] = corTsgMedian(hMainFig, dateMin, dateMax) % -------------------- tsg = getappdata( hMainFig, 'tsg_data'); +% Get the parameter +% ----------------- +PARA = tsg.preference.parameter; + % Shorten the variable name % ------------------------- TIME_WINDOWS = tsg.cst.COR_TIME_WINDOWS; @@ -42,8 +47,8 @@ if dateMax > dateMin % intialisation % ------------- - if isempty( tsg.SSPS_ADJUSTED ) - msgbox( 'Variable SSPS_ADJUSTED should be initialise in updateTsgStruct',... + if isempty( tsg.([PARA '_ADJUSTED']) ) + msgbox( ['Variable ' PARA '_ADJUSTED should be initialise in updateTsgStruct'],... 'Function ''corTsgMedian''',... 'warn', 'modal'); end @@ -60,20 +65,20 @@ if dateMax > dateMin % --------------------------------------------------------------- ind = find( tsg.DAYD_SPL >= (tsg.DAYD_SPL(indSample(i)) - TIME_WINDOWS/2) &... tsg.DAYD_SPL <= (tsg.DAYD_SPL(indSample(i)) + TIME_WINDOWS/2) &... - tsg.SSPS_SPL_QC <= PROBABLY_GOOD); + tsg.([PARA '_SPL_QC']) <= PROBABLY_GOOD); if ~isempty(ind) % detect NaN in sample.SSPS_DIF due to bad QC code in tsg.SSPS % ------------------------------------------------------------ - ind2 = find(~isnan(tsg.SSPS_SPL_DIF(ind))); + ind2 = find(~isnan(tsg.([PARA '_SPL_DIF'])(ind))); % Compute the median difference and error within TIME_WINDOWS % ----------------------------------------------------------- if ~isempty(ind2) - if ~isempty(tsg.SSPS_SPL_DIF(ind(ind2))) + if ~isempty(tsg.([PARA '_SPL_DIF'])(ind(ind2))) - A = tsg.SSPS_SPL_DIF(ind(ind2)); + A = tsg.([PARA '_SPL_DIF'])(ind(ind2)); meanA = mean(A); stdA = std(A); @@ -81,7 +86,7 @@ if dateMax > dateMin % ------------------------------------------ ind3 = find( A >= meanA-3*stdA & A <= meanA+3*stdA); - B = tsg.SSPS_SPL_DIF(ind(ind2(ind3))); + B = tsg.([PARA '_SPL_DIF'])(ind(ind2(ind3))); if ~isempty( B ) indCor = indCor + 1; cor.DAYD(indCor) = tsg.DAYD_SPL((indSample(i))); @@ -95,7 +100,7 @@ if dateMax > dateMin % ------------------------------------------------------ ind4 = find( A < meanA-3*stdA | A > meanA+3*stdA); if ~isempty( ind4 ) - tsg.SSPS_SPL_QC(ind(ind2(ind4))) = PROBABLY_BAD; + tsg.([PARA '_SPL_QC'])(ind(ind2(ind4))) = PROBABLY_BAD; end end end @@ -123,7 +128,7 @@ if dateMax > dateMin % % Find the tsg date in the interval dateMin-dateMax % ------------------------------------------------- - dtTsg = find(tsg.DAYD >= dateMin & tsg.DAYD <= dateMax); + dtTsg = find(tsg.DAYD >= dateMin & tsg.DAYD <= dateMax); if cor.DAYD(1) ~= dateMin cor.DAYD = [tsg.DAYD(dtTsg(1)) cor.DAYD]; @@ -143,22 +148,22 @@ if dateMax > dateMin % PROBABLY_GOOD QC % ---------------------------------------------------------------------- dtTsg = find( tsg.DAYD >= dateMin & tsg.DAYD <= dateMax &... - tsg.SSPS_QC <= PROBABLY_GOOD); + tsg.([PARA '_QC']) <= PROBABLY_GOOD); - tsg.SSPS_ADJUSTED(dtTsg) = tsg.SSPS(dtTsg) + ... + tsg.([PARA '_ADJUSTED'])(dtTsg) = tsg.(PARA)(dtTsg) + ... interp1(cor.DAYD, cor.DIFF, tsg.DAYD(dtTsg)); - tsg.SSPS_ADJUSTED_ERROR(dtTsg) = ... + tsg.([PARA '_ADJUSTED_ERROR'])(dtTsg) = ... interp1(cor.DAYD, cor.ERROR, tsg.DAYD(dtTsg)); % VALUE_CHANGED code % ------------------ - tsg.SSPS_ADJUSTED_QC(dtTsg) = VALUE_CHANGED; + tsg.([PARA '_ADJUSTED_QC'])(dtTsg) = VALUE_CHANGED; end % Update the QC sample Code % ------------------------- - updateSampleQC( hMainFig ); + updateSampleQC( hMainFig, PARA ); % Update tsg application data % --------------------------- diff --git a/tsg_util/diffTsgSample.m b/tsg_util/diffTsgSample.m index fb52cd370f3e730f6495c0b80c4103b4060ed5f9..11bae565cc6a8b8f9d9fd136685be77e467477f9 100644 --- a/tsg_util/diffTsgSample.m +++ b/tsg_util/diffTsgSample.m @@ -1,4 +1,4 @@ -function diffTsgSample(hTsgGUI) +function diffTsgSample(hTsgGUI, PARA) % % Co-location of sample and TSG measurements % Compute the sample-TSG difference @@ -14,14 +14,9 @@ probablyGoodCode = get(tsg.qc.hash, 'PROBABLY_GOOD', 'code'); % Consider only tsg data with NO_CONTROL, GOOD and PROBABLY_GOOD code % ------------------------------------------------------------------- -indTsg = find( tsg.SSPS_QC <= probablyGoodCode ); +indTsg = find( tsg.([PARA '_QC']) <= probablyGoodCode ); -[m, n] = size(tsg.SSPS_SPL); - -% time difference between 2 successive TSG measurements -% Not use anymore. Now use a constant tsg.cst.TSG_WS_TIMEDIFF in the test -% ----------------------------------------------------------------------- -% dt = min(diff(tsg.DAYD)); +[m, n] = size(tsg.([PARA '_SPL'])); % Loop on the samples % ------------------- @@ -42,14 +37,14 @@ for i= 1 : m if timeDiff(indMin) < tsg.cst.TSG_WS_TIMEDIFF && ... ~isnan(tsg.ssps_smooth(indMin)) - tsg.SSPS_SPL_SMOOTH(i) = tsg.ssps_smooth(indMin); + tsg.([PARA '_SPL_SMOOTH'])(i) = tsg.ssps_smooth(indMin); end end % Salinity difference : Sample minus smoothed TSG % ----------------------------------------------- -tsg.SSPS_SPL_DIF = tsg.SSPS_SPL - tsg.SSPS_SPL_SMOOTH; +tsg.([PARA '_SPL_DIF']) = tsg.([PARA '_SPL']) - tsg.([PARA '_SPL_SMOOTH']); % update the sample structures in the application % ------------------------------------------------ diff --git a/tsg_util/plot_Correction.m b/tsg_util/plot_Correction.m index 919bd0426f32bb42697db30ffb54f5b2720c2afc..5b2763137cac8762d4355f90dafaa0b5da97edd3 100644 --- a/tsg_util/plot_Correction.m +++ b/tsg_util/plot_Correction.m @@ -1,4 +1,4 @@ -function plot_Correction( hMainFig, hPlotAxes ) +function plot_Correction( hMainFig, hPlotAxes, PARA ) % Reinitialise plot 1 and 3 @@ -18,30 +18,30 @@ VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code'); % **************************** AXE 1 *********************************** % Plot the samples % ---------------- -if ~isempty( tsg.SSPS_SPL ) +if ~isempty( tsg.([PARA '_SPL']) ) % Plot bucket samples % ------------------- - iWS = find( tsg.SSPS_SPL_TYPE == 1 ); + iWS = find( tsg.([PARA '_SPL_TYPE']) == 1 ); if ~isempty(iWS) plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(iWS),... - tsg.SSPS_SPL_DIF(iWS), tsg.SSPS_SPL_QC(iWS),... - 'SSPS_SPL_1','','none','square',5); + tsg.([PARA '_SPL_DIF'])(iWS), tsg.([PARA '_SPL_QC'])(iWS),... + [PARA '_SPL_1'],'','none','square',5); end % Plot other (external) samples % ----------------------------- - iEXT = find( tsg.SSPS_SPL_TYPE > 1 ); + iEXT = find( tsg.([PARA '_SPL_TYPE']) > 1 ); if ~isempty(iEXT) plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD_SPL(iEXT),... - tsg.SSPS_SPL_DIF(iEXT), tsg.SSPS_SPL_QC(iEXT),... - 'SSPS_SPL_2','','none','o',5); + tsg.([PARA '_SPL_DIF'])(iEXT), tsg.([PARA '_SPL_QC'])(iEXT),... + [PARA '_SPL_2'],'','none','o',5); end end % Select the record with VALUE_CHANGED code % ----------------------------------------- -iVC = find( tsg.SSPS_ADJUSTED_QC == VALUE_CHANGED ); +iVC = find( tsg.([PARA '_ADJUSTED_QC']) == VALUE_CHANGED ); % Select only records corrected but not calibrated. % Records corrected and calibrated have the same QC code. @@ -49,7 +49,7 @@ iVC = find( tsg.SSPS_ADJUSTED_QC == VALUE_CHANGED ); % ------------------------------------------------------ iERR = []; if iVC ~= 0 - iERR = find( isnan( tsg.SSPS_ADJUSTED_ERROR(iVC) ) == 0 ); + iERR = find( isnan( tsg.([PARA '_ADJUSTED_ERROR'])(iVC) ) == 0 ); end % Plot the difference tsg.SSPS_ADJUSTED-tsg.SSPS on axe 1 @@ -59,29 +59,29 @@ end if iERR ~= 0 plot_Tsg( hMainFig, hPlotAxes, 1,... tsg.DAYD(iVC(iERR)),... - tsg.SSPS_ADJUSTED(iVC(iERR))-tsg.SSPS(iVC(iERR)),... - [], 'SSPS_ADJUSTED','b','none','.',1); + tsg.([PARA '_ADJUSTED'])(iVC(iERR))-tsg.(PARA)(iVC(iERR)),... + [], [PARA '_ADJUSTED'],'b','none','.',1); end % **************************** AXE 2 *********************************** % Plot SSPS and SAMPLE, with code color, on axe 2 % ------------------------------------------------ -plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.SSPS, tsg.SSPS_QC,... - 'SSPS','','none','*',2); +plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.(PARA), tsg.([PARA '_QC']),... + PARA,'','none','*',2); -if ~isempty( tsg.SSPS_SPL ) - ind = find( tsg.SSPS_SPL_TYPE == 1 ); +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.SSPS_SPL(ind), tsg.SSPS_SPL_QC(ind),... - 'SSPS_SPL_1','','none','square',5); + tsg.([PARA '_SPL'])(ind), tsg.([PARA '_SPL_QC'])(ind),... + [PARA '_SPL_1'],'','none','square',5); end - ind = find( tsg.SSPS_SPL_TYPE > 1 ); + ind = find( tsg.([PARA '_SPL_TYPE']) > 1 ); if ~isempty(ind) plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD_SPL(ind),... - tsg.SSPS_SPL(ind), tsg.SSPS_SPL_QC(ind),... - 'SSPS_SPL_2','','none','o',5); + tsg.([PARA '_SPL'])(ind), tsg.([PARA '_SPL_QC'])(ind),... + [PARA '_SPL_2'],'','none','o',5); end end @@ -89,21 +89,21 @@ end % Plot SSPS, with no code, on axe3 % -------------------------------- -plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.SSPS_ADJUSTED, [],... - 'SSPS_ADJUSTED','r','none','*',1); +plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.([PARA '_ADJUSTED']), [],... + [PARA '_ADJUSTED'],'r','none','*',1); -plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.SSPS,... - [],'SSPS','k','none','*',1); +plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.(PARA),... + [],PARA,'k','none','*',1); % Plot TSG_ADJUSTED + ERROR on axe 3 % ----------------------------------- if iERR ~= 0 plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD(iVC(iERR)),... - tsg.SSPS_ADJUSTED(iVC(iERR)) + tsg.SSPS_ADJUSTED_ERROR(iVC(iERR)),... - [], 'SSPS_ADJUSTED','g','none','*',1); + tsg.([PARA '_ADJUSTED'])(iVC(iERR)) + tsg.([PARA '_ADJUSTED_ERROR'])(iVC(iERR)),... + [], [PARA '_ADJUSTED'],'g','none','*',1); plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD(iVC(iERR)),... - tsg.SSPS_ADJUSTED(iVC(iERR)) - tsg.SSPS_ADJUSTED_ERROR(iVC(iERR)),... - [], 'SSPS_ADJUSTED','g','none','*',1); + tsg.([PARA '_ADJUSTED'])(iVC(iERR)) - tsg.([PARA '_ADJUSTED_ERROR'])(iVC(iERR)),... + [], [PARA '_ADJUSTED'],'g','none','*',1); end end diff --git a/tsg_util/plot_Interpolation.m b/tsg_util/plot_Interpolation.m index ac44765e96ca247f596356b28cbbbb2df6dcbe10..65427155dd3c6f56c88a982be76c478c745e6554 100644 --- a/tsg_util/plot_Interpolation.m +++ b/tsg_util/plot_Interpolation.m @@ -38,7 +38,13 @@ switch nPlot case 2 erase_Line( hPlotAxes, 2 ); - if ~isempty(tsg.POSITION_QC) + + if ~isempty( tsg.LATX ) + plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.LATX,[],... + 'LATX','k','none','*',2); + end + + if ~isempty(tsg.POSITION_QC) ind = find( tsg.POSITION_QC == INTERPOLATED_VALUE ); if ~isempty( ind ) plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD(ind), tsg.LATX(ind),[],... @@ -46,17 +52,18 @@ switch nPlot end end - if ~isempty( tsg.LATX ) - plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.LATX,[],... - 'LATX','k','none','*',2); - end - % set( hPlotAxes(2) ,'xlim', [tsg.DAYD(1) tsg.DAYD(end)] ); % --------------------------------------------------------------------- case 3 erase_Line( hPlotAxes, 3 ); + + if ~isempty( tsg.LONX ) + plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.LONX,[],... + 'LONX','k','none','*',2); + end + if ~isempty(tsg.POSITION_QC) ind = find( tsg.POSITION_QC == INTERPOLATED_VALUE ); if ~isempty( ind ) @@ -65,11 +72,6 @@ switch nPlot end end - if ~isempty( tsg.LONX ) - plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.LONX,[],... - 'LONX','k','none','*',2); - end - % set( hPlotAxes(3) ,'xlim', [tsg.DAYD(1) tsg.DAYD(end)] ); end diff --git a/tsg_util/plot_Validation.m b/tsg_util/plot_Validation.m index 2bf0fb016fa95afbd0892cdc7ea98dd9f425d675..1ec841395fcba747db0e8086db08199d6dab628c 100644 --- a/tsg_util/plot_Validation.m +++ b/tsg_util/plot_Validation.m @@ -1,4 +1,4 @@ -function plot_Validation( hMainFig, hPlotAxes, nPlot ) +function plot_Validation( hMainFig, hPlotAxes, nPlot, PARA ) % Get tsg application data % ------------------------ @@ -10,37 +10,37 @@ 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.ssps_smooth ) +% plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD, tsg.ssps_smooth, [],... +% 'SSPS_SMOOTH','k','-','*',2); +% end - if ~isempty( tsg.SSPS ) - plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD, tsg.SSPS, tsg.SSPS_QC,... - 'SSPS','','none','*',2); + if ~isempty( tsg.(PARA) ) + plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD, tsg.(PARA), tsg.([PARA '_QC']),... + PARA,'','none','*',2); end % 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.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 % --------------------------------------------------------------------- case 2 erase_Line( hPlotAxes, 2 ); if ~isempty( tsg.SSJT ) - plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.SSJT,[],... + plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.SSJT, tsg.SSJT_QC,... 'SSJT','k','none','*',2); end diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m index 70f11a12c1616078c6eaaa7977bce92ba5224466..0364bf9ec7a7fd9c6ca2227ce02b5d5a7a2e1910 100644 --- a/tsg_util/tsg_initialisation.m +++ b/tsg_util/tsg_initialisation.m @@ -114,7 +114,9 @@ tsg.cst.TSG_DT_SMOOTH = datenum(0, 0, 0, 1, 0 , 0); % Salinity, in 1 hour interval, should not depart the average for more % than SAL_STD_MAX standard deviation % -------------------------------------------------------------------- -tsg.cst.TSG_STDMAX = 0.1; +tsg.SSPS_STDMAX = 0.1; +tsg.SSJT_STDMAX = 1.0; +tsg.SSTP_STDMAX = 1.0; % Correction is estimated by computing the median value of X tsg-sample % differences diff --git a/tsg_util/tsg_mergesample.m b/tsg_util/tsg_mergesample.m index 0b1068a18e5a33d488fcef1f16bccc734f4bca78..635be0e48b34358079bd54f090516b50248357c1 100644 --- a/tsg_util/tsg_mergesample.m +++ b/tsg_util/tsg_mergesample.m @@ -1,4 +1,4 @@ -function [] = tsg_mergesample( hTsgGUI ) +function [] = tsg_mergesample( hTsgGUI, PARA ) % % function [] = tsg_mergesample( hTsgGUI ) % @@ -16,72 +16,83 @@ function [] = tsg_mergesample( hTsgGUI ) % --------------------------------------------------------------------- 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 +% --------------------------------------------------------------- +PARA_OLD = PARA; +if strcmp( PARA, 'SSJT' ) + PARA_OLD = PARA; + PARA = 'SSTP'; +end + % Create a structure with an NaN % No other solution as I can't add a structure to an empty one % ------------------------------------------------------------ sample = struct('DAYD',NaN , 'LATX',NaN , 'LONX',NaN , ... - 'SSPS',NaN , 'SSPS_QC',NaN , 'SSPS_DIF',NaN ,... - 'SSPS_SMOOTH',NaN , 'SSPS_TYPE', NaN, 'SSPS_INDICE', NaN); + 'PARM',NaN , 'PARM_QC',NaN , 'PARM_DIF',NaN ,... + 'PARM_SMOOTH',NaN , 'PARM_TYPE', NaN, 'PARM_INDICE', NaN); % Fill the structure sample with the bucket data. +% WS exist only for SSPS % This measurements are of TYPE 1 % ------------------------------------------------ -if ~isempty(tsg.SSPS_WS) +if strcmp( PARA, 'SSPS') & ~isempty(tsg.([PARA '_WS'])) sample.DAYD = [sample.DAYD; tsg.DAYD_WS]; sample.LATX = [sample.LATX; tsg.LATX_WS]; sample.LONX = [sample.LONX; tsg.LONX_WS]; - sample.SSPS = [sample.SSPS; tsg.SSPS_WS]; - if ~isempty(tsg.SSPS_WS_QC) - sample.SSPS_QC = [sample.SSPS_QC; tsg.SSPS_WS_QC]; + sample.PARM = [sample.PARM; tsg.([PARA '_WS']) ]; + if ~isempty(tsg.([PARA '_WS_QC'])) + sample.PARM_QC = [sample.PARM_QC; tsg.([PARA '_WS_QC']) ]; else - sample.SSPS_QC = [sample.SSPS_QC; ones(size(tsg.DAYD_WS))]; + sample.PARM_QC = [sample.PARM_QC; ones(size(tsg.DAYD_WS))]; end % Fill the structure with NaN. NaN is tested in diffTsgSample % ----------------------------------------------------------- - sample.SSPS_DIF = [sample.SSPS_DIF; NaN*ones(size(tsg.DAYD_WS))]; - sample.SSPS_SMOOTH = [sample.SSPS_SMOOTH; NaN*ones(size(tsg.DAYD_WS))]; + sample.PARM_DIF = [sample.PARM_DIF; NaN*ones(size(tsg.DAYD_WS))]; + sample.PARM_SMOOTH = [sample.PARM_SMOOTH; NaN*ones(size(tsg.DAYD_WS))]; % INDICE is used to put back the QC once the validation procedure has % been applied % ------------------------------------------------------------------- - sample.SSPS_INDICE = [sample.SSPS_INDICE; [1:length(tsg.DAYD_WS)]']; + sample.PARM_INDICE = [sample.PARM_INDICE; [1:length(tsg.DAYD_WS)]']; % Used for the plots : WS are given a type 1 % ------------------------------------------ - sample.SSPS_TYPE = [sample.SSPS_TYPE; ones(size(tsg.DAYD_WS))]; + sample.PARM_TYPE = [sample.PARM_TYPE; ones(size(tsg.DAYD_WS))]; end % Fill the structure sample with the external sample % This measurements are of TYPE EXT % -------------------------------------------------- -if ~isempty(tsg.SSPS_EXT) +if ~isempty(tsg.([PARA '_EXT'])) sample.DAYD = [sample.DAYD; tsg.DAYD_EXT]; sample.LATX = [sample.LATX; tsg.LATX_EXT]; sample.LONX = [sample.LONX; tsg.LONX_EXT]; - sample.SSPS = [sample.SSPS; tsg.SSPS_EXT]; - if ~isempty(tsg.SSPS_EXT_QC) - sample.SSPS_QC = [sample.SSPS_QC; tsg.SSPS_EXT_QC]; + sample.PARM = [sample.PARM; tsg.([PARA '_EXT'])]; + if ~isempty(tsg.([PARA '_EXT_QC'])) + sample.PARM_QC = [sample.PARM_QC; tsg.([PARA '_EXT_QC'])]; else - sample.SSPS_QC = [sample.SSPS_QC; ones(size(sample.DAYD_EXT))]; + sample.PARM_QC = [sample.PARM_QC; ones(size(sample.DAYD_EXT))]; end % Fill the following structures with NaN. NaN is test in diffTsgSample % -------------------------------------------------------------------- - sample.SSPS_DIF = [sample.SSPS_DIF; NaN*ones(size(tsg.DAYD_EXT))]; - sample.SSPS_SMOOTH = [sample.SSPS_SMOOTH; NaN*ones(size(tsg.DAYD_EXT))]; + sample.PARM_DIF = [sample.PARM_DIF; NaN*ones(size(tsg.DAYD_EXT))]; + sample.PARM_SMOOTH = [sample.PARM_SMOOTH; NaN*ones(size(tsg.DAYD_EXT))]; % Used for the plots : EXT sample are given a type 2 % -------------------------------------------------- - sample.SSPS_TYPE = [sample.SSPS_TYPE; 2*ones(size(tsg.DAYD_EXT))]; + sample.PARM_TYPE = [sample.PARM_TYPE; 2*ones(size(tsg.DAYD_EXT))]; % INDICE is used to put back the QC once the validation procedure has % been applied % ------------------------------------------------------------------- - sample.SSPS_INDICE = [sample.SSPS_INDICE; [1:length(tsg.DAYD_EXT)]']; + sample.PARM_INDICE = [sample.PARM_INDICE; [1:length(tsg.DAYD_EXT)]']; end @@ -91,12 +102,12 @@ if isnan(sample.DAYD(1)) sample.DAYD(1) = []; sample.LATX(1) = []; sample.LONX(1) = []; - sample.SSPS(1) = []; - sample.SSPS_QC(1) = []; - sample.SSPS_DIF(1) = []; - sample.SSPS_SMOOTH(1) = []; - sample.SSPS_TYPE(1) = []; - sample.SSPS_INDICE(1) = []; + sample.PARM(1) = []; + sample.PARM_QC(1) = []; + sample.PARM_DIF(1) = []; + sample.PARM_SMOOTH(1) = []; + sample.PARM_TYPE(1) = []; + sample.PARM_INDICE(1) = []; end % Sort the struct sample - increasing time. @@ -105,27 +116,40 @@ if ~isempty(sample) [sample.DAYD, iOrder] = sort(sample.DAYD); sample.LATX = sample.LATX(iOrder); sample.LONX = sample.LONX(iOrder); - sample.SSPS = sample.SSPS(iOrder); - sample.SSPS_QC = sample.SSPS_QC(iOrder); - sample.SSPS_DIF = sample.SSPS_DIF(iOrder); - sample.SSPS_SMOOTH = sample.SSPS_SMOOTH(iOrder); - sample.SSPS_TYPE = sample.SSPS_TYPE(iOrder); - sample.SSPS_INDICE = sample.SSPS_INDICE(iOrder); + sample.PARM = sample.PARM(iOrder); + sample.PARM_QC = sample.PARM_QC(iOrder); + sample.PARM_DIF = sample.PARM_DIF(iOrder); + sample.PARM_SMOOTH = sample.PARM_SMOOTH(iOrder); + sample.PARM_TYPE = sample.PARM_TYPE(iOrder); + sample.PARM_INDICE = sample.PARM_INDICE(iOrder); % put the structure sample in the tsg structure % --------------------------------------------- - tsg.DAYD_SPL = sample.DAYD; - tsg.LATX_SPL = sample.LATX; - tsg.LONX_SPL = sample.LONX; - tsg.SSPS_SPL = sample.SSPS; - tsg.SSPS_SPL_QC = sample.SSPS_QC; - tsg.SSPS_SPL_DIF = sample.SSPS_DIF; - tsg.SSPS_SPL_SMOOTH = sample.SSPS_SMOOTH; - tsg.SSPS_SPL_TYPE = sample.SSPS_TYPE; - tsg.SSPS_SPL_INDICE = sample.SSPS_INDICE; + tsg.DAYD_SPL = sample.DAYD; + tsg.LATX_SPL = sample.LATX; + tsg.LONX_SPL = sample.LONX; + tsg.([PARA '_SPL']) = sample.PARM; + tsg.([PARA '_SPL_QC']) = sample.PARM_QC; + tsg.([PARA '_SPL_DIF']) = sample.PARM_DIF; + tsg.([PARA '_SPL_SMOOTH']) = sample.PARM_SMOOTH; + tsg.([PARA '_SPL_TYPE']) = sample.PARM_TYPE; + tsg.([PARA '_SPL_INDICE']) = sample.PARM_INDICE; end +% 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 +% --------------------------------------------------------------- +if strcmp( PARA_OLD, 'SSJT' ) + tsg.SSJT_SPL = tsg.SSTP_SPL; + tsg.SSJT_SPL_QC = tsg.SSTP_SPL_QC; + tsg.SSJT_SPL_DIF = tsg.SSTP_SPL_DIF; + tsg.SSJT_SPL_SMOOTH = tsg.SSTP_SPL_SMOOTH; + tsg.SSJT_SPL_TYPE = tsg.SSTP_SPL_TYPE; + tsg.SSJT_SPL_INDICE = tsg.SSTP_SPL_INDICE; +end + % Update application data % ----------------------- setappdata( hTsgGUI, 'tsg_data', tsg ); diff --git a/tsg_util/tsg_moveaverage.m b/tsg_util/tsg_moveaverage.m index c97986d207e5735f48b94a6082d4c2a0a2eb0ad3..fd6b58489d3b6465bebe199c5b6c0ad53ceeed7c 100644 --- a/tsg_util/tsg_moveaverage.m +++ b/tsg_util/tsg_moveaverage.m @@ -1,4 +1,4 @@ -function [] = tsg_moveaverage(hTsgGUI) +function [] = tsg_moveaverage(hTsgGUI, PARA) % Perform a moving average of a time series. % 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' @@ -16,12 +16,16 @@ tsg = getappdata( hTsgGUI, 'tsg_data'); % Memory allocation % ----------------- -smooth = zeros( size(tsg.SSPS) ); -nval = zeros( size(tsg.SSPS) ); +smooth = zeros( size(tsg.(PARA)) ); +nval = zeros( size(tsg.(PARA)) ); % Loop over the tsg.SSPS time series % ----------------------------------- -for i = 1:length(tsg.SSPS) +h = waitbar(0,'Please wait. Compute a smooth time series ....'); +iEnd = length(tsg.(PARA)); +for i = 1:iEnd + + 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 @@ -39,22 +43,22 @@ for i = 1:length(tsg.SSPS) % Compare Standard Deviation to the MAX acceptable STD % ---------------------------------------------------- - while currentStd > tsg.cst.TSG_STDMAX && currentStd ~= previousStd + while currentStd > tsg.([PARA '_STDMAX']) && currentStd ~= previousStd previousStd = currentStd; % Standard deviation and average over timeInterval % ------------------------------------------------ - currentStd = nanstd( tsg.SSPS(ind2) ); - meanParam = nanmean( tsg.SSPS(ind2) ); + currentStd = nanstd( tsg.(PARA)(ind2) ); + meanParam = nanmean( tsg.(PARA)(ind2) ); % Indices of 'good' values of Param % --------------------------------- - ind2 = ind1( tsg.SSPS(ind1) >= meanParam - currentStd & ... - tsg.SSPS(ind1) <= meanParam + currentStd ); + ind2 = ind1( tsg.(PARA)(ind1) >= meanParam - currentStd & ... + tsg.(PARA)(ind1) <= meanParam + currentStd ); end - smooth(i) = nanmean( tsg.SSPS(ind2) ); + smooth(i) = nanmean( tsg.(PARA)(ind2) ); else smooth(i) = NaN; @@ -62,7 +66,10 @@ for i = 1:length(tsg.SSPS) nval( i ) = length( ind2 ); end +close(h) +% Transfer the smooth timeseries to the TSG structure +% --------------------------------------------------- tsg.ssps_smooth = smooth; tsg.ssps_smooth_nval = nval; diff --git a/tsg_util/updateSampleQC.m b/tsg_util/updateSampleQC.m index 01cb57761d3c8866a77088a99623690393e8afdc..05deb7e0af54df6f0385b3c8df7d30c458d6bb1c 100644 --- a/tsg_util/updateSampleQC.m +++ b/tsg_util/updateSampleQC.m @@ -1,4 +1,4 @@ -function updateSampleQC( hTsgGUI ) +function updateSampleQC( hTsgGUI, PARA ) % % Update the QC code for WS and EXT samples % @@ -16,16 +16,16 @@ tsg = getappdata( hTsgGUI, 'tsg_data'); % Update WS QC % ------------ -indWS = find( tsg.SSPS_SPL_TYPE == 1 ); +indWS = find( tsg.([PARA '_SPL_TYPE']) == 1 ); if ~isempty(indWS) - tsg.SSPS_WS_QC = tsg.SSPS_SPL_QC(indWS); + tsg.([PARA '_WS_QC']) = tsg.([PARA '_SPL_QC'])(indWS); end % Update EXT QC % ------------- -indEXT = find( tsg.SSPS_SPL_TYPE == 2 ); +indEXT = find( tsg.([PARA '_SPL_TYPE']) == 2 ); if ~isempty(indEXT) - tsg.SSPS_EXT_QC = tsg.SSPS_SPL_QC(indEXT); + tsg.([PARA '_EXT_QC']) = tsg.([PARA '_SPL_QC'])(indEXT); end % update the tsg structure in the application diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m index 43565e6274008464e3782c2260ff5e5164860212..bfd7c1f297423e901aea703df4a94514ff2f23ae 100644 --- a/tsg_util/updateTsgStruct.m +++ b/tsg_util/updateTsgStruct.m @@ -13,8 +13,8 @@ function updateTsgStruct(hMainFig) % ------------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); -nPARA = 3; -PARA = ['SSPS'; 'SSJT'; 'SSPS']; +nPARA = 2; +PARA = ['SSPS'; 'SSJT']; % get min and max values for position and set to globals attributes % ----------------------------------------------------------------- diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index 064e67e96c6e958768bb9bd8ac11faa36394bc8c..1d0860bf2f11fdd9eb3cd4a4df78c29a23de0b43 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -910,9 +910,6 @@ hrbInterpCancel = uicontrol( ... % ------------------------------------------------------- if strcmp(tsg.preference.autoload, 'on') - % this code need to be fatorized file/open menu - % --------------------------------------------- - % A TSG file has been open and read % --------------------------------- set( hOpenMenu, 'UserData', 'on' ); @@ -939,24 +936,28 @@ if strcmp(tsg.preference.autoload, 'on') % ----------------------------------- updateTsgStruct( hMainFig ); - % Running average of TSG time series - % ---------------------------------- - tsg_moveaverage(hMainFig); - % Get application data for the test % --------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); - if ~isempty( tsg.SSPS_WS ) || ~isempty( tsg.SSPS_EXT ) - tsg_mergesample( hMainFig ); - end + % Get the default parameter + % ------------------------- + PARA = tsg.preference.parameter; + + % Running average of TSG time series + % ---------------------------------- + tsg_moveaverage( hMainFig, PARA ); + + % Merge sample from different origins : WS and EXT + % ------------------------------------------------ + tsg_mergesample( hMainFig, PARA ); % Draw the 3 plots of the validation figure % ----------------------------------------- resetAxes( hMainFig, hPlotAxes ); - plot_Validation( hMainFig, hPlotAxes, 1 ); - plot_Validation( hMainFig, hPlotAxes, 2 ); - plot_Validation( hMainFig, hPlotAxes, 3 ); + plot_Validation( hMainFig, hPlotAxes, 1, PARA ); + plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); + plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); % Draw the map with the ship track % -------------------------------- @@ -1026,8 +1027,8 @@ end % Read the data % ------------- - errTsg = -1; - errSpl = -1; + errTsg = -2; + errSpl = -2; switch filterIndex case 1 % read TSG text file *.txt @@ -1069,7 +1070,13 @@ end end % switch filterIndex + % Get the tsg structure + % --------------------- tsg = getappdata( hMainFig, 'tsg_data'); + + % Default parameter + % ----------------- + PARA = tsg.preference.parameter; % A TSG file has been read % ------------------------ @@ -1102,7 +1109,7 @@ end % Running average of TSG time series % ---------------------------------- - tsg_moveaverage(hMainFig); + tsg_moveaverage(hMainFig, PARA); % The callback to detect the mouse motion can be set to on % -------------------------------------------------------- @@ -1112,12 +1119,12 @@ end % -------------------- display_QC( hMainFig, hPlotAxes); - else + elseif errTsg > -2 % Problem to read the file or % Choice of parameters for Labview file canceled by the user % TSG structure has been reinitialize - % Disable toolbar menu pushtool + % Disable toolbar menu pushtool except the open file button % ---------------------------------------------------------- hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_'); set(hdl_pushtool, 'Enable', 'off'); @@ -1125,27 +1132,19 @@ end set( hOpenPushtool, 'Enable', 'on' ); end %if errTsg > 0 - - % A Sample file has been read - % --------------------------- - if errSpl > 0 - - % Merge bucket and external samples - % --------------------------------- - if ~isempty( tsg.SSPS_WS ) || ~isempty( tsg.SSPS_EXT ) - tsg_mergesample( hMainFig ); - end - - end + + % Merge sample from different origins : WS and EXT + % ------------------------------------------------ + tsg_mergesample( hMainFig, PARA ); end % if ~isequal(fileName, 0) % Draw the 3 plots of the validation figure % ----------------------------------------- resetAxes( hMainFig, hPlotAxes ) - plot_Validation( hMainFig, hPlotAxes, 1 ); - plot_Validation( hMainFig, hPlotAxes, 2 ); - plot_Validation( hMainFig, hPlotAxes, 3 ); + plot_Validation( hMainFig, hPlotAxes, 1, PARA ); + plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); + plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); % Pointer reset to arrow % ---------------------- @@ -1168,13 +1167,13 @@ end % Toggle button % ------------- - set( hBottleToggletool, 'state', 'off', 'enable', 'off' ); - set( hCalToggletool, 'state', 'off', 'enable', 'off' ); - set( hClimToggletool, 'state', 'off', 'enable', 'off' ); - set( hPanToggletool, 'state', 'off', 'enable', 'on' ); - set( hQCToggletool, 'state', 'off', 'enable', 'off' ); + set( hBottleToggletool, 'state', 'off', 'enable', 'off'); + set( hCalToggletool, 'state', 'off', 'enable', 'off'); + set( hClimToggletool, 'state', 'off', 'enable', 'off'); + set( hPanToggletool, 'state', 'off', 'enable', 'on' ); + set( hQCToggletool, 'state', 'off', 'enable', 'off'); set( hTimelimitToggletool, 'state', 'off', 'enable', 'on' ); - set( hZoomToggletool, 'state', 'off', 'enable', 'on' ); + set( hZoomToggletool, 'state', 'off', 'enable', 'on' ); set( hHeaderPushtool, 'enable', 'off' ); @@ -1211,11 +1210,15 @@ end set( hHeaderPushtool, 'enable', 'on' ); + % Get tsg structure + % ----------------- + tsg = getappdata( hMainFig, 'tsg_data' ); + % Draw the 3 plots of the validation figure % ----------------------------------------- - plot_Validation( hMainFig, hPlotAxes, 1 ); - plot_Validation( hMainFig, hPlotAxes, 2 ); - plot_Validation( hMainFig, hPlotAxes, 3 ); + plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter ); + plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); + plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); % Set the pointer % --------------- @@ -1384,9 +1387,9 @@ end % Draw the 3 plots of the validation figure % ----------------------------------------- - plot_Validation( hMainFig, hPlotAxes, 1 ); - plot_Validation( hMainFig, hPlotAxes, 2 ); - plot_Validation( hMainFig, hPlotAxes, 3 ); + plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter ); + plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); + plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); end @@ -1587,6 +1590,8 @@ end %---------------------------------------------------------------------- function QC_OnMenuCallback(gcbo, eventdata) + PARA = tsg.preference.parameter; + % Desactivate toggletools. % ------------------------ set( hZoomToggletool, 'state', 'off' ); @@ -1647,8 +1652,10 @@ end % get index on selected zone % -------------------------- - ind = find(tsg.DAYD_SPL > p1(1,1) & tsg.DAYD_SPL < p2(1,1) & ... - tsg.SSPS_SPL_DIF > p1(1,2) & tsg.SSPS_SPL_DIF < p2(1,2)); + ind = find(tsg.DAYD_SPL > p1(1,1) &... + tsg.DAYD_SPL < p2(1,1) & ... + tsg.([PARA '_SPL_DIF']) > p1(1,2) &... + tsg.([PARA '_SPL_DIF']) < p2(1,2)); % Keep the information on the indices of the selected zone % -------------------------------------------------------- @@ -1656,7 +1663,7 @@ end % Modifiy the QC % -------------- - tsg.SSPS_SPL_QC(ind) = tsg.qc.active.Code; + tsg.([PARA '_SPL_QC'])(ind) = tsg.qc.active.Code; % Save the modifications % ---------------------- @@ -1664,18 +1671,18 @@ end % Update sample QC in the _WS and _EXT records % -------------------------------------------- - updateSampleQC( hMainFig ); + updateSampleQC( hMainFig, PARA ); % plot selected data with selected code % -------------------------------------- - plot_Correction( hMainFig, hPlotAxes); + plot_Correction( hMainFig, hPlotAxes, PARA); else % get index on selected zone % --------------------------- - ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... - tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2)); + ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... + tsg.(PARA) > p1(1,2) & tsg.(PARA) < p2(1,2)); % Keep the information on the indices of the selected zone % -------------------------------------------------------- @@ -1683,15 +1690,15 @@ end % Modifiy the QC % -------------- - tsg.SSPS_QC(ind) = tsg.qc.active.Code; + tsg.([PARA '_QC'])(ind) = tsg.qc.active.Code; % put last SSPS_QC in queue (Undo/Redo) % ------------------------------------- - tsg.queue = push( tsg.queue, tsg.SSPS_QC); + tsg.queue = push( tsg.queue, tsg.([PARA '_QC'])); % store QC in queue object, for undo % ---------------------------------- - tsg.queue = push(tsg.queue, tsg.SSPS_QC); + tsg.queue = push(tsg.queue, tsg.([PARA '_QC'])); % Save the modifications % ---------------------- @@ -1699,7 +1706,7 @@ end % Draw plot 1 of the validation figure % ------------------------------------ - plot_Validation( hMainFig, hPlotAxes, 1 ); + plot_Validation( hMainFig, hPlotAxes, 1, PARA ); % refresh QC statistic panel % -------------------------- @@ -1759,6 +1766,10 @@ end % Retrieve Default Quality Code and Color % --------------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); + + % Get the parameter (SSPS, SSJT or SSTP) + % -------------------------------------- + PARA = tsg.preference.parameter; % get key and some values in hashtable % ------------------------------------ @@ -1776,7 +1787,7 @@ end if strcmp( get(hBottleToggletool, 'state'), 'on') - tsg.SSPS_SPL_QC(tsg.rbboxind) = tsg.qc.active.Code; + tsg.([PARA '_SPL_QC'])(tsg.rbboxind) = tsg.qc.active.Code; % Save tsg.SSPS_QC and tsg.qc.active.Code % in the application data @@ -1785,10 +1796,10 @@ end % Draw the 3 plots of the Correction figure % ----------------------------------------- - plot_Correction( hMainFig, hPlotAxes ); + plot_Correction( hMainFig, hPlotAxes, PARA ); else - tsg.SSPS_QC(tsg.rbboxind) = tsg.qc.active.Code; + tsg.([PARA '_QC'])(tsg.rbboxind) = tsg.qc.active.Code; % Save tsg.SSPS_QC in the application data % ---------------------------------------- @@ -1796,7 +1807,7 @@ end % Draw plot 1 of the validation figure % ------------------------------------ - plot_Validation( hMainFig, hPlotAxes, 1 ); + plot_Validation( hMainFig, hPlotAxes, 1, PARA ); end @@ -1975,16 +1986,6 @@ end %--------------------------------------------------------------------- function Map_OffMenuCallback(hObject, eventdata) - %if ~isempty( get(hMapPanel, 'UserData')) - % delete(get(hMapPanel, 'UserData')); - %end - - %hLines = findobj( hPlotAxes(4), 'Tag', 'TAG_AXES_MAP'); - %hLines = get( hPlotAxes(4), 'Children' ); - %if ~isempty( hLines ) - % delete(hLines); - %end - % Make the earth map invisible % ---------------------------- set(hMapPanel, 'Visible', 'off' ); @@ -2024,6 +2025,10 @@ end % --------------------- tsg = getappdata(hMainFig, 'tsg_data'); + % Get the parameter we are working on (SSPS, SSJT, SSTP) + % ------------------------------------------------------ + PARA = tsg.preference.parameter; + % Switch somme buttons % -------------------- set( hZoomToggletool, 'state', 'off' ); @@ -2042,15 +2047,19 @@ end % Test if tsg and sample data have been loaded % -------------------------------------------- - if ~isempty( tsg.SSPS_SPL ) + if ~isempty( tsg.([PARA '_SPL']) ) + +% % Running average of TSG time series +% % ---------------------------------- +% tsg_moveaverage(hMainFig, PARA); % Compute the sample-TSG differences % ---------------------------------- - diffTsgSample( hMainFig ); + diffTsgSample( hMainFig, PARA ); % Plot in the 3 axes % ------------------ - plot_Correction( hMainFig, hPlotAxes ); + plot_Correction( hMainFig, hPlotAxes, PARA ); % Get the information on time limits of the time series % Write them in the uipanel @@ -2095,16 +2104,24 @@ end % Desactivate Click Mouse on figure % --------------------------------- set( hMainFig, 'WindowButtonDownFcn', []); + + % Get tsg structure + % ----------------- + tsg = getappdata( hMainFig, 'tsg_data' ); + + % Get the parameter (SSPS, SSJT, SSTP) + % ------------------------------------ + PARA = tsg.preference.parameter; % Drawing only necessary if the Correction moduel has been activated % ------------------------------------------------------------------ - if ~isempty( tsg.SSPS_SPL ) + if ~isempty( tsg.([PARA '_SPL']) ) % Draw the 3 plots of the validation figure % ----------------------------------------- - plot_Validation( hMainFig, hPlotAxes, 1 ); - plot_Validation( hMainFig, hPlotAxes, 2 ); - plot_Validation( hMainFig, hPlotAxes, 3 ); + plot_Validation( hMainFig, hPlotAxes, 1, PARA ); + plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); + plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); end % Set the pointer @@ -2116,37 +2133,40 @@ end %% CorCancelCallback .................................... Correction Module function CorCancelCallback(hObject, eventdata) % Callback function run when ... - + % Desactivate somme Toggle button % ------------------------------- set( hZoomToggletool, 'state', 'off' ); set( hPanToggletool, 'state', 'off' ); set( hQCToggletool, 'state', 'off' ); set( hTimelimitToggletool, 'state', 'off' ); - + % Get tsg application data % ------------------------ tsg = getappdata(hMainFig, 'tsg_data'); + % Get parameter we are working on (SSPS, SSJT, SSTP) + % -------------------------------------------------- + PARA = tsg.preference.parameter; + % To cancel the correction set the ERROR to NaN then % call updateAdjustedVariable. % -------------------------------------------------- - tsg.SSPS_ADJUSTED_ERROR = NaN * ones( size(tsg.SSPS_ADJUSTED_ERROR)); + tsg.([PARA '_ADJUSTED_ERROR']) = ... + NaN * ones( size(tsg.([PARA '_ADJUSTED_ERROR']))); - % Save tsg data - % ------------- - setappdata(hMainFig, 'tsg_data', tsg); + % Save tsg data + % ------------- + setappdata(hMainFig, 'tsg_data', tsg); - % Set the ADJUSTED variable either to the raw variable or to - % the calibrated variable - % ---------------------------------------------------------- - updateAdjustedVariable( hMainFig ); + % Set the ADJUSTED variable either to the raw variable or to + % the calibrated variable + % ---------------------------------------------------------- + updateAdjustedVariable( hMainFig ); - % Plot in the 3 axes - % ------------------ - plot_Correction( hMainFig, hPlotAxes ); -% end -% end + % Plot in the 3 axes + % ------------------ + plot_Correction( hMainFig, hPlotAxes, PARA ); end @@ -2162,17 +2182,22 @@ end set( hTimelimitToggletool, 'state', 'off' ); % Get the time limits for the correction A TESTER - % -------------------------------------- + % ----------------------------------------------- dateMin = datenum(get( hetDateMin, 'String'), 'yyyy-mm-dd HH:MM:SS'); dateMax = datenum(get( hetDateMax, 'String'), 'yyyy-mm-dd HH:MM:SS'); + + % Get the parameter (SSPS, SSJT, or SSTP) + % --------------------------------------- + tsg = getappdata(hMainFig, 'tsg_data'); + PARA = tsg.preference.parameter; % Compute the sample-TSG differences % ---------------------------------- - diffTsgSample( hMainFig ); + diffTsgSample( hMainFig, PARA ); % Correction % ---------- - error = corTsgLinear(hMainFig, dateMin, dateMax); + error = corTsgLinear(hMainFig, PARA, dateMin, dateMax); switch error @@ -2180,7 +2205,7 @@ end % Plot in the 3 axes % ------------------ - plot_Correction( hMainFig, hPlotAxes ); + plot_Correction( hMainFig, hPlotAxes, PARA ); case -1 msgbox( 'Date limits are not correct',... @@ -2204,14 +2229,19 @@ end % -------------------------------------- dateMin = datenum(get( hetDateMin, 'String'), 'yyyy-mm-dd HH:MM:SS'); dateMax = datenum(get( hetDateMax, 'String'), 'yyyy-mm-dd HH:MM:SS'); + + % Get the parameter (SSPS, SSJT, or SSTP) + % --------------------------------------- + tsg = getappdata(hMainFig, 'tsg_data'); + PARA = tsg.preference.parameter; % Compute the sample-TSG differences % ---------------------------------- - diffTsgSample( hMainFig ); + diffTsgSample( hMainFig, PARA ); % Correction % ---------- - error = corTsgMedian(hMainFig, dateMin, dateMax); + error = corTsgMedian(hMainFig, PARA, dateMin, dateMax); switch error @@ -2219,7 +2249,7 @@ end % Plot in the 3 axes % ------------------ - plot_Correction( hMainFig, hPlotAxes ); + plot_Correction( hMainFig, hPlotAxes, PARA ); case -1 msgbox( 'Date limits are not correct',...