Newer
Older
Yves Gouriou
committed
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' );
% Get PROBABLY_GOOD code
% ----------------------
probablyGoodCode = get(tsg.qc.hash, 'PROBABLY_GOOD', 'code');
% Consider only tsg data with NO_CONTROL, GOOD and PROBABLY_GOOD code
% -------------------------------------------------------------------
indTsg = find( tsg.SSPS_QC <= probablyGoodCode );
Yves Gouriou
committed
[m, n] = size(sample.SSPS);
% time difference between 2 successive TSG measurements
% Not use anymore. Now use a constant tsg.cst.TSG_WS_TIMEDIFF in the test
% -----------------------------------------------------------------------
% dt = min(diff(tsg.DAYD));
Yves Gouriou
committed
% Loop on the samples with NO_CONTROL, GOOD and PROBABLY_GOOD code
% ----------------------------------------------------------------
Yves Gouriou
committed
for i= 1 : m
if sample.SSPS_QC(i) <= probablyGoodCode
% Compute the differences between the sample and the time serie
% -------------------------------------------------------------
Yves Gouriou
committed
timeDiff = abs(tsg.DAYD - sample.DAYD(i));
% Compute the indice of the TSG measurement the closest to the sample
% taking into account the TSG quality code
% -------------------------------------------------------------------
[timeMin, indMin] = min(timeDiff(indTsg));
indMin = indTsg( indMin );
% Keep the smooth TSG value
% -------------------------
if timeDiff(indMin) < tsg.cst.TSG_WS_TIMEDIFF && ...
~isnan(tsg.ssps.smooth.val(indMin))
sample.SSPS_SMOOTH(i) = tsg.ssps.smooth.val(indMin);
Yves Gouriou
committed
end
end
Yves Gouriou
committed
end
% Salinity difference : Sample minus smoothed TSG
% -----------------------------------------------
sample.SSPS_DIF = sample.SSPS - sample.SSPS_SMOOTH;
Yves Gouriou
committed
% update the sample structures in the application
% ------------------------------------------------
setappdata( hTsgGUI, 'sample', sample );