Newer
Older
Yves Gouriou
committed
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
function diffTsgSample(hTsgGUI)
%
% Co-location of sample and TSG measurements
% Compute the sample-TSG difference
%
% Get the tsg and sample structures from the application
% ------------------------------------------------------
tsg = getappdata( hTsgGUI, 'tsg_data');
sample = getappdata( hTsgGUI, 'sample' );
[m, n] = size(sample.SSPS);
% time difference between 2 succesive TSG measurements
% ----------------------------------------------------
dt = tsg.DAYD(2) - tsg.DAYD(1);
% Loop on the samples
% -------------------
for i= 1 : m
% Indice of the TSG measurement the closest to the sample
% --------------------------------------------------------
timeDiff = abs(tsg.DAYD - sample.DAYD(i));
[timeMin, indMin] = min(timeDiff);
if timeDiff(indMin) < dt && ~isnan(tsg.ssps.smooth.val(indMin))
sample.SSPS_SMOOTH(i) = tsg.ssps.smooth.val(indMin);
sample.SSPS_QC(i) = 1;
else
sample.SSPS_QC(i) = 0;
end
end
% Salinity difference : Sample minus smoothed TSG
% -----------------------------------------------
indSample = find( sample.SSPS_QC == 1 );
sample.SSPS_DIF(indSample) = ...
sample.SSPS(indSample) - sample.SSPS_SMOOTH(indSample);
% update the sample structures in the application
% ------------------------------------------------
setappdata( hTsgGUI, 'sample', sample );