Skip to content
Snippets Groups Projects
tsgqc.m 171 KiB
Newer Older
function tsgqc( varargin )
%TSGQC Thermosalinograph (TSG) Quality Control software
% TSGQC is a software for interactive analysis and validation of
% underway SST / SSS (Sea Surface Temperature and Sea Surface Salinity)
% measurements from a SeaBird Thermosalinograph (TSG).
% It has been developed under Matlab.
% Usage:
%   tsgqc help
%
% See:
%   Documentation: http://www.ird.fr/us191/spip.php?article63
%   Source code: https://git.outils-is.ird.fr/grelet/TSG-QC
%

% Tips:
%  To get and check tsg structure anywhere during debug:
%  tsg = getappdata( findobj('Tag', 'TAG_TSG-QC_GUI'), 'tsg_data')
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed


%% COPYRIGHT & LICENSE
%  Copyright 2007-2018 - IRD US191, all rights reserved.
%  This file is part of tsgqc.
%    TSG-QC is free software; you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as publDisplayished by
%    the Free Software Foundation; either version 2 of the License, or
%    (at your option) any later version.
%
%    tsgqc is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with Datagui; if not, write to the Free Software
%    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
%% Define global variables for VERSIONING
% ---------------------------------------
global DATE_VERSION
global DEBUGGING
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
global DEFAULT_PATH_FILE

% version number, may be used to initialize some files when it change
% 0.90x -> 1.0RCx
% if you modify the tsgqc.preference structure, you need to increment
% or modify the version number to load a new default structure
% -------------------------------------------------------------------
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
VERSION      = 1.50;  % -> 1.44
CHAR_VERSION = '1.50RC2';
DATE_VERSION = '07/01/2019';

% netcdf file version, see DATA FORMAT TSG document:
% CORTSG_format_gosud.doc
% --------------------------------------------------
%%  Initialization tasks
%   ********************

% Clear Command Window display, giving up a "clean screen."
% ---------------------------------------------------------
clc;

% Find program directory.
% functions (icons) should be store at a lower level
% add directories to Matlab search path, works on UNIX
% and Windows host
% ---------------------------------------------------
tsgqcname = mfilename;
fulltsgqcname = mfilename('fullpath');

% regular expression expr if it occurs at the end of the input string
% -------------------------------------------------------------------

% get pathname
% ------------
DEFAULT_PATH_FILE =  regexprep(fulltsgqcname, expr, '');

% update Matlab pathdef only for session
% addpath isn't mandatory and failed with compiled applications
% -------------------------------------------------------------
if (~isdeployed)
  p = [pathsep,...
    DEFAULT_PATH_FILE,[ 'tsg_util' pathsep],...
    DEFAULT_PATH_FILE,[ 'tsg_data' pathsep],...
    DEFAULT_PATH_FILE,[ 'tsg_icon' pathsep],...
    DEFAULT_PATH_FILE,[ 'tsg_map' pathsep]
    ];
  addpath( p, '-end' );
  rehash;

% define 'HandleVisibility' property for all objects
% --------------------------------------------------
handleVisibility = 'on';

% % get screen dimensions (pixels)
% % ------------------------------
% set(0,'Units','pixels');
% screenSize = get(0,'ScreenSize');
% % set default font size
% % ---------------------
% if screenSize(3) <= 1024
%   tsg.fontSize = 9;
% else
%   tsg.fontSize = 11;
% end

% Screen limits for the GUI
% -------------------------
if verLessThan('matlab','8.4')
  set(0,'Units','normalized');
  guiLimits = get(0,'ScreenSize');
else
  r = groot;
  r.Units = 'normalized';
  guiLimits = r.ScreenSize;
end

guiLimits(1) = guiLimits(1) + 0.01;
guiLimits(2) = guiLimits(2) + 0.05;
guiLimits(3) = guiLimits(3) - 0.02;
guiLimits(4) = guiLimits(4) - 0.15;

%% Optional arguments
% --------------------
inputFile  = '';
outputFile = '';
display    = false;
DEBUGGING  = false;
help       = false;

% parse and set optional arguments with couple 'property', 'value'
% -----------------------------------------------------------------
if length(varargin) == 1
  inputFile = varargin{1};
end
property_argin = varargin(1:end);
  property = property_argin{1};
  value    = property_argin{2};
  property_argin = property_argin(3:end);
  switch lower(property)
    case {'inputfile', 'input', 'file'}
      inputFile = value;
    case {'outputfile', 'output'}
      outputFile = value;
    case 'display'
      display = value;
    case 'debug'
      DEBUGGING = value;
    otherwise
      error('Unknow property: %s', property);
  end
end

% if property display is set to display, display them and quit
% -----------------------------------------------------------
if display
  fprintf('inputFile: %s\noutpuFile: %s\n', inputFile, outputFile);
  return;
end
% if property help is set to on, display help and quit
% -----------------------------------------------------------
if strcmp(help, 'on') || ~isempty(strfind(inputFile,'help'))
  fprintf('tsgqc usage:\n');
  fprintf('tsgqc(''<file>'')\n');
  fprintf('tsgqc(''inputfile'', <file>, ''outputfile'', <file>)\n');
  fprintf('tsgqc(''inputfile'', <file>, ''outputfile'', <file>),''display'',''true''\n');
  fprintf('tsgqc(''help'',''true'')\n');
  fprintf('tsgqc --help\n');
  fprintf('tsgqc(''<file>'', ''debug'', 1)\n');

%% Main TSGQC GUI
% ---------------

% Check if main TSGQC figure exist
% --------------------------------
hMainFig = findobj('Tag', 'TAG_TSG-QC_GUI');

% if TSGQC figure exist and still running, don't create a new instance
% --------------------------------------------------------------------
if ~isempty(hMainFig)
Loading
Loading full blame...