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');
% 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
% 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
% -------------------
Yves Gouriou
committed
for i= 1 : m
% Compute the differences between the sample and the time serie
% -------------------------------------------------------------
timeDiff = abs(tsg.DAYD - tsg.DAYD_SPL(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 && ...
tsg.SSPS_SPL_SMOOTH(i) = tsg.ssps_smooth(indMin);
Yves Gouriou
committed
end
end
% Salinity difference : Sample minus smoothed TSG
% -----------------------------------------------
tsg.SSPS_SPL_DIF = tsg.SSPS_SPL - tsg.SSPS_SPL_SMOOTH;
Yves Gouriou
committed
% update the sample structures in the application
% ------------------------------------------------
setappdata( hTsgGUI, 'tsg_data', tsg );