Skip to content
Snippets Groups Projects
Commit 3e2c0c85 authored by Yves Gouriou's avatar Yves Gouriou
Browse files

Développement module d'interpolation des positions

parent 7dcac2c7
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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
% ---------------------------
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment