Skip to content
Snippets Groups Projects
minSSJTQC.m 1.97 KiB
Newer Older
function minSSJTQC(hMainFig)
%
% This function is called after option/preferences menu has been activated
% and flag salinity data where SSJT < min as BAD if test is on
%
% Input
% -----
% hMainFig ............ Handle to the main user interface
%
% $Id$

% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

% Get BAD code value
% ----------------------
badCode = tsg.qc.hash.BAD.code;

ssjt_min = tsg.preference.ssjt_min_string;

% If necessary replace a comma by a point
% ---------------------------------------
ssjt_min = regexprep(ssjt_min, ',', '.');

% If bias not a numeric, str2double return a NaN
% ----------------------------------------------
ssjt_min = str2double( ssjt_min );

if isnumeric( ssjt_min ) && ~isnan( ssjt_min )
alory's avatar
alory committed
    
    % Set salinity QC to BAD for ssps < ssps_max
    % -----------------------------------------------------
    ind = find(tsg.SSJT < ssjt_min);
    
    if ~isempty( ind )
        
        % store last QC in history for undo
        % ---------------------------------
        
        if (tsg.qc_history_pointer == 0)
            tsg.qc_history_state = int8(zeros(size(tsg.SSPS_QC,1),tsg.qc_history_size));
        end
        
        if (tsg.qc_history_pointer == tsg.qc_history_size)
            tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]);
        else
            tsg.qc_history_pointer = tsg.qc_history_pointer + 1;
        end
        
        tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.SSPS_QC;
        tsg.qc_redo_possible = 0;
        
        tsg.SSJT_QC(ind) = castByteQC( badCode, ind );
        tsg.SSPS_QC(ind) = castByteQC( badCode, ind );
        
    end
    
    % Save tsg structure
    % ------------------
    setappdata( hMainFig, 'tsg_data', tsg);
    
alory's avatar
alory committed
    
    msgbox('Enter a numeric value in the REFERENCE menu', 'ssjt QC',...
        'error', 'modal');