From f73bce9a745c969ce27868381d41ee57cc822661 Mon Sep 17 00:00:00 2001 From: Yves Gouriou <yves.gouriou@ird.fr> Date: Tue, 11 Mar 2008 16:10:10 +0000 Subject: [PATCH] =?UTF-8?q?Renommer=20la=20fonction=20d'interpolation=20ln?= =?UTF-8?q?=C3=A9aire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @tsg_nc/tsg_quality.csv | 2 +- tsg_util/InterpPosLinear.m | 47 ----------------------------- tsg_util/interpPosLinear.m | 61 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 48 deletions(-) delete mode 100644 tsg_util/InterpPosLinear.m create mode 100644 tsg_util/interpPosLinear.m diff --git a/@tsg_nc/tsg_quality.csv b/@tsg_nc/tsg_quality.csv index bf122ea..a7d4968 100644 --- a/@tsg_nc/tsg_quality.csv +++ b/@tsg_nc/tsg_quality.csv @@ -11,5 +11,5 @@ char;char;char;byte;char;char;char #;VALUE_CHANGED;Value changed;5;c;off;# #;HARBOUR;Harbour;6;c;on;# #;NOT_USED;Not used;7;w;off;# -#;INTERPOLATED_VALUE;Interpolated value;8;k;off;# +#;INTERPOLATED_VALUE;Interpolated value;8;b;off;# #;MISSING_VALUE;Missing value;9;k;off;# diff --git a/tsg_util/InterpPosLinear.m b/tsg_util/InterpPosLinear.m deleted file mode 100644 index c0d0e72..0000000 --- a/tsg_util/InterpPosLinear.m +++ /dev/null @@ -1,47 +0,0 @@ -function interpPosLinear( hMainFig, dateMin, dateMax ) -% -% Function that interpolate linearly Latitude and position when they are -% set to NaN -% -% Input -% hMainFig ..... Handle to the main GUI -% dateMin ...... the correction is applied between dateMin and date Max -% dateMax ...... the correction is applied between dateMin and date Max -% -% Output -% Error ........ 1 everything OK -% ........ -1 dateMax <= date Min -% - -% Get application data -% -------------------- -tsg = getappdata( hMainFig, 'tsg_data'); - -error = 1; -if dateMax > dateMin - - % find the closest point - % ---------------------- - ind = find( tsg.DAYD >= dateMin && tsg.DAYD <= dateMax ); - - if ~isempty( ind ) - - interp1( tsg.DAYD(ind), tsg.LATX(ind) - end - - % Create time series - % ------------------ - time = dateMin:deltaT:dateMax; - - - % Update tsg application data - % --------------------------- - setappdata( hMainFig, 'tsg_data', tsg); - -else - - error = -1; - -end - -end \ No newline at end of file diff --git a/tsg_util/interpPosLinear.m b/tsg_util/interpPosLinear.m new file mode 100644 index 0000000..0fe231d --- /dev/null +++ b/tsg_util/interpPosLinear.m @@ -0,0 +1,61 @@ +function [error] = interpPosLinear( hMainFig, dateMin, dateMax ) +% +% Function that interpolate linearly Latitude and position when they are +% set to NaN +% +% Input +% hMainFig ..... Handle to the main GUI +% dateMin ...... the correction is applied between dateMin and date Max +% dateMax ...... the correction is applied between dateMin and date Max +% +% Output +% Error ........ 1 everything OK +% ........ -1 dateMax <= date Min +% + +% Get application data +% -------------------- +tsg = getappdata( hMainFig, 'tsg_data'); + +% Get INTERPOLATED_VALUE code +% --------------------------- +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 ); + + if ~isempty( ind ) + + % 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; + + Y = interp1( tsg.DAYD(ind), tsg.LONX(ind), tsg.DAYD(ind(ind2)) ); + tsg.LONX(ind(ind2)) = Y; + + if isempty( tsg.POSITION_QC ) + tsg.POSITION = NO_CONTROL * ones( size(tsg.DAYD) ); + end + + tsg.POSITION_QC(ind(ind2)) = INTERPOLATED_VALUE; + + end + + % Update tsg application data + % --------------------------- + setappdata( hMainFig, 'tsg_data', tsg); + +else + + error = -1; + +end + +end \ No newline at end of file -- GitLab