Skip to content
Snippets Groups Projects
automaticQC.m 1.26 KiB
Newer Older
Yves Gouriou's avatar
Yves Gouriou committed
function [] = automaticQC( hTsgGUI )
%
% function [] = automaticQC( hTsgGUI )
%
% Automatic controlon TSG time series
%
% Test for :
% No date or time
% SSS < 0 and SSS > 40
%

% Get application data : TSG structure
% --------------------------------------
tsg  = getappdata( hTsgGUI, 'tsg_data');

% Delete records with date and time at NaN
% ----------------------------------------
indNaN = find( isnan(tsg.DAYD) == 1 );
tsg.DAYD(indNaN)    = [];
tsg.DATE(indNaN,:)  = [];
tsg.LATX(indNaN)    = [];
tsg.LONX(indNaN)    = [];
tsg.SSJT(indNaN)    = [];
tsg.SSPS(indNaN)    = [];
tsg.SSPS_QC(indNaN) = []; 
tsg.SPDC(indNaN)    = [];
if ~isempty( tsg.SSJT_FREQ )
  tsg.SSJT_FREQ(indNaN) = [];
  tsg.CNDC_FREQ(indNaN) = [];
end

% Get BAD code value
% ------------------
badCode = get(tsg.qc.hash, 'BAD', 'code');

% Set salinity QC to BAD for SSS > 40
% -----------------------------------
ind = find(tsg.SSPS > 40);
tsg.SSPS_QC(ind)    = badCode*ones(size(ind),1);

% Set salinity QC to BAD for SSS < 0
% -----------------------------------
ind = find(tsg.SSPS < 0);
tsg.SSPS_QC(ind)    = badCode*ones(size(ind),1);

% Save the data in the application GUI
% ------------------------------------
setappdata( hTsgGUI, 'tsg_data', tsg );

end