Skip to content
Snippets Groups Projects
minSSPSQC.m 1.89 KiB
Newer Older
function minSSPSQC(hMainFig)
%
% This function is called after option/preferences menu has been activated
alory's avatar
alory committed
% and flag salinity data where SSPS < min as BAD if test is on
%
% Input
% -----
% hMainFig ............ Handle to the main user interface
%
alory's avatar
alory committed
% $Id: minSSPSQC.m 562 2010-04-06 14:46:58Z ygouriou $

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

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

ssps_min = tsg.preference.ssps_min_string;

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

% If bias not a numeric, str2double return a NaN
% ----------------------------------------------
ssps_min = str2double( ssps_min );
if isnumeric( ssps_min ) && ~isnan( ssps_min )
  % Set salinity QC to BAD for ssps < ssps_min
  % -----------------------------------------------------
  ind = find(tsg.SSPS < ssps_min);
alory's avatar
alory committed
  
alory's avatar
alory committed
      
      % 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.SSPS_QC(ind) = castByteQC( badCode, ind );
      
alory's avatar
alory committed
  
  % Save tsg structure
  % ------------------
  setappdata( hMainFig, 'tsg_data', tsg);
  
else
  
  msgbox('Enter a numeric value in the REFERENCE menu', 'ssps QC',...