diff --git a/tsg_util/automaticQC.m b/tsg_util/automaticQC.m index aba6307c545c9d2f217c941051e1fe4e44d35492..98716b94f38c9ebeabbfe5f66819b08a6988ab71 100644 --- a/tsg_util/automaticQC.m +++ b/tsg_util/automaticQC.m @@ -32,7 +32,7 @@ difDate = diff( tsg.DAYD ); ind = find( difDate < 0 ) + 1; while ~isempty( ind ) if ~isempty( tsg.DAYD ); tsg.DAYD(ind) = []; end; - if ~isempty( tsg.DATE ); tsg.DATE(ind) = []; end; + if ~isempty( tsg.DATE ); tsg.DATE(ind, :) = []; end; if ~isempty( tsg.LATX ); tsg.LATX(ind) = []; end; if ~isempty( tsg.LONX ); tsg.LONX(ind) = []; end; if ~isempty( tsg.SSPS ); tsg.SSPS(ind) = []; end; diff --git a/tsg_util/interpPosLinear.m b/tsg_util/interpPosLinear.m index 0fe231d6c9b3598b4479c1885e3a2675ee21cca5..dab63ff3820a1743847f2f1bf6fe5fba73b47346 100644 --- a/tsg_util/interpPosLinear.m +++ b/tsg_util/interpPosLinear.m @@ -15,38 +15,49 @@ function [error] = interpPosLinear( hMainFig, dateMin, dateMax ) % Get application data % -------------------- -tsg = getappdata( hMainFig, 'tsg_data'); +tsg = getappdata( hMainFig, 'tsg_data'); -% Get INTERPOLATED_VALUE code -% --------------------------- +% Get NO_CONTROL and INTERPOLATED_VALUE codes +% ------------------------------------------- NO_CONTROL = get(tsg.qc.hash, 'NO_CONTROL', 'code'); INTERPOLATED_VALUE = get(tsg.qc.hash, 'INTERPOLATED_VALUE', 'code'); error = 1; if dateMax > dateMin - % find the closest point - % ---------------------- - ind = find( tsg.DAYD >= dateMin && tsg.DAYD <= dateMax ); + % Indices of the records to interpolate + % ------------------------------------- + iRec = find( tsg.DAYD >= dateMin & tsg.DAYD <= dateMax ); - if ~isempty( ind ) + if ~isempty( iRec ) - % Look for records with no position - % --------------------------------- - ind2 = find( isnan(tsg.LATX(ind)) == 1 ); - Y = interp1( tsg.DAYD(ind), tsg.LATX(ind), tsg.DAYD(ind(ind2)) ); - tsg.LATX(ind(ind2)) = Y; + % Look for records with Good Position + % ----------------------------------- + iGP = find( isnan(tsg.LATX(iRec)) == 0 ); - Y = interp1( tsg.DAYD(ind), tsg.LONX(ind), tsg.DAYD(ind(ind2)) ); - tsg.LONX(ind(ind2)) = Y; + % Look for records with No Position + % ----------------------------------- + iNP = find( isnan(tsg.LATX(iRec)) == 1 ); - if isempty( tsg.POSITION_QC ) - tsg.POSITION = NO_CONTROL * ones( size(tsg.DAYD) ); + if ~isempty( iNP ) && ~isempty( iGP ) + + Y = interp1(tsg.DAYD(iRec(iGP)), tsg.LATX(iRec(iGP)), tsg.DAYD(iRec) ); + + tsg.LATX(iRec(iNP)) = Y(iRec(iNP) - iRec(1) + 1); + + Y = interp1(tsg.DAYD(iRec(iGP)), tsg.LONX(iRec(iGP)), tsg.DAYD(iRec) ); + + tsg.LONX(iRec(iNP)) = Y(iRec(iNP) - iRec(1) + 1); + + if isempty( tsg.POSITION_QC ) + tsg.POSITION_QC = castByteQC( NO_CONTROL, tsg.DAYD ); + end + + tsg.POSITION_QC(iRec(iNP)) = INTERPOLATED_VALUE; + end - - tsg.POSITION_QC(ind(ind2)) = INTERPOLATED_VALUE; - end + end % Update tsg application data % --------------------------- diff --git a/tsg_util/plot_Interpolation.m b/tsg_util/plot_Interpolation.m index 9c6a26c467d3bb7ace039bdb92671baf548c06fe..af8e917fe5af1b08cec516dee65bd7ca5f15b3bc 100644 --- a/tsg_util/plot_Interpolation.m +++ b/tsg_util/plot_Interpolation.m @@ -22,7 +22,7 @@ switch nPlot ind = find( isnan(tsg.LATX) == 1 | isnan(tsg.LONX) == 1); if ~isempty( tsg.ssps_smooth ) plot_Tsg( hMainFig, hPlotAxes, 1, tsg.DAYD(ind), tsg.SSPS(ind), [],... - 'SSPS_NOPOS','r','none','*',2); + 'SSPS_NOPOS','b','none','*',2); end ind = find( isnan(tsg.LATX) == 0 | isnan(tsg.LONX) == 0); @@ -42,8 +42,10 @@ switch nPlot end if ~isempty(tsg.POSITION_QC) ind = find( tsg.POSITION_QC == INTERPOLATED_VALUE ); - plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD(ind), tsg.LATX(ind),[],... - 'LATX_INTERP','r','none','*',2); + if ~isempty( ind ) + plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD(ind), tsg.LATX(ind),[],... + 'LATX_INTERP','r','none','*',2); + end end % --------------------------------------------------------------------- @@ -55,8 +57,10 @@ switch nPlot end if ~isempty(tsg.POSITION_QC) ind = find( tsg.POSITION_QC == INTERPOLATED_VALUE ); - plot_Tsg( hMainFig, hPlotAxes, 2, tsg.DAYD(ind), tsg.LONX(ind),[],... - 'LONX_INTERP','r','none','*',2); + if ~isempty( ind ) + plot_Tsg( hMainFig, hPlotAxes, 3, tsg.DAYD(ind), tsg.LONX(ind),[],... + 'LONX_INTERP','r','none','*',2); + end end end diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index 9ac9358fc492c8e27dbf939df9957d2ad2b54dde..d223e76fa0211084e527346a5fcaedb486a518ae 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -885,13 +885,13 @@ hpInterpPos = uipanel( ... 'Title', 'Lat-Lon interpolation', ... 'FontSize', tsg.fontSize-1, 'Fontweight', 'bold', ... 'Visible', 'off', ... - 'Units', 'normalized','Position', [.0, .85, .15, .11]); + 'Units', 'normalized','Position', [.0, .75, .15, .21]); hrbInterpLinear = uicontrol( ... 'Style','pushbutton', 'Parent',hpInterpPos, ... 'String','Linear interpolation',... 'FontSize',tsg.fontSize-1,... 'Tag', 'TAG_PUSH_INTERP_LINEAR', ... - 'Units', 'normalized','pos',[.05 .6 .9 .3], ... + 'Units', 'normalized','pos',[.05 .65 .9 .25], ... 'HandleVisibility','callback', ... 'Callback', @InterpPosLinearCallback); hrbInterpOther = uicontrol( ... @@ -899,9 +899,17 @@ hrbInterpOther = uicontrol( ... 'String','Other method',... 'FontSize',tsg.fontSize-1,... 'Tag', 'TAG_PUSH_INTERP_OTHER', ... - 'Units', 'normalized','pos',[.05 .1 .9 .3], ... + 'Units', 'normalized','pos',[.05 .35 .9 .25], ... 'HandleVisibility','callback', ... 'Callback', @InterpPosOtherCallback); +hrbInterpCancel = uicontrol( ... + 'Style','pushbutton', 'Parent',hpInterpPos, ... + 'String','Cancel interpolation',... + 'FontSize',tsg.fontSize-1,... + 'Tag', 'TAG_PUSH_INTERP_CANCEL', ... + 'Units', 'normalized','pos',[.05 .05 .9 .25], ... + 'HandleVisibility','callback', ... + 'Callback', @InterpPosCancelCallback); %% test if user preference autoload field is checked (on) @@ -1120,8 +1128,7 @@ end % Callback function run when % function Inter_OnMenuCallback( hObject, eventdata) - - + % Activate or desactivate uipanels % -------------------------------- set( hpCalCoef, 'Visible', 'off' ); @@ -1174,6 +1181,10 @@ end plot_Validation( hMainFig, hPlotAxes, 2 ); plot_Validation( hMainFig, hPlotAxes, 3 ); + % Set the pointer + % --------------- + set( hMainFig, 'Pointer', 'arrow'); + end %% InterpLinearCallback ...............................Interpolation Linear @@ -1218,6 +1229,40 @@ end 'modal' ); end +%% InterpPosCancelCallback ..........................Cancel Interpolation + %---------------------------------------------------------------------- + function InterpPosCancelCallback(hObject, eventdata) + % Callback function run when + + % Get tsg application data + % ------------------------ + tsg = getappdata( hMainFig, 'tsg_data' ); + + % Get NO_CONTROL and INTERPOLATED_VALUE codes + % ------------------------------------------- + NO_CONTROL = get(tsg.qc.hash, 'NO_CONTROL', 'code'); + INTERPOLATED_VALUE = get(tsg.qc.hash, 'INTERPOLATED_VALUE', 'code'); + + if ~isempty( tsg.POSITION_QC ) + iINTERP = find( tsg.POSITION_QC == INTERPOLATED_VALUE); + tsg.LATX( iINTERP ) = NaN * ones( size( iINTERP), 1 ); + tsg.LONX( iINTERP ) = NaN * ones( size( iINTERP), 1 ); + tsg.POSITION_QC = []; + end + + % Save tsg application data + % -------------------------- + setappdata( hMainFig, 'tsg_data', tsg ); + + % Refresh plots + % ------------- + plot_Interpolation( hMainFig, hPlotAxes, 1 ); + plot_Interpolation( hMainFig, hPlotAxes, 2 ); + plot_Interpolation( hMainFig, hPlotAxes, 3 ); + + end + + %% Cal_OnMenuCallback ..................................... Calibration %---------------------------------------------------------------------- % Callback function run when @@ -2040,6 +2085,10 @@ end plot_Validation( hMainFig, hPlotAxes, 2 ); plot_Validation( hMainFig, hPlotAxes, 3 ); end + + % Set the pointer + % --------------- + set( hMainFig, 'Pointer', 'arrow'); end