function calibration( hMainFig )
%
% Calibrate :
% CNDC ...... Conductivity
% SSJT ...... Jacket temperature
% SSTP ...... Precise temperature
%
% Compute salinity from calibrated conductivity and jacket temperature 
%

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

% Variables
% ---------
PARA = [ 'CNDC'; 'SSJT'; 'SSTP' ];

for i = 1:3

  if ~isempty( tsg.(PARA(i,:)) )

    para1 = [PARA(i,:) '_LINCOEF'];
    para2 = [PARA(i,:) '_CAL'];

    tsg.(para2)= tsg.(para1)(1) * tsg.(PARA(i,:)) + tsg.(para1)(2);

  elseif strcmp( PARA(i,:), 'CNDC' ) || strcmp( PARA(i,:), 'SSJT' )

    msgbox( [ PARA(i,:) ' not loaded'],...
      'Function ''Calibration''',...
      'warn', 'modal');
    return
  end
end

% Compute salinity - Use CSIRO functions
% --------------------------------------
tsg.SSPS_CAL = sw_salt( ...
  tsg.CNDC_CAL/sw_c3515(), t90TOt68(tsg.SSJT_CAL), zeros(size(tsg.CNDC_CAL)));

% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );

end
