From dcc1544e03d3832ab7a0430286839ba527bfd8e3 Mon Sep 17 00:00:00 2001
From: alory <gael.alory@legos.obs-mip.fr>
Date: Wed, 30 Jan 2019 18:40:44 +0100
Subject: [PATCH] replace seawater functions from outdated EOS-80 toolbox with
 equivalent functions from TEOS-10 toolbox

---
 tsg_util/calibration.m  | 12 +-----------
 tsg_util/tsg_accuracy.m | 22 ++++++++++++----------
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/tsg_util/calibration.m b/tsg_util/calibration.m
index 032fa26..994512e 100644
--- a/tsg_util/calibration.m
+++ b/tsg_util/calibration.m
@@ -7,12 +7,6 @@ function calibration( hMainFig )
 %
 % Compute salinity from calibrated conductivity and jacket temperature 
 %
-% Bug :
-% 1 - tsg.SSPS_CAL = sw_salt( cond/sw_c3515(),t90TOt68(temp),zeros(size(cond)));
-%     replaced by
-%     tsg.SSPS_CAL = sw_salt( cond/sw_c3515(),temp,zeros(size(cond)));
-%
-%     CSIRO toolbox modified sw_salt modified to use temprature ITS90
 %
 % $Id$
 
@@ -88,11 +82,7 @@ if ~isempty( indC ) || ~isempty( indT )
   end
   
   if ~isempty( temp ) && ~isempty( cond )
-
-% Modification du 13/02/2009
-% tsg.SSPS_CAL = sw_salt( ...
-%       cond/sw_c3515(), t90TOt68(temp), zeros(size(cond)));
-    tsg.SSPS_CAL = sw_salt( cond/sw_c3515(), temp, zeros(size(cond)));
+    tsg.SSPS_CAL = gsw_SP_from_R( cond/gsw_C3515, temp, zeros(size(cond)));
   end
 
 else
diff --git a/tsg_util/tsg_accuracy.m b/tsg_util/tsg_accuracy.m
index f8f8355..b7167da 100644
--- a/tsg_util/tsg_accuracy.m
+++ b/tsg_util/tsg_accuracy.m
@@ -66,25 +66,27 @@ if strcmp( PARA, 'SSPS')
 
     if (~isempty( T) & ~isempty( C))
 
+        c68 = 1.00024;
+        c0 =  0.6766097;
+        c1 =  2.00564e-2;
+        c2 =  1.104259e-4;
+        c3 = -6.9698e-7;
+        c4 =  1.0031e-9;
+        
         % salinity error is computed from temperature/conductivity errors
         % by error propagation in the salinity equation
         % see Emery and Thomson, Data analysis methods in phys. oceano., p.273
 
-        R=C/sw_c3515();
-        rt = sw_salrt(T);
-        Rt=R./rt;
+        R = C/gsw_C3515;
+        T68 = T * c68;
+        rt = c0 + (c1 + (c2 + (c3 + c4.*T68).*T68).*T68).*T68;
+        Rt = R./rt;
 
         %Rt is a function of C,T
         %error on Rt : err(Rt)^2=(d(Rt)/dC*errC)^2+(d(Rt)/dT*errT)^2
 
-        dRtdC=1./(rt*sw_c3515());
+        dRtdC=1./(rt*gsw_C3515);
 
-        c68 = 1.00024;
-        c0 =  0.6766097;
-        c1 =  2.00564e-2;
-        c2 =  1.104259e-4;
-        c3 = -6.9698e-7;
-        c4 =  1.0031e-9;
         dRtdT=c68*R.*(c1+(2*c2+(3*c3+4*c4*T).*T*c68).*T*c68)./(rt.^2);
 
         errRt=sqrt((dRtdC*errC).^2+(dRtdT*errT).^2);
-- 
GitLab