function calibration( hMainFig )
%
% Compute salinity from calibrated conductivity and jacket temperature 
%

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

if ~isempty( tsg.CNDC )
  cndcCal = tsg.CNDC_LINCOEF(1) * tsg.CNDC + tsg.CNDC_LINCOEF(2);
else
  msgbox( 'Conductivity not loaded',...
          'Function ''Calibration''',...
          'warn', 'modal');
end

if ~isempty( tsg.SSJT )
  ssjtCal = tsg.SSJT_LINCOEF(1) * tsg.SSJT + tsg.SSJT_LINCOEF(2);
else
  msgbox( 'Jacket temperature not loaded',...
          'Function ''Calibration''',...
          'warn', 'modal');
end

% Compute salinity - Use CSIRO functions
% --------------------------------------
tsg.SSPS_CAL = sw_salt( ...
               cndcCal/sw_c3515(), t90TOt68(ssjtCal), zeros(size(cndcCal)));
            
% Keep SSJT calibrated
% --------------------
tsg.SSJT_CAL = ssjtCal;

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

end
