Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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