From 85eb74eefd33f1d963a68952756adf8ea13ba177 Mon Sep 17 00:00:00 2001 From: Yves Gouriou <yves.gouriou@ird.fr> Date: Wed, 13 Feb 2008 18:02:17 +0000 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20des=20modules=20de=20correc?= =?UTF-8?q?tion.=20Modification=20du=20trac=C3=A9=20de=20la=20carte=20pour?= =?UTF-8?q?=20s'adapter=20aux=20limites=20de=20la=20s=C3=A9rie=20temporell?= =?UTF-8?q?e=20visible=20=C3=A0=20l'=C3=A9cran?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Desactivation du module PREFERENCE qui bugue --- tsg_util/corTsgLinear.m | 143 +++++++++++++------------------------ tsg_util/corTsgMedian.m | 80 ++++++++++++++------- tsg_util/plot_Sample.m | 6 +- tsg_util/plot_Tsg.m | 7 +- tsg_util/plot_map.m | 30 ++++++-- tsg_util/tsg_preferences.m | 3 +- tsgqc_GUI.m | 106 ++++++++++++++++++++------- 7 files changed, 212 insertions(+), 163 deletions(-) diff --git a/tsg_util/corTsgLinear.m b/tsg_util/corTsgLinear.m index 901db14..d1a9fc2 100644 --- a/tsg_util/corTsgLinear.m +++ b/tsg_util/corTsgLinear.m @@ -1,8 +1,6 @@ function [error] = corTsgLinear(hMainFig, dateMin, dateMax) -% % Correct the TSG salinity time series with the Water sample. -% Use the median value of TIME_WINDOWS water sample to compute the -% correction. see the documentation +% Use a linear fit to the water sample/tsg difference % % Input % hMainFig ..... Handle to the main GUI @@ -12,119 +10,73 @@ function [error] = corTsgLinear(hMainFig, dateMin, dateMax) % Output % Error ........ 1 everything OK % ........ -1 dateMax <= date Min -% -% TO DO -% corTsgMethod1.m -% 1) Test if there are NaN values in 'sample': -% We could get some problem with the computation of the median and std -% 2) Initialisation de la structure 'cor' -% 3) Test for anormal sample-tsg difference - Suppress bad points -% 4) Test on the validation code. do we apply the correction whatever the -% is the code ? -% 5) Return an Error code ? -% 6) Test Date_Min < Date_Max % Get application data % -------------------- tsg = getappdata( hMainFig, 'tsg_data'); sample = getappdata( hMainFig, 'sample'); -% Shorten the variable name -% ------------------------- -TIME_WINDOWS = tsg.cst.COR_TIME_WINDOWS; - -% Get PROBABLY_GOOD and VALUE_CHANGED code -% ---------------------------------------- +% 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'); VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code'); -% The correction is computed between dateMin and dateMax -% ------------------------------------------------------ -dt = find(sample.DAYD >= dateMin & sample.DAYD <= dateMax); - if dateMax > dateMin - - % Create a structure with an NaN - % No other solution as I can't add a structure to an empty one - % ------------------------------------------------------------ - cor = struct('DAYD', NaN, 'DIFF', NaN, 'ERROR', NaN, 'NVALUE', NaN); - - % -------------------- - for i = 1 : length(dt) - - % Find the sample within TIME_WINDOWS with Good and probably Good QC - % ------------------------------------------------------------------ - ind = find( sample.DAYD(dt) >= sample.DAYD(dt(i)) - TIME_WINDOWS/2 &... - sample.DAYD(dt) <= sample.DAYD(dt(i)) + TIME_WINDOWS/2 &... - sample.SSPS_QC(dt) <= PROBABLY_GOOD); - - end - % Eliminate the first element if NaN - % ---------------------------------- - if isnan(cor.DAYD(1)) - cor.DAYD(1) = []; - cor.DIFF(1) = []; - cor.ERROR(1) = []; - cor.NVALUE(1) = []; - end - - if ~isempty( cor.DAYD ) - - % The error is maximum if the median is computed with less than 4 samples - % ----------------------------------------------------------------------- - cor.ERROR( cor.NVALUE < 4 ) = 1; - - % The correction is applied between dateMin and dateMax - % We attribute to dateMin the first correction computed - % and to dateMax the last one - % - % Find the tsg date in the interval dateMin-dateMax - % ------------------------------------------------- - dtTsg = find(tsg.DAYD >= dateMin & tsg.DAYD <= dateMax); - - if cor.DAYD(1) ~= dateMin - cor.DAYD = [tsg.DAYD(dtTsg(1)) cor.DAYD]; - cor.DIFF = [cor.DIFF(1) cor.DIFF]; - cor.ERROR = [cor.ERROR(1) cor.ERROR]; - cor.NVALUE = [cor.NVALUE(1) cor.NVALUE]; - end - if cor.DAYD(end) ~= dateMax - cor.DAYD = [cor.DAYD tsg.DAYD(dtTsg(end))]; - cor.DIFF = [cor.DIFF cor.DIFF(end)]; - cor.ERROR = [cor.ERROR cor.ERROR(end)]; - cor.NVALUE = [cor.NVALUE cor.NVALUE(end)]; + % Find samples within TIME_WINDOWS with Good and probably Good QC + % --------------------------------------------------------------- + ind = find( sample.DAYD >= dateMin & sample.DAYD <= dateMax &... + sample.SSPS_QC <= PROBABLY_GOOD); + + if ~isempty(ind) + + % detect NaN in sample.SSPS_DIF due to bad QC code for tsg.SSPS + % ------------------------------------------------------------- + ind2 = find(~isnan(sample.SSPS_DIF(ind))); + + % Compute linear fit of the TSG/SAMPLE difference + % ----------------------------------------------- + if ~isempty(sample.SSPS_DIF(ind(ind2))) + + X = sample.DAYD(ind(ind2)); + Y = sample.SSPS_DIF(ind(ind2)); + + [p, S, mu] = polyfit( X, Y, 1); + + % The correction is applied to the TSG between dateMin and dateMax using + % a linear interpolation only on measurements with GOOD and + % PROBABLY_GOOD QC + % ---------------------------------------------------------------------- + dtTsg = find( tsg.DAYD >= dateMin & tsg.DAYD <= dateMax &... + tsg.SSPS_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); + + % VALUE_CHANGED code + % ------------------ + tsg.SSPS_ADJUSTED_QC(dtTsg) = VALUE_CHANGED; end - p = polyfit( x, y, 1); - y = polyval(p,x); - - % The correction is applied to the TSG between dateMin and dateMax using - % a linear interpolation - % ---------------------------------------------------------------------- - tsg.SSPS_ADJUSTED(dtTsg) = tsg.SSPS(dtTsg) + ... - interp1(cor.DAYD, cor.DIFF, tsg.DAYD(dtTsg)); - tsg.SSPS_ADJUSTED_ERROR(dtTsg) = ... - interp1(cor.DAYD, cor.ERROR, tsg.DAYD(dtTsg)); - - tsg.SSPS_ADJUSTED_QC(dtTsg) = VALUE_CHANGED; - else % RAZ if no correction % -------------------- - dt = find(tsg.DAYD >= dateMin & tsg.DAYD <= dateMax); + dtTsg = find(tsg.DAYD >= dateMin & tsg.DAYD <= dateMax); + + tsg.SSPS_ADJUSTED(dtTsg) = NaN*ones(size(tsg.SSPS(dt))); + tsg.SSPS_ADJUSTED_ERROR(dtTsg) = NaN*ones(size(tsg.SSPS(dt))); + tsg.SSPS_ADJUSTED_QC(dtTsg) = zeros(size(tsg.SSPS(dt))); - tsg.SSPS_ADJUSTED(dt) = NaN*ones(size(tsg.SSPS(dt))); - tsg.SSPS_ADJUSTED_ERROR(dt) = NaN*ones(size(tsg.SSPS(dt))); - tsg.SSPS_ADJUSTED_QC(dt) = zeros(size(tsg.SSPS(dt))); - end - + % Update tsg application data % --------------------------- setappdata( hMainFig, 'tsg_data', tsg); - + setappdata( hMainFig, 'sample', sample); + % everything OK % ------------- error = 1; @@ -134,6 +86,7 @@ else % DateMax <= DateMin % ------------------ error = -1; - + end + diff --git a/tsg_util/corTsgMedian.m b/tsg_util/corTsgMedian.m index dabf0cb..e3c0c73 100644 --- a/tsg_util/corTsgMedian.m +++ b/tsg_util/corTsgMedian.m @@ -15,16 +15,9 @@ function [error] = corTsgMedian(hMainFig, dateMin, dateMax) % % TO DO % corTsgMethod1.m -% 1) Test if there are NaN values in 'sample': -% We could get some problem with the computation of the median and std -% 2) Initialisation de la structure 'cor' % 3) Test for anormal sample-tsg difference - Suppress bad points % 4) Test on the validation code. do we apply the correction whatever the % is the code ? -% 5) Return an Error code ? -% 6) Test Date_Min < Date_Max -% 7) BUG : Le nombre d'elements est faux si il y a des NaN - % Get application data % -------------------- @@ -35,41 +28,69 @@ sample = getappdata( hMainFig, 'sample'); % ------------------------- TIME_WINDOWS = tsg.cst.COR_TIME_WINDOWS; -% Get PROBABLY_GOOD code -% ---------------------- +% 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'); VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code'); % Create a structure with an NaN -% No other solution as I can't add a structure to an empty one -% ------------------------------------------------------------ +% No other solution, as I can't add a structure to an empty one +% ------------------------------------------------------------- cor = struct('DAYD', NaN, 'DIFF', NaN, 'ERROR', NaN, 'NVALUE', NaN); if dateMax > dateMin + % Find the number of samples within the time limits. + % -------------------------------------------------- indSample = find(sample.DAYD >= dateMin & sample.DAYD <= dateMax); indCor = 0; for i=1:length(indSample) - % Find the sample within TIME_WINDOWS with Good and probably Good QC - % ------------------------------------------------------------------ + % Find samples within TIME_WINDOWS with Good and probably Good QC + % --------------------------------------------------------------- ind = find( sample.DAYD >= (sample.DAYD(i) - TIME_WINDOWS/2) &... sample.DAYD <= (sample.DAYD(i) + TIME_WINDOWS/2) &... sample.SSPS_QC <= PROBABLY_GOOD); - - % Compute the median difference and error within TIME_WINDOWS - % ----------------------------------------------------------- + if ~isempty(ind) - indCor = indCor + 1; - cor.DAYD(indCor) = sample.DAYD(i); - cor.DIFF(indCor) = nanmedian(sample.SSPS_DIF(ind)); - cor.ERROR(indCor) = nanstd(sample.SSPS_DIF(ind))/sqrt(length(ind)); - % BUG : Le nombre d'element est faux si il y a des NaN - cor.NVALUE(indCor) = length(ind); + % detect NaN in sample.SSPS_DIF due to bad QC code in tsg.SSPS + % ------------------------------------------------------------ + ind2 = find(~isnan(sample.SSPS_DIF(ind))); + + % Compute the median difference and error within TIME_WINDOWS + % ----------------------------------------------------------- + if ~isempty(sample.SSPS_DIF(ind(ind2))) + + A = sample.SSPS_DIF(ind(ind2)); + meanA = mean(A); + stdA = std(A); + + % Standard deviation test: keep these values + % ------------------------------------------ + ind3 = find( A >= meanA-3*stdA & A <= meanA+3*stdA); + + B = sample.SSPS_DIF(ind(ind2(ind3))); + if ~isempty( B ) + indCor = indCor + 1; + cor.DAYD(indCor) = sample.DAYD(i); + cor.DIFF(indCor) = median(B); + cor.ERROR(indCor) = nanstd(B)/sqrt(length(B)); + cor.NVALUE(indCor) = length(B); + end + + % Standard deviation test: don't keep these values + % QC PROBABLY_BAD + % ------------------------------------------------------ + ind4 = find( A < meanA-3*stdA | A > meanA+3*stdA); + if ~isempty( ind4 ) + sample.SSPS_QC(ind(ind2(ind4))) = PROBABLY_BAD; + end + + end end - end % Eliminate the first element if NaN @@ -93,7 +114,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]; @@ -109,15 +130,19 @@ if dateMax > dateMin end % The correction is applied to the TSG between dateMin and dateMax using - % a linear interpolation + % a linear interpolation only on measurements with GOOD and + % PROBABLY_GOOD QC % ---------------------------------------------------------------------- + dtTsg = find( tsg.DAYD >= dateMin & tsg.DAYD <= dateMax &... + tsg.SSPS_QC <= PROBABLY_GOOD); + tsg.SSPS_ADJUSTED(dtTsg) = tsg.SSPS(dtTsg) + ... interp1(cor.DAYD, cor.DIFF, tsg.DAYD(dtTsg)); tsg.SSPS_ADJUSTED_ERROR(dtTsg) = ... interp1(cor.DAYD, cor.ERROR, tsg.DAYD(dtTsg)); - % Get PROBABLY_GOOD code - % ---------------------- + % VALUE_CHANGED code + % ------------------ tsg.SSPS_ADJUSTED_QC(dtTsg) = VALUE_CHANGED; else @@ -135,6 +160,7 @@ if dateMax > dateMin % Update tsg application data % --------------------------- setappdata( hMainFig, 'tsg_data', tsg); + setappdata( hMainFig, 'sample', sample); % everything OK % ------------- diff --git a/tsg_util/plot_Sample.m b/tsg_util/plot_Sample.m index 238175d..4f429aa 100644 --- a/tsg_util/plot_Sample.m +++ b/tsg_util/plot_Sample.m @@ -62,7 +62,7 @@ if isempty(MyColor) line( sample.DAYD(ind), sample.(Para)(ind), ... 'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para '_' key],... 'LineStyle', 'none',... - 'Marker', 'square', 'MarkerSize', 3,... + 'Marker', 'square', 'MarkerSize', 5,... 'MarkerEdgeColor', 'k', 'MarkerFaceColor', color); end @@ -73,10 +73,8 @@ else line( sample.DAYD, sample.(Para),... 'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para],... - 'LineStyle', 'none',... - 'Marker', 'square', 'MarkerSize', 3,... + 'LineStyle', 'none', 'Marker', 'square', 'MarkerSize', 5,... 'MarkerEdgeColor', MyColor, 'MarkerFaceColor', MyColor); - end hold off; diff --git a/tsg_util/plot_Tsg.m b/tsg_util/plot_Tsg.m index 608fc8f..6defc76 100644 --- a/tsg_util/plot_Tsg.m +++ b/tsg_util/plot_Tsg.m @@ -80,9 +80,10 @@ if ~isempty( tsg.(Para) ) end else - line( tsg.DAYD, tsg.(Para),'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para], ... - 'LineStyle', Style, ... - 'Marker', Mark, 'MarkerSize', 5, 'Color', MyColor); + + line(tsg.DAYD, tsg.(Para),... + 'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para], ... + 'LineStyle', Style,'Marker', Mark, 'MarkerSize', 5, 'Color', MyColor); end hold off; diff --git a/tsg_util/plot_map.m b/tsg_util/plot_map.m index 81369bb..e8e087a 100644 --- a/tsg_util/plot_map.m +++ b/tsg_util/plot_map.m @@ -1,4 +1,4 @@ -function plot_map(hTsgGUI, hAxes) +function plot_map(hTsgGUI, hPlotAxes) % Function to plot the earth map and ship trackline % % Input @@ -20,13 +20,28 @@ function plot_map(hTsgGUI, hAxes) % ------------------------------- tsg = getappdata( hTsgGUI, 'tsg_data'); +% Get the Geographic limit of the TSG time series +% ----------------------------------------------- +dateLim = get(hPlotAxes(1), 'Xlim'); +ind = find( tsg.DAYD >= dateLim(1) & tsg.DAYD <= dateLim(2)); +latMin = min( tsg.LATX(ind) ); +latMax = max( tsg.LATX(ind) ); +lonMin = min( tsg.LONX(ind) ); +lonMax = max( tsg.LONX(ind) ); + % Positionning the right axes % ---------------------------- -axes(hAxes(4)); +axes(hPlotAxes(4)); + +%hLines = get( hPlotAxes(4), 'Children' ); +%if ~isempty( hLines ) +% delete(hLines); +%end % Use of Mercator projection % -------------------------- -m_proj('Mercator','lat',[-70 70],'long',[-180 180]); +%m_proj('Mercator','lat',[-70 70],'long',[-180 180]); +m_proj('Mercator','lat',[latMin latMax],'long',[lonMin lonMax]); % detailed coast lines % m_gshhs_i('patch',[.7 .7 .7]); @@ -38,10 +53,11 @@ m_proj('Mercator','lat',[-70 70],'long',[-180 180]); % ---------------------------- m_coast('patch',[.7 .7 .7]); -m_grid('box','fancy','tickdir','in', ... - 'ytick', [-70:20:70],... - 'xtick', [-180:40:180],... - 'Fontsize', [10]); +%m_grid('box','fancy','tickdir','in', ... +% 'ytick', [-70:20:70],... +% 'xtick', [-180:40:180],... +% 'Fontsize', [10]); +m_grid('box','fancy','tickdir','in', 'Fontsize', [10]); % Plot the ship track - Check if LAT-LON in deg-decimal % ----------------------------------------------------- diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m index 82ced8e..bbbb227 100644 --- a/tsg_util/tsg_preferences.m +++ b/tsg_util/tsg_preferences.m @@ -28,7 +28,8 @@ config_file = [prefdir, filesep, app_name, '.mat']; % Open config file % ---------------- -config = fopen( config_file, 'r' ); +%config = fopen( config_file, 'r' ); +config = -1; % test fopen return value % ----------------------- diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index 2186fcb..d250547 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -662,7 +662,7 @@ hrbCorCancel = uicontrol( ... 'FontSize',tsg.fontSize-1,... 'Tag', 'CORRECT_CANCEL_PUSH', ... 'Enable', 'off',... - 'pos',[.05 .68 .9 .25], ... + 'pos',[.05 .08 .9 .25],... 'HandleVisibility','callback', ... 'Callback', @CorCancelCallback); hrbCorLinear = uicontrol( ... @@ -684,7 +684,7 @@ hrbCorMedian = uicontrol( ... 'FontSize',tsg.fontSize-1,... 'Tag', 'CORRECT_MEDIAN_PUSH', ... 'Enable', 'off',... - 'pos',[.05 .08 .9 .25],... + 'pos',[.05 .68 .9 .25], ... 'HandleVisibility','callback', ... 'Callback', @CorMedianCallback); @@ -893,7 +893,11 @@ end % Plot the Map with the ship trackline % ------------------------------------ - plot_map( hMainFig, hPlotAxes) + % plot_map( hMainFig, hPlotAxes) + + % Update QC statistics + % -------------------- + display_QC( hMainFig, hPlotAxes) end end @@ -1291,7 +1295,7 @@ end y = a(2,2); % Code to Activate the PAN function when QC mode is active - % A PAN zone is defined in the bottom (5%) of PlotAxes(1) + % A PAN zone is defined in the bottom (10%) of PlotAxes(1) % 2 callback are needed : % 1 - one to desactivate QC when Pan is set to on. % 2 - one to reactivate QC once the pan has been used. @@ -1304,9 +1308,9 @@ end % Suppose that Y axes is increasing from the bottom to the top % ------------------------------------------------------------ - limy2 = limy(1) + (limy(2)-limy(1)) * 0.05; + limy2 = limy(1) + (limy(2)-limy(1)) * 0.10; - if x > limx(1) && x < limx(2) && y <= limy2 + if x > limx(1) && x < limx(2) && y <= limy2 && y >= limy(1) hPan = pan(hMainFig); set(hPan,'ActionPreCallback', @preQcPanCallback); set(hPan,'ActionPostCallback', @postQcPanCallback); @@ -1381,7 +1385,13 @@ end % --------------------------------------- set(hZoomToggletool, 'state', 'off' ); set(hPanToggletool, 'state', 'off' ); - + + if ~isempty( get(hMapPanel, 'UserData')) + delete(get(hMapPanel, 'UserData')); + end + + plot_map( hMainFig, hPlotAxes) + % Make the earth map visible % -------------------------- set(hMapPanel, 'Visible', 'on' ); @@ -1597,6 +1607,14 @@ end 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( hStartlimitToggletool, 'State', 'off' ); + set( hEndlimitToggletool, 'State', 'off' ); + tsg = getappdata(hMainFig, 'tsg_data'); tsg.SSPS_ADJUSTED = NaN*ones(size(tsg.SSPS)); @@ -1616,13 +1634,21 @@ end %% CorLinearCallback .................................... Correction Module function CorLinearCallback(hObject, eventdata) - % Callback function run when - + % Callback function run when + + % Desactivate somme Toggle button + % ------------------------------- + set( hZoomToggletool, 'state', 'off' ); + set( hPanToggletool, 'state', 'off' ); + set( hQCToggletool, 'state', 'off' ); + set( hStartlimitToggletool, 'State', 'off' ); + set( hEndlimitToggletool, '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'); - + % Compute the sample-TSG differences % ---------------------------------- diffTsgSample( hMainFig ); @@ -1630,11 +1656,11 @@ end % Correction % ---------- error = corTsgLinear(hMainFig, dateMin, dateMax); - + switch error case 1 - + % Reinitialise plot 2 and 3 % ------------------------- erase_Line( hPlotAxes(2), 2 ) @@ -1646,19 +1672,28 @@ end % ---------------------------------------- plot_Tsg( hMainFig, hPlotAxes(3), 3, 'SSPS_ADJUSTED', 0, 'r' ); + tsg = getappdata( hMainFig, 'tsg_data'); + % Plot the difference tsg.SSPS_ADJUSTED-tsg.SSPS on axe 2 % ------------------------------------------------------- axes( hPlotAxes(2) ); - tsg = getappdata( hMainFig, 'tsg_data'); line( tsg.DAYD, tsg.SSPS_ADJUSTED-tsg.SSPS,... - 'Tag', 'TAG_PLOT2_LINE_TSGDIF', 'Color', 'b'); - + 'Tag', 'TAG_PLOT2_LINE_TSGDIF', 'Color', 'b'); + + % Plot TSG + ERROR on axe 3 + % ------------------------- + errorPlus = tsg.SSPS_ADJUSTED + tsg.SSPS_ADJUSTED_ERROR; + errorMinus = tsg.SSPS_ADJUSTED - tsg.SSPS_ADJUSTED_ERROR; + axes( hPlotAxes(3) ); + line( tsg.DAYD, errorPlus,... + 'Tag', 'TAG_PLOT3_LINE_TSGERROR_PLUS', 'Color', 'g'); + line( tsg.DAYD, errorMinus,... + 'Tag', 'TAG_PLOT3_LINE_TSGERROR_MINUS', 'Color', 'g'); + case -1 msgbox( 'Date limits are not correct',... - 'Correction module', 'warn', 'modal'); + 'Correction module', 'warn', 'modal'); end - - msgbox('Method not yet implemented', 'modal' ); end @@ -1666,11 +1701,19 @@ end function CorMedianCallback(hObject, eventdata) % Callback function run when + % Desactivate somme Toggle button + % ------------------------------- + set( hZoomToggletool, 'state', 'off' ); + set( hPanToggletool, 'state', 'off' ); + set( hQCToggletool, 'state', 'off' ); + set( hStartlimitToggletool, 'State', 'off' ); + set( hEndlimitToggletool, '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'); - + % Compute the sample-TSG differences % ---------------------------------- diffTsgSample( hMainFig ); @@ -1678,11 +1721,11 @@ end % Correction % ---------- error = corTsgMedian(hMainFig, dateMin, dateMax); - + switch error case 1 - + % Reinitialise plot 2 and 3 % ------------------------- erase_Line( hPlotAxes(2), 2 ) @@ -1694,18 +1737,29 @@ end % ---------------------------------------- plot_Tsg( hMainFig, hPlotAxes(3), 3, 'SSPS_ADJUSTED', 0, 'r' ); + tsg = getappdata( hMainFig, 'tsg_data'); + % Plot the difference tsg.SSPS_ADJUSTED-tsg.SSPS on axe 2 % ------------------------------------------------------- axes( hPlotAxes(2) ); - tsg = getappdata( hMainFig, 'tsg_data'); line( tsg.DAYD, tsg.SSPS_ADJUSTED-tsg.SSPS,... - 'Tag', 'TAG_PLOT2_LINE_TSGDIF', 'Color', 'b'); - + 'Tag', 'TAG_PLOT2_LINE_TSGDIF', 'Color', 'b'); + + % Plot TSG + ERROR on axe 3 + % ------------------------- + errorPlus = tsg.SSPS_ADJUSTED + tsg.SSPS_ADJUSTED_ERROR; + errorMinus = tsg.SSPS_ADJUSTED - tsg.SSPS_ADJUSTED_ERROR; + axes( hPlotAxes(3) ); + line( tsg.DAYD, errorPlus,... + 'Tag', 'TAG_PLOT3_LINE_TSGERROR_PLUS', 'Color', 'g'); + line( tsg.DAYD, errorMinus,... + 'Tag', 'TAG_PLOT3_LINE_TSGERROR_MINUS', 'Color', 'g'); + case -1 msgbox( 'Date limits are not correct',... - 'Correction module', 'warn', 'modal'); + 'Correction module', 'warn', 'modal'); end - + end %% Clim_OffMenuCallback -- GitLab