diff --git a/tsg_data/Touc0702.nc b/tsg_data/Touc0702.nc index f8f42e65984125a6c237a425330510ef7a919c66..982d00dfe3013825715203212d41c584ef659724 100644 Binary files a/tsg_data/Touc0702.nc and b/tsg_data/Touc0702.nc differ diff --git a/tsg_util/diffTsgSample.m b/tsg_util/diffTsgSample.m index 0ad8f7af2cf857bc0835ec83506fb83a3dba75ea..342daa536253c915300248b8d446f2dd42080349 100644 --- a/tsg_util/diffTsgSample.m +++ b/tsg_util/diffTsgSample.m @@ -16,12 +16,14 @@ probablyGoodCode = get(tsg.qc.hash, 'PROBABLY_GOOD', 'code'); % ------------------------------------------------------------------- indTsg = find( tsg.([PARA '_QC']) <= probablyGoodCode ); -[m, n] = size(tsg.([PARA '_SPL'])); +if ~isempty( indTsg ) + + [m, n] = size(tsg.([PARA '_SPL'])); + + % Loop on the samples + % ------------------- + for i= 1 : m -% Loop on the samples -% ------------------- -for i= 1 : m - % Compute the differences between the sample and the time serie % ------------------------------------------------------------- timeDiff = abs(tsg.DAYD - tsg.DAYD_SPL(i)); @@ -36,7 +38,7 @@ for i= 1 : m % ------------------------- 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 @@ -44,13 +46,15 @@ for i= 1 : m %tsg.([PARA '_SPL_SMOOTH'])(i) = tsg.ssps_smooth(indMin); tsg.([PARA '_SPL_SMOOTH'])(i) = smooth; - end -end + end + end + + % Salinity difference : Sample minus smoothed TSG + % ----------------------------------------------- + tsg.([PARA '_SPL_DIF']) = tsg.([PARA '_SPL']) - tsg.([PARA '_SPL_SMOOTH']); -% Salinity difference : Sample minus smoothed TSG -% ----------------------------------------------- -tsg.([PARA '_SPL_DIF']) = tsg.([PARA '_SPL']) - tsg.([PARA '_SPL_SMOOTH']); + % update the sample structures in the application + % ------------------------------------------------ + setappdata( hTsgGUI, 'tsg_data', tsg ); -% update the sample structures in the application -% ------------------------------------------------ -setappdata( hTsgGUI, 'tsg_data', tsg ); \ No newline at end of file +end \ No newline at end of file diff --git a/tsg_util/initParameterChoice.m b/tsg_util/initParameterChoice.m new file mode 100644 index 0000000000000000000000000000000000000000..a5e147d4a4f2d315649bb68819820ba9b8efd132 --- /dev/null +++ b/tsg_util/initParameterChoice.m @@ -0,0 +1,79 @@ +function error = initParameterChoice( hMainFig, pmhPara ) +% +% Initialise the 3 popup menu used to choose the parameters that will be +% plot on figure 1, 2 and 3 + + +% Get the tsg structure +% --------------------- +tsg = getappdata( hMainFig, 'tsg_data'); + +% Initialisation du popup n°1 +% --------------------------- +if isfield( tsg, 'SSPS' ) + pop1 = { 'SSPS' }; +end +if isfield( tsg, 'SSJT' ) + pop1 = [ pop1 {'SSJT'} ]; +end +if isfield( tsg, 'SSTP' ) + pop1 = [ pop1 {'SSTP'} ]; +end + +set( pmhPara(1), 'String', pop1 ); + +% Initialisation du popup n°2 - Same as pop1 +% ------------------------------------------ +pop2 = pop1; +set( pmhPara(2), 'String', pop2 ); + +% Initialisation du popup n°3 +% --------------------------- +if isfield( tsg, 'SPDC' ) + pop3 = { 'SPDC' }; +end +if isfield( tsg, 'CNDC' ) + pop3 = [ pop3 {'CNDC'} ]; +end +if isfield( tsg, 'LATX' ) + pop3 = [ pop3 {'LATX'} ]; +end +if isfield( tsg, 'LONX' ) + pop3 = [ pop3 {'LONX'} ]; +end +if isfield( tsg, 'SSPS' ) + pop3 = [ pop3 {'SSPS'} ]; +end +if isfield( tsg, 'SSJT' ) + pop3 = [ pop3 {'SSJT'} ]; +end +if isfield( tsg, 'SSTP' ) + pop3 = [ pop3 {'SSTP'} ]; +end + +set( pmhPara(3), 'String', pop3 ); + +% Initialise tsg.preference.parameter +% ----------------------------------- +if ~isempty( pop1{1} ) + tsg.preference.parameter{1} = pop1{1}; +else + tsg.preference.parameter{1} = 'NONE'; +end + +if ~isempty( pop2{2} ) + tsg.preference.parameter{2} = pop2{1}; +else + tsg.preference.parameter{2} = 'NONE'; +end +if ~isempty( pop1{3} ) + tsg.preference.parameter{3} = pop3{1}; +else + tsg.preference.parameter{3} = 'NONE'; +end + +% Save the tsg structure +% --------------------- +setappdata( hMainFig, 'tsg_data', tsg); + +end diff --git a/tsg_util/plot_ClimatologyB.m b/tsg_util/plot_ClimatologyB.m index ec92be26b5a088c6cc8df397e4281d16470ba038..83a4125e563e2d2511e701d7bdacf6ffc5276d98 100644 --- a/tsg_util/plot_ClimatologyB.m +++ b/tsg_util/plot_ClimatologyB.m @@ -68,49 +68,38 @@ dayd = tsg.DAYD( ind ); % Get Climatology % LATX(80) = -0.5 et LATX(81) = 0.5 % LONX(180) = -0.5 et LONX(181) = 0.5 -% ---------------- -para = {'SSTP'; 'SSPS'}; - +% --------------------------------------------- for i = 1:2 + + para = tsg.preference.parameter{i}; + if strcmp( para, 'SSJT' ) + para = 'SSTP'; + end mean = zeros(size(ind)); std = zeros(size(ind)); for ii=1:length(ind) ilat = find(tsg.levitus.data.WOA01_LATX == lat2(ii)); ilon = find(tsg.levitus.data.WOA01_LONX == lon2(ii)); - mean(ii) = tsg.levitus.data.(['WOA01_MEAN_' para{i}])(time_dim,1,ilat,ilon); - std(ii) = tsg.levitus.data.(['WOA01_STD_' para{i}])(time_dim,1,ilat,ilon); + mean(ii) = tsg.levitus.data.(['WOA01_MEAN_' para])(time_dim,1,ilat,ilon); + std(ii) = tsg.levitus.data.(['WOA01_STD_' para])(time_dim,1,ilat,ilon); end - % get handle of axe when SSPS is plotted - % -------------------------------------- - hdls = findobj('-regexp','Tag', ['TAG_PLOT\d_LINE_' para{i}]); - - % get handle of axe when SSTP is plotted - % -------------------------------------- - if strcmp( para{i}, 'SSTP' ) - hdls = findobj('-regexp','Tag', 'TAG_PLOT\d_LINE_SSJT'); - if isempty(hdls) - hdls = findobj('-regexp','Tag', 'TAG_PLOT\d_LINE_SSTP'); - end - end - - if ~isempty(hdls) - hdl_current_axes = get(hdls(1),'parent'); - axes( hdl_current_axes ); - - % Plot mean salinity climatology - % ------------------------------ - line(dayd, mean, ... - 'Tag', ['TAG_LINE_CLIMATO_MEAN_' para{i}], 'Linestyle', '-', 'Color','k'); - - % Plot with 3 standard deviation - % ------------------------------ - line(dayd, mean + 3 * std, ... - 'Tag', ['TAG_LINE_CLIMATO_STDDEV_PLUS_' para{i}], 'Linestyle', '-', 'Color','r'); - line(dayd, mean - 3 * std, ... - 'Tag', ['TAG_LINE_CLIMATO_STDDEV_MINUS_' para{i}], 'Linestyle', '-', 'Color','r'); - end + % Select the axes + % --------------- + axes( hPlotAxes(i) ); + + % Plot mean salinity climatology + % ------------------------------ + line(dayd, mean, ... + 'Tag', ['TAG_LINE_CLIMATO_MEAN_' para], 'Linestyle', '-', 'Color','k'); + + % Plot with 3 standard deviation + % ------------------------------ + line(dayd, mean + 3 * std, ... + 'Tag', ['TAG_LINE_CLIMATO_STDDEV_PLUS_' para], 'Linestyle', '-', 'Color','r'); + line(dayd, mean - 3 * std, ... + 'Tag', ['TAG_LINE_CLIMATO_STDDEV_MINUS_' para], 'Linestyle', '-', 'Color','r'); end diff --git a/tsg_util/plot_Validation.m b/tsg_util/plot_Validation.m index 392dac6b82629b169df8e8448cafb8914ee9618f..ecf7556c919752b5ab9ae94c4803b1b4e43001cc 100644 --- a/tsg_util/plot_Validation.m +++ b/tsg_util/plot_Validation.m @@ -40,17 +40,17 @@ switch nPlot case 2 erase_Line( hPlotAxes, 2 ); - if ~isempty( tsg.SSJT ) - plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.SSJT, tsg.SSJT_QC,... - 'SSJT','k','none','*',2); + if ~isempty( tsg.(PARA) ) + plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD, tsg.(PARA), [],... + PARA,'k','none','*',2); end % --------------------------------------------------------------------- case 3 erase_Line( hPlotAxes, 3 ); - if ~isempty( tsg.SPDC ) - plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.SPDC,[],... - 'SPDC','k','none','*',2); + if ~isempty( tsg.(PARA) ) + plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD, tsg.(PARA),[],... + PARA,'k','none','*',2); end end diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m index aa92df76b79899698d0fa07116e59154459683cb..c0676389cf489096a64f565dc7d1b1ccd641dc38 100644 --- a/tsg_util/tsg_initialisation.m +++ b/tsg_util/tsg_initialisation.m @@ -21,7 +21,7 @@ set( hMainFig, 'WindowButtonMotionFcn', []); tsg = getappdata( hMainFig, 'tsg_data' ); oldPara = []; if ~isempty( tsg ) - oldPara = tsg.preference.parameter; + oldPara = tsg.preference.parameter{1}; end % init empty tsg structure @@ -211,9 +211,9 @@ tsg.REFERENCE_DATE_TIME = REFERENCE_DATE_TIME; % ------------------------------------- tsg.preference.autoload = 'off'; if ~isempty(oldPara) - tsg.preference.parameter = oldPara; + tsg.preference.parameter{1} = oldPara; else - tsg.preference.parameter = 'SSPS'; + tsg.preference.parameter{1} = 'SSPS'; end % Save tsg structure diff --git a/tsg_util/tsg_mergesample.m b/tsg_util/tsg_mergesample.m index 9deaeac520d75bb3369ae6c3f4b0459d32653de4..b1c6faa82eeaab8ea35093ae492de092417ed95a 100644 --- a/tsg_util/tsg_mergesample.m +++ b/tsg_util/tsg_mergesample.m @@ -1,143 +1,145 @@ -function [] = tsg_mergesample( hTsgGUI, PARA ) +function [] = tsg_mergesample_B( hMainFig ) % -% function [] = tsg_mergesample( hTsgGUI ) +% function [] = tsg_mergesample( hMainFig ) % -% Merge the 2 types of 'bucket' records, if they exists +% Merge the 2 types of 'bucket' records % % Input -% _WS ........ Water sample -% _EXT ....... External samples (ARGO, CTD, etc.) % % Ouptut % +% Sample of type WS only have SSPS parameter +% Sample of type EXT may have SSPS and SSTP parameters. +% +% When WS and EXT parameters are merge I must create a fake SSTP variable +% for WS type. +% % Get bucket data in ASCII or NETCDF format. If the data does not exist % getappdata return an empty matrix % --------------------------------------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); +tsg = getappdata( hMainFig, 'tsg_data'); % Get NO_CONTROL code value % ------------------------- NO_CONTROL = get(tsg.qc.hash, 'NO_CONTROL', 'code'); -% 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 equal to the SSTP sample structure -% --------------------------------------------------------------- -PARA_OLD = PARA; -if strcmp( PARA, 'SSJT' ) - PARA_OLD = PARA; - PARA = 'SSTP'; -end - -% Create a structure with an NaN +% Create a temporary structure with one NaN % No other solution as I can't add a structure to an empty one % ------------------------------------------------------------ -sample = struct('DAYD',NaN , 'LATX',NaN , 'LONX',NaN , ... - 'X',NaN , 'X_QC',NaN , 'X_DIF',NaN ,... - 'X_SMOOTH',NaN , 'X_TYPE', 'UNKN', 'X_INDICE', NaN); +sample = struct('DAYD', NaN, 'LATX', NaN, 'LONX', NaN, ... + 'SSPS', NaN, 'SSPS_QC', NaN, 'SSPS_TYPE', 'UNKN',... + 'SSTP', NaN, 'SSTP_QC', NaN, 'SSTP_TYPE', 'UNKN', ... + 'INDICE', NaN ); % Fill the structure sample with the bucket data. % WS exist only for SSPS -% This measurements are of TYPE 1 % ------------------------------------------------ -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.X = [sample.X; tsg.([PARA '_WS']) ]; - if ~isempty(tsg.([PARA '_WS_QC'])) - sample.X_QC = [sample.X_QC; tsg.([PARA '_WS_QC']) ]; +if ~isempty( tsg.DAYD_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]; + sample.SSTP = [sample.SSTP; NaN*ones(size(tsg.DAYD_WS)) ]; + + if ~isempty(tsg.SSPS_WS_QC) + sample.SSPS_QC = [int8(sample.SSPS_QC); tsg.SSPS_WS_QC ]; else - sample.X_QC = [sample.X_QC; NO_CONTROL * ones(size(tsg.DAYD_WS))]; + sample.SSPS_QC = [int8(sample.SSPS_QC); ... + NO_CONTROL*int8(ones(size(tsg.DAYD_WS)))]; end - - % Fill the structure with NaN. NaN is tested in diffTsgSample - % ----------------------------------------------------------- - sample.X_DIF = [sample.X_DIF; NaN*ones(size(tsg.DAYD_WS))]; - sample.X_SMOOTH = [sample.X_SMOOTH; NaN*ones(size(tsg.DAYD_WS))]; + sample.SSTP_QC = [int8(sample.SSTP_QC); ... + NO_CONTROL*int8(ones(size(tsg.DAYD_WS)))]; % INDICE is used to put back the QC once the validation procedure has % been applied % ------------------------------------------------------------------- - sample.X_INDICE = [sample.X_INDICE; [1:length(tsg.DAYD_WS)]']; + sample.INDICE = [sample.INDICE; [1:length(tsg.DAYD_WS)]']; -% % Used for the plots : WS are given a type 1 -% % ------------------------------------------ -% sample.X_TYPE = [sample.X_TYPE; ones(size(tsg.DAYD_WS))]; - + % Type Used for the plots : type WS + % ----------------------------- label = 'WS '; m = length(tsg.DAYD_WS); - sample.X_TYPE = strvcat( sample.X_TYPE, label( ones(m,1), :) ); - + sample.SSPS_TYPE = strvcat( sample.SSPS_TYPE, label( ones(m,1), :) ); + sample.SSTP_TYPE = strvcat( sample.SSTP_TYPE, label( ones(m,1), :) ); + end % Fill the structure sample with the external sample % This measurements are of TYPE 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.X = [sample.X; tsg.([PARA '_EXT'])]; - if ~isempty(tsg.([PARA '_EXT_QC'])) - sample.X_QC = [sample.X_QC; tsg.([PARA '_EXT_QC'])]; - else - sample.X_QC = [sample.X_QC; NO_CONTROL * ones(size(sample.DAYD_EXT))]; - end - - % Fill the following structures with NaN. NaN is test in diffTsgSample - % -------------------------------------------------------------------- - sample.X_DIF = [sample.X_DIF; NaN*ones(size(tsg.DAYD_EXT))]; - sample.X_SMOOTH = [sample.X_SMOOTH; NaN*ones(size(tsg.DAYD_EXT))]; - -% % Used for the plots : EXT sample are given a type 2 -% % -------------------------------------------------- -% sample.X_TYPE = [sample.X_TYPE; 2*ones(size(tsg.DAYD_EXT))]; - -if isempty( tsg.([PARA '_EXT_TYPE']) ) - m = length(tsg.DAYD_EXT); - label = 'UNKN'; - sample.X_TYPE = strvcat( sample.X_TYPE, label( ones(m,1), :) ); -else - sample.X_TYPE = strvcat( sample.X_TYPE, tsg.([PARA '_EXT_TYPE']) ); -end +if ~isempty(tsg.DAYD_EXT) + + sample.DAYD = [sample.DAYD; tsg.DAYD_EXT]; + sample.LATX = [sample.LATX; tsg.LATX_EXT]; + sample.LONX = [sample.LONX; tsg.LONX_EXT]; + para = { 'SSPS'; 'SSTP' }; + for i = 1 : 2 + PARA = para{i}; + + if ~isempty(tsg.([ PARA '_EXT'])) + sample.(PARA) = [sample.(PARA); tsg.([ PARA '_EXT']) ]; + else + sample.(PARA) = [sample.(PARA); NaN * ones( size(tsg.DAYD_EXT)) ]; + end + + if ~isempty(tsg.([ PARA '_EXT_QC'])) + sample.([PARA '_QC']) = [int8(sample.([PARA '_QC']));... + tsg.([PARA '_EXT_QC'])]; + else + sample.([PARA '_QC']) = [int8(sample.([PARA '_QC'])); ... + NO_CONTROL*int8(ones(size(tsg.DAYD_EXT)))]; + end + + m = length(tsg.DAYD_EXT); + if isempty( tsg.([ PARA '_EXT_TYPE']) ) + label = 'UNKN'; + sample.([ PARA '_TYPE']) = strvcat(sample.([PARA '_TYPE']), ... + label(ones(m,1),:) ); + else + sample.([ PARA '_TYPE']) = strvcat(sample.([ PARA '_TYPE']),... + tsg.SSPS_EXT_TYPE ); + end + end + % INDICE is used to put back the QC once the validation procedure has % been applied % ------------------------------------------------------------------- - sample.X_INDICE = [sample.X_INDICE; [1:length(tsg.DAYD_EXT)]']; + sample.INDICE = [sample.INDICE; [1:length(tsg.DAYD_EXT)]']; end % Eliminate the first element if NaN % ---------------------------------- if isnan(sample.DAYD(1)) - sample.DAYD(1) = []; - sample.LATX(1) = []; - sample.LONX(1) = []; - sample.X(1) = []; - sample.X_QC(1) = []; - sample.X_DIF(1) = []; - sample.X_SMOOTH(1) = []; - sample.X_TYPE(1,:) = []; - sample.X_INDICE(1) = []; + sample.DAYD(1) = []; + sample.LATX(1) = []; + sample.LONX(1) = []; + sample.SSPS(1) = []; + sample.SSPS_QC(1) = []; + sample.SSPS_TYPE(1,:) = []; + sample.SSTP(1) = []; + sample.SSTP_QC(1) = []; + sample.SSTP_TYPE(1,:) = []; + sample.INDICE(1) = []; end -% Sort the struct sample - increasing time. -% ----------------------------------------- if ~isempty(sample.DAYD) + + % Sort the struct sample - increasing time. + % ----------------------------------------- [sample.DAYD, iOrder] = sort(sample.DAYD); sample.LATX = sample.LATX(iOrder); sample.LONX = sample.LONX(iOrder); - sample.X = sample.X(iOrder); - sample.X_QC = sample.X_QC(iOrder); - sample.X_DIF = sample.X_DIF(iOrder); - sample.X_SMOOTH = sample.X_SMOOTH(iOrder); - sample.X_TYPE = sample.X_TYPE(iOrder,:); - sample.X_INDICE = sample.X_INDICE(iOrder); + sample.SSPS = sample.SSPS(iOrder); + sample.SSPS_QC = sample.SSPS_QC(iOrder); + sample.SSPS_TYPE = sample.SSPS_TYPE(iOrder,:); + sample.SSTP = sample.SSTP(iOrder); + sample.SSTP_QC = sample.SSTP_QC(iOrder); + sample.SSTP_TYPE = sample.SSTP_TYPE(iOrder,:); + sample.INDICE = sample.INDICE(iOrder); % Test if DAYD is strictly increasing % ----------------------------------- @@ -151,34 +153,38 @@ if ~isempty(sample.DAYD) % put the structure sample in the tsg structure % --------------------------------------------- if ~isempty( increasingInd ) - tsg.DAYD_SPL = sample.DAYD(increasingInd); - tsg.LATX_SPL = sample.LATX(increasingInd); - tsg.LONX_SPL = sample.LONX(increasingInd); - tsg.([PARA '_SPL']) = sample.X(increasingInd); - tsg.([PARA '_SPL_QC']) = int8( sample.X_QC(increasingInd) ); - tsg.([PARA '_SPL_DIF']) = sample.X_DIF(increasingInd); - tsg.([PARA '_SPL_SMOOTH']) = sample.X_SMOOTH(increasingInd); - tsg.([PARA '_SPL_TYPE']) = sample.X_TYPE(increasingInd, :); - tsg.([PARA '_SPL_INDICE']) = sample.X_INDICE(increasingInd); + tsg.DAYD_SPL = sample.DAYD(increasingInd); + tsg.LATX_SPL = sample.LATX(increasingInd); + tsg.LONX_SPL = sample.LONX(increasingInd); + tsg.INDICE_SPL = sample.INDICE(increasingInd); + + para = { 'SSPS'; 'SSTP' }; + for i = 1 : 2 + PARA = para{i}; + + tsg.([PARA '_SPL']) = sample.(PARA)(increasingInd); + tsg.([PARA '_SPL_QC']) = int8(sample.([PARA '_QC'])(increasingInd)); + tsg.([PARA '_SPL_TYPE']) = sample.([PARA '_TYPE'])(increasingInd,:); + + tsg.([PARA '_SPL_DIF']) = NaN * ones(size(tsg.DAYD_SPL)); + tsg.([PARA '_SPL_SMOOTH'])= NaN * ones(size(tsg.DAYD_SPL)); + end end - + end % There are only SSTP samples. The SSJT time series should % be compared to the SSTP samples. To simplify the soft we use a % variable SSJT sample equals to the SSTP sample structure % --------------------------------------------------------------- -if strcmp( PARA_OLD, 'SSJT' ) - if ~isempty( tsg.SSTP_SPL ) - 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 +if ~isempty( tsg.SSTP_SPL ) + 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; end % Update application data % ----------------------- -setappdata( hTsgGUI, 'tsg_data', tsg ); +setappdata( hMainFig, 'tsg_data', tsg ); diff --git a/tsg_util/tsg_mergesample_B.m b/tsg_util/tsg_mergesample_B.m deleted file mode 100644 index b1c6faa82eeaab8ea35093ae492de092417ed95a..0000000000000000000000000000000000000000 --- a/tsg_util/tsg_mergesample_B.m +++ /dev/null @@ -1,190 +0,0 @@ -function [] = tsg_mergesample_B( hMainFig ) -% -% function [] = tsg_mergesample( hMainFig ) -% -% Merge the 2 types of 'bucket' records -% -% Input -% -% Ouptut -% -% Sample of type WS only have SSPS parameter -% Sample of type EXT may have SSPS and SSTP parameters. -% -% When WS and EXT parameters are merge I must create a fake SSTP variable -% for WS type. -% - -% Get bucket data in ASCII or NETCDF format. If the data does not exist -% getappdata return an empty matrix -% --------------------------------------------------------------------- -tsg = getappdata( hMainFig, 'tsg_data'); - -% Get NO_CONTROL code value -% ------------------------- -NO_CONTROL = get(tsg.qc.hash, 'NO_CONTROL', 'code'); - -% Create a temporary structure with one 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_TYPE', 'UNKN',... - 'SSTP', NaN, 'SSTP_QC', NaN, 'SSTP_TYPE', 'UNKN', ... - 'INDICE', NaN ); - -% Fill the structure sample with the bucket data. -% WS exist only for SSPS -% ------------------------------------------------ -if ~isempty( tsg.DAYD_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]; - sample.SSTP = [sample.SSTP; NaN*ones(size(tsg.DAYD_WS)) ]; - - if ~isempty(tsg.SSPS_WS_QC) - sample.SSPS_QC = [int8(sample.SSPS_QC); tsg.SSPS_WS_QC ]; - else - sample.SSPS_QC = [int8(sample.SSPS_QC); ... - NO_CONTROL*int8(ones(size(tsg.DAYD_WS)))]; - end - sample.SSTP_QC = [int8(sample.SSTP_QC); ... - NO_CONTROL*int8(ones(size(tsg.DAYD_WS)))]; - - % INDICE is used to put back the QC once the validation procedure has - % been applied - % ------------------------------------------------------------------- - sample.INDICE = [sample.INDICE; [1:length(tsg.DAYD_WS)]']; - - % Type Used for the plots : type WS - % ----------------------------- - label = 'WS '; - m = length(tsg.DAYD_WS); - sample.SSPS_TYPE = strvcat( sample.SSPS_TYPE, label( ones(m,1), :) ); - sample.SSTP_TYPE = strvcat( sample.SSTP_TYPE, label( ones(m,1), :) ); - -end - -% Fill the structure sample with the external sample -% This measurements are of TYPE EXT -% -------------------------------------------------- -if ~isempty(tsg.DAYD_EXT) - - sample.DAYD = [sample.DAYD; tsg.DAYD_EXT]; - sample.LATX = [sample.LATX; tsg.LATX_EXT]; - sample.LONX = [sample.LONX; tsg.LONX_EXT]; - - para = { 'SSPS'; 'SSTP' }; - for i = 1 : 2 - PARA = para{i}; - - if ~isempty(tsg.([ PARA '_EXT'])) - sample.(PARA) = [sample.(PARA); tsg.([ PARA '_EXT']) ]; - else - sample.(PARA) = [sample.(PARA); NaN * ones( size(tsg.DAYD_EXT)) ]; - end - - if ~isempty(tsg.([ PARA '_EXT_QC'])) - sample.([PARA '_QC']) = [int8(sample.([PARA '_QC']));... - tsg.([PARA '_EXT_QC'])]; - else - sample.([PARA '_QC']) = [int8(sample.([PARA '_QC'])); ... - NO_CONTROL*int8(ones(size(tsg.DAYD_EXT)))]; - end - - m = length(tsg.DAYD_EXT); - if isempty( tsg.([ PARA '_EXT_TYPE']) ) - label = 'UNKN'; - sample.([ PARA '_TYPE']) = strvcat(sample.([PARA '_TYPE']), ... - label(ones(m,1),:) ); - else - sample.([ PARA '_TYPE']) = strvcat(sample.([ PARA '_TYPE']),... - tsg.SSPS_EXT_TYPE ); - end - end - - % INDICE is used to put back the QC once the validation procedure has - % been applied - % ------------------------------------------------------------------- - sample.INDICE = [sample.INDICE; [1:length(tsg.DAYD_EXT)]']; - -end - -% Eliminate the first element if NaN -% ---------------------------------- -if isnan(sample.DAYD(1)) - sample.DAYD(1) = []; - sample.LATX(1) = []; - sample.LONX(1) = []; - sample.SSPS(1) = []; - sample.SSPS_QC(1) = []; - sample.SSPS_TYPE(1,:) = []; - sample.SSTP(1) = []; - sample.SSTP_QC(1) = []; - sample.SSTP_TYPE(1,:) = []; - sample.INDICE(1) = []; -end - -if ~isempty(sample.DAYD) - - % Sort the struct sample - increasing time. - % ----------------------------------------- - [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_TYPE = sample.SSPS_TYPE(iOrder,:); - sample.SSTP = sample.SSTP(iOrder); - sample.SSTP_QC = sample.SSTP_QC(iOrder); - sample.SSTP_TYPE = sample.SSTP_TYPE(iOrder,:); - sample.INDICE = sample.INDICE(iOrder); - - % Test if DAYD is strictly increasing - % ----------------------------------- - increasingInd = 1:length(sample.DAYD); - diffDay = diff(sample.DAYD); - ind = find(diffDay == 0); - if ~isempty(ind) - increasingInd(ind) = []; - end - - % put the structure sample in the tsg structure - % --------------------------------------------- - if ~isempty( increasingInd ) - tsg.DAYD_SPL = sample.DAYD(increasingInd); - tsg.LATX_SPL = sample.LATX(increasingInd); - tsg.LONX_SPL = sample.LONX(increasingInd); - tsg.INDICE_SPL = sample.INDICE(increasingInd); - - para = { 'SSPS'; 'SSTP' }; - for i = 1 : 2 - PARA = para{i}; - - tsg.([PARA '_SPL']) = sample.(PARA)(increasingInd); - tsg.([PARA '_SPL_QC']) = int8(sample.([PARA '_QC'])(increasingInd)); - tsg.([PARA '_SPL_TYPE']) = sample.([PARA '_TYPE'])(increasingInd,:); - - tsg.([PARA '_SPL_DIF']) = NaN * ones(size(tsg.DAYD_SPL)); - tsg.([PARA '_SPL_SMOOTH'])= NaN * ones(size(tsg.DAYD_SPL)); - end - end - -end - -% There are only SSTP samples. The SSJT time series should -% be compared to the SSTP samples. To simplify the soft we use a -% variable SSJT sample equals to the SSTP sample structure -% --------------------------------------------------------------- -if ~isempty( tsg.SSTP_SPL ) - 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; -end - -% Update application data -% ----------------------- -setappdata( hMainFig, 'tsg_data', tsg ); diff --git a/tsgqc.m b/tsgqc.m index 6a1e7a815ee1b49474988582e88e81955db76d81..86d6a30656a979528014711185a32c6be30f3b95 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -772,25 +772,24 @@ hbgParameter = uibuttongroup(... 'BorderType', 'etchedin',... 'Units', 'normalized', 'Position', [.0, .78, .15, .18]); -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.15]); - -end +pmhPara(1) = uicontrol(... + 'Parent', hbgParameter, 'Style', 'popupmenu', ... + 'String', { 'NONE' }, 'Value', 1, ... + 'HandleVisibility', handleVisibility, ... + 'Callback', {@SelectParameter, 1}, ... + 'Units', 'normalized', 'Position', [.05, .7, .3, 0.25]); +pmhPara(2) = uicontrol(... + 'Parent', hbgParameter, 'Style', 'popupmenu', ... + 'String', { 'NONE' }, 'Value', 1, ... + 'HandleVisibility', handleVisibility, ... + 'Callback', {@SelectParameter, 2}, ... + 'Units', 'normalized', 'Position', [.05, .38, .3, 0.25]); +pmhPara(3) = uicontrol(... + 'Parent', hbgParameter, 'Style', 'popupmenu', ... + 'String', { 'NONE' }, 'Value', 1, ... + 'HandleVisibility', handleVisibility, ... + 'Callback', {@SelectParameter, 3}, ... + 'Units', 'normalized', 'Position', [.05, .05, .3, 0.25]); % Initialize CallBack for button group properties % ----------------------------------------------- @@ -1076,21 +1075,10 @@ if strcmp(tsg.preference.autoload, 'on') % Get application data for the test % --------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); - - % Get the default parameter - % ------------------------- - PARA = tsg.preference.parameter; - - % 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 % ------------------------------------------------ - tsg_mergesample_B( hMainFig ); + tsg_mergesample( hMainFig ); % Draw the 3 plots of the validation figure % The plots need to be re-initialize because of a bug with @@ -1112,11 +1100,16 @@ if strcmp(tsg.preference.autoload, 'on') 'box', 'on', 'Units', 'normalized', 'Tag', 'TAG_AXES_3', ... 'HandleVisibility','on', 'Position',[.05, .02, .93, .27]); + % Initialise the popupmenu displaying the parameters that can be + % plot + % -------------------------------------------------------------- + initParameterChoice( hMainFig, pmhPara ); + resetAxes( hMainFig, hPlotAxes ); - plot_Validation( hMainFig, hPlotAxes, 1, PARA ); - plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); - plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); + 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} ); % Draw the map with the ship track % -------------------------------- @@ -1246,10 +1239,6 @@ end % Get the tsg structure % --------------------- tsg = getappdata( hMainFig, 'tsg_data'); - - % Default parameter - % ----------------- - PARA = tsg.preference.parameter; % A TSG file has been read % ------------------------ @@ -1278,6 +1267,7 @@ end % update some fields in tsg structure and restore tsg % --------------------------------------------------- updateTsgStruct(hMainFig ); + tsg = getappdata( hMainFig, 'tsg_data'); % update the filename display % --------------------------- @@ -1291,6 +1281,12 @@ end % -------------------- display_QC( hMainFig, hPlotAxes); + % Initialise the popupmenu displaying the parameters that can be + % plot + % -------------------------------------------------------------- + initParameterChoice( hMainFig, pmhPara ); + tsg = getappdata( hMainFig, 'tsg_data'); + elseif errTsg > -2 % Problem to read the file or @@ -1307,7 +1303,7 @@ end % Merge sample from different origins : WS and EXT % ------------------------------------------------ - tsg_mergesample_B( hMainFig ); + tsg_mergesample( hMainFig ); % Draw the 3 plots of the validation figure % The plots need to be re-initialize because of a bug with @@ -1330,10 +1326,10 @@ end 'HandleVisibility','on', 'Position',[.05, .02, .93, .27]); resetAxes( hMainFig, hPlotAxes ) - - plot_Validation( hMainFig, hPlotAxes, 1, PARA ); - plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); - plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); + + 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 % ---------------------- @@ -1419,9 +1415,9 @@ end % Draw the 3 plots of the validation figure % ----------------------------------------- - plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter ); - plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); - plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); + 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} ); % Set the pointer % --------------- @@ -1592,9 +1588,9 @@ end % Draw the 3 plots of the validation figure % ----------------------------------------- - plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter ); - plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); - plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); + 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 @@ -1806,7 +1802,7 @@ end %---------------------------------------------------------------------- function QC_OnMenuCallback(gcbo, eventdata) - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; % Make the QC code uipanel visible % -------------------------------- @@ -2007,7 +2003,7 @@ end % Get the parameter (SSPS, SSJT or SSTP) % -------------------------------------- - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; % get key and some values in hashtable % ------------------------------------ @@ -2102,75 +2098,6 @@ 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'); - set( hClimToggletool, '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 @@ -2370,7 +2297,7 @@ end % Get the parameter we are working on (SSPS, SSJT, SSTP) % ------------------------------------------------------ - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; % Switch somme buttons % -------------------- @@ -2450,13 +2377,13 @@ end % Get the parameter (SSPS, SSJT, SSTP) % ------------------------------------ - PARA = tsg.preference.parameter; + % PARA = tsg.preference.parameter; % Draw the 3 plots of the validation figure % ----------------------------------------- - plot_Validation( hMainFig, hPlotAxes, 1, PARA ); - plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' ); - plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' ); + 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} ); % Set the pointer % --------------- @@ -2481,7 +2408,7 @@ end % Get parameter we are working on (SSPS, SSJT, SSTP) % -------------------------------------------------- - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; % To cancel the correction set the ERROR to [] then % call updateAdjustedVariable. @@ -2522,7 +2449,7 @@ end % Get the parameter (SSPS, SSJT, or SSTP) % --------------------------------------- tsg = getappdata(hMainFig, 'tsg_data'); - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; if ~isempty( tsg.([PARA '_SPL']) ) @@ -2570,7 +2497,7 @@ end % Get the parameter (SSPS, SSJT, or SSTP) % --------------------------------------- tsg = getappdata(hMainFig, 'tsg_data'); - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; if ~isempty( tsg.([PARA '_SPL']) ) @@ -2596,9 +2523,56 @@ end end end - end +%% PopupMenu Select Parameter +% --------------------------- + function SelectParameter(hObject, eventdata, nplot) + % Callback function run when the .... + + % Get application data + % -------------------- + tsg = getappdata( hMainFig, 'tsg_data'); + + % Get the active string of the selected box + % ----------------------------------------- + val = get( hObject, 'Value' ); + string_list = get( hObject, 'String' ); + selected_string = string_list{val}; + + % Get the default parameter + % ------------------------- + tsg.preference.parameter{nplot} = selected_string; + + % Save application data + % -------------------- + setappdata( hMainFig, 'tsg_data', tsg); + + % Disable the climatology + % ----------------------- + plotClim = 0; + if strcmp( get(hClimToggletool, 'state'), 'on' ) + set( hClimToggletool, 'state', 'off' ); + plotClim = 1; + end + + % Disable the climatology + % ----------------------- + set( hClimToggletool, 'state', 'off' ); + + 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} ); + + % Plot the climatology if it was already plotted + % ---------------------------------------------- + if plotClim + set( hClimToggletool, 'state', 'on' ); + plot_ClimatologyB(hMainFig, hPlotAxes); + end + + end + %% SelectTime_OnMenuCallback %--------------------------- function SelectTime_OnMenuCallback(hObject, eventdata) @@ -2813,7 +2787,7 @@ end % Default parameter % ----------------- - PARA = tsg.preference.parameter; + PARA = tsg.preference.parameter{1}; hPrintFig = figure( 'Name', 'Print','NumberTitle', 'off','Resize', 'on'); hPlot(1) = subplot(3,1,1); @@ -2834,9 +2808,9 @@ end plot_Interpolation( hMainFig, hPlot, 2 ); plot_Interpolation( hMainFig, hPlot, 3 ); else - plot_Validation( hMainFig, hPlot, 1, PARA ); - plot_Validation( hMainFig, hPlot, 2, 'SSJT' ); - plot_Validation( hMainFig, hPlot, 3, 'SPDC' ); + 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} ); % I = getframe(hPlotAxes(1)); % imwrite(I.cdata, 'myplot.png');