Back to home page

MITgcm

 
 

    


File indexing completed on 2024-12-19 06:11:49 UTC

view on githubraw file Latest commit 83a53713 on 2024-12-18 20:15:23 UTC
58679b5a83 Esta*0001 #
                0002 # created by mlosch on 2002-08-09
                0003 # converted to python by EGavilan Pascual-Ahuir on 2023-04-07
                0004 
                0005 import numpy as np
                0006 import warnings
                0007 
                0008 __doc__ = """
                0009 Density of Sea Water using linear EOS and POLY3 method.
                0010 Density of Sea Water using the Jackett and McDougall 1995 (JAOT 12) polynomial
                0011 Density of Sea Water using the UNESCO equation of state formula (IES80)
                0012 of Fofonoff and Millard (1983) [FRM83].
                0013 Density of Sea Water using the EOS-10 48-term polynomial.
                0014 """
                0015 
                0016 # coefficients nonlinear equation of state in pressure coordinates for
                0017 # 1. density of fresh water at p = 0 jmd95 and unesco
                0018 eosJMDCFw = [   999.842594,
                0019                 6.793952e-02,
                0020               - 9.095290e-03,
                0021                 1.001685e-04,
                0022               - 1.120083e-06,
                0023                 6.536332e-09,
                0024             ]
                0025 # 2. density of sea water at p = 0
                0026 eosJMDCSw = [   8.244930e-01,
                0027               - 4.089900e-03,
                0028                 7.643800e-05,
                0029               - 8.246700e-07,
                0030                 5.387500e-09,
                0031               - 5.724660e-03,
                0032                 1.022700e-04,
                0033               - 1.654600e-06,
                0034                 4.831400e-04,
                0035             ]
                0036 
                0037 def _check_salinity(s):
                0038 
                0039     sneg = s<0
83a53713c2 Oliv*0040     if np.any(sneg):
                0041         warnings.warn('found negative salinity values')
                0042         # warnings.warn('found negative salinity values, reset them to nan')
                0043         # s[sneg] = np.nan
58679b5a83 Esta*0044 
                0045     return s
                0046 
                0047 def _check_dimensions(s,t,p=np.zeros(())):
                0048     """
                0049     Check compatibility of dimensions of input variables and
                0050 
                0051     Parameters
                0052     ----------
                0053     salt : array_like
                0054         salinity [psu (PSS-78)]
                0055     theta : array_like
                0056         potential temperature [degree C (IPTS-68)]
                0057         same shape as salt
                0058     p  : pressure [dBar]
                0059     """
                0060 
                0061     if s.shape != t.shape or s.shape != p.shape:
                0062         print('trying to broadcast shapes')
                0063         np.broadcast(s,t,p)
                0064 
                0065     return
                0066 
                0067 def linear(salt,theta,
                0068            sref=30,tref=20,sbeta=7.4e-04,talpha=2.0e-04,rhonil=9.998e+02):
                0069     """
                0070     Computes in-situ density of water
                0071 
                0072     Density of water using the linear EOS of McDougall (1987).
                0073 
                0074     Parameters
                0075     ----------
                0076     salt : array_like
                0077         salinity [psu (PSS-78)]
                0078     theta : array_like
                0079         potential temperature [degree C (IPTS-68)]
                0080         same shape as salt
                0081     sref  : reference  salinity
                0082             default 30 [psu (PSS-78)]
                0083     tref  : reference potential temperature
                0084             default 20 [degree C (IPTS-68)]
                0085     sbeta  : haline expansion coefficient
                0086              default 7.4e-04 [1/C]
                0087     talpha    : therma expansion coefficient
                0088               default 2.0e-04 [(g/Kg)-1]
                0089     rhonil    : density of water
                0090               default 999.8 [(g/Kg)-1];
                0091 
                0092     Returns
                0093     -------
                0094     dens : array
                0095         density [kg/m^3]
                0096 
                0097     Example
                0098     -------
                0099     >>> dens.linear(35.5, 3.)
                0100     1007.268506
                0101 
                0102     Notes
                0103     -----
                0104     - Source code written by Martin Losch 2002-08-09
                0105     - Converted to python by Gavilan on 2024-07-18
                0106     """
                0107 
                0108     # make sure arguments are floating point
83a53713c2 Oliv*0109     s = np.asarray(salt, dtype=np.float64)
                0110     t = np.asarray(theta, dtype=np.float64)
58679b5a83 Esta*0111 
                0112     _check_dimensions(s,t)
                0113 
                0114     s = _check_salinity(s)
                0115 
                0116     rho = rhonil*(sbeta *(s-sref)-talpha*(t-tref))+rhonil
                0117 
                0118     return rho
                0119 
                0120 def poly3(poly3,salt,theta):
                0121     """
                0122     Calculates in-situ density as approximated by the POLY3 method
                0123     based on the Knudsen formula (see Bryan and Cox 1972).
                0124 
                0125     Parameters
                0126     ----------
                0127     poly3 : coefficients read from file
                0128             'POLY3.COEFFS' using INI_POLY3
                0129     salt : array_like
                0130            salinity [psu (PSS-78)]
                0131     theta : array_like
                0132             potential temperature [degree C (IPTS-68)];
                0133             same shape as salt
                0134 
                0135     Returns
                0136     -------
                0137     dens : array
                0138         density [kg/m^3]
                0139 
                0140     Example
                0141     -------
                0142     >>> p=ini_poly3()
                0143     >>> T=rdmds('T',100)
                0144     >>> S=rdmds('S',100)
                0145     >>> D=poly3(p,salt,theta)
                0146     >>> or to work within a single model level
                0147     >>> D=poly3(P[3,:],S[3,:,:],T[3,:,:])
                0148 
                0149 
                0150     Notes
                0151     -----
                0152     - Source code written by Martin Losch 2002-08-09
                0153     - Converted to python by Gavilan on 2024-07-18
                0154     """
                0155     # make sure arguments are floating point
83a53713c2 Oliv*0156     s = np.asarray(salt, dtype=np.float64)
                0157     t = np.asarray(theta, dtype=np.float64)
58679b5a83 Esta*0158     coeffs=poly3[:,3:]
                0159 
                0160 
                0161     _check_dimensions(s,t)
                0162 
                0163     s = _check_salinity(s)
                0164 
                0165     Nr=poly3.shape[0]
                0166 
                0167     t=np.reshape(t,[Nr,np.prod(np.shape(t))//Nr])
                0168     s=np.reshape(s,[Nr,np.prod(np.shape(s))//Nr])
                0169     rho=np.zeros([Nr,np.prod(np.shape(s))//Nr])
                0170     for k in range(0,Nr):
                0171         tRef=poly3[k,0]
                0172         sRef=poly3[k,1]
                0173         dRef=poly3[k,2]+1000
                0174         tp=t[k,:]-tRef;
                0175         sp=s[k,:]-sRef;
                0176 
                0177         tp2=tp*tp
                0178         sp2=sp*sp
                0179 
                0180         deltaSig = (   coeffs[k,0]*tp
                0181                      + coeffs[k,1]*sp
                0182                      + coeffs[k,2]*tp2
                0183                      + coeffs[k,3]*tp*sp
                0184                      + coeffs[k,4]*sp2
                0185                      + coeffs[k,5]*tp2*tp
                0186                      + coeffs[k,6]*tp2*sp
                0187                      + coeffs[k,7]*tp*sp2
                0188                      + coeffs[k,8]*sp2*sp
                0189                     )
                0190 
                0191         rho[k,:]=deltaSig+dRef
                0192 
                0193     return np.reshape(rho,s.shape)
                0194 
                0195 
                0196 def ini_poly3(fpath='POLY3.COEFFS'):
                0197     """Reads the file fpath (default 'POLY3.COEFFS') and returns
                0198     coefficients in poly
                0199     """
                0200 
                0201     with open(fpath,'r') as fid:
                0202         poly_data=fid.readlines()
                0203 
                0204     Nr=int(poly_data.pop(0))    # Number of vertical levels
                0205 
                0206     poly=np.zeros([Nr,12])
                0207 
                0208     poly_split = [i.split() for i in poly_data[:Nr]]
                0209     poly[:,:3] = np.asarray(poly_split)
                0210 
                0211     poly_split = [i.split() for i in poly_data[Nr:]]
                0212     poly[:,3:] = np.asarray(poly_split).reshape((Nr,9))
                0213 
                0214     return poly
                0215 
                0216 def jmd95(salt,theta,p):
                0217     """
                0218     Computes in-situ density of sea water
                0219 
                0220     Density of Sea Water using Jackett and McDougall 1995 (JAOT 12)
                0221     polynomial (modified UNESCO polynomial).
                0222 
                0223     Parameters
                0224     ----------
                0225     salt : array_like
                0226            salinity [psu (PSS-78)]
                0227     theta : array_like
                0228         potential temperature [degree C (IPTS-68)];
                0229         same shape as s
                0230     p : array_like
                0231         sea pressure [dbar]. p may have dims 1x1,
                0232         mx1, 1xn or mxn for s(mxn)
                0233 
                0234     Returns
                0235     -------
                0236     dens : array
                0237         density [kg/m^3]
                0238 
                0239     Example
                0240     -------
                0241     >>> dens.jmd95(35.5, 3., 3000.)
                0242     1041.83267
                0243 
                0244     Notes
                0245     -----
                0246 
                0247     - Jackett and McDougall, 1995, JAOT 12(4), pp. 381-388
                0248     - Source code written by Martin Losch 2002-08-09
                0249     - Converted to python by jahn on 2010-04-29
                0250     """
                0251 
                0252     # make sure arguments are floating point
83a53713c2 Oliv*0253     s = np.asarray(salt, dtype=np.float64)
                0254     t = np.asarray(theta, dtype=np.float64)
                0255     p = np.asarray(p, dtype=np.float64)
58679b5a83 Esta*0256 
                0257     _check_dimensions(s,t,p)
                0258 
                0259     s = _check_salinity(s)
                0260 
                0261     # convert pressure to bar
                0262     p = .1*p
                0263     t2 = t*t
                0264     t3 = t2*t
                0265     t4 = t3*t
                0266 
                0267     s3o2 = s*np.sqrt(s)
                0268 
                0269     # density of freshwater at the surface
                0270     rho = ( eosJMDCFw[0]
                0271           + eosJMDCFw[1]*t
                0272           + eosJMDCFw[2]*t2
                0273           + eosJMDCFw[3]*t3
                0274           + eosJMDCFw[4]*t4
                0275           + eosJMDCFw[5]*t4*t
                0276           )
                0277     # density of sea water at the surface
                0278     rho = ( rho
                0279            + s*(
                0280                  eosJMDCSw[0]
                0281                + eosJMDCSw[1]*t
                0282                + eosJMDCSw[2]*t2
                0283                + eosJMDCSw[3]*t3
                0284                + eosJMDCSw[4]*t4
                0285                )
                0286            + s3o2*(
                0287                  eosJMDCSw[5]
                0288                + eosJMDCSw[6]*t
                0289                + eosJMDCSw[7]*t2
                0290                )
                0291            + eosJMDCSw[8]*s*s
                0292           )
                0293 
                0294     rho = rho / (1. - p/bulkmodjmd95(s,t,p))
                0295 
                0296     return rho
                0297 
                0298 
                0299 def bulkmodjmd95(salt,theta,p):
                0300     """ Compute bulk modulus
                0301     """
                0302     # make sure arguments are floating point
83a53713c2 Oliv*0303     s = np.asarray(salt, dtype=np.float64)
                0304     t = np.asarray(theta, dtype=np.float64)
                0305     p = np.asarray(p, dtype=np.float64)
58679b5a83 Esta*0306 
                0307     # coefficients in pressure coordinates for
                0308     # 3. secant bulk modulus K of fresh water at p = 0
                0309     eosJMDCKFw = [   1.965933e+04,
                0310                      1.444304e+02,
                0311                    - 1.706103e+00,
                0312                      9.648704e-03,
                0313                    - 4.190253e-05
                0314                  ]
                0315     # 4. secant bulk modulus K of sea water at p = 0
                0316     eosJMDCKSw = [  5.284855e+01,
                0317                   - 3.101089e-01,
                0318                     6.283263e-03,
                0319                   - 5.084188e-05,
                0320                     3.886640e-01,
                0321                     9.085835e-03,
                0322                   - 4.619924e-04
                0323                  ]
                0324     # 5. secant bulk modulus K of sea water at p
                0325     eosJMDCKP = [    3.186519e+00,
                0326                     2.212276e-02,
                0327                   - 2.984642e-04,
                0328                     1.956415e-06,
                0329                     6.704388e-03,
                0330                   - 1.847318e-04,
                0331                     2.059331e-07,
                0332                     1.480266e-04,
                0333                     2.102898e-04,
                0334                   - 1.202016e-05,
                0335                     1.394680e-07,
                0336                   - 2.040237e-06,
                0337                     6.128773e-08,
                0338                     6.207323e-10
                0339                 ]
                0340 
                0341     _check_dimensions(s,t,p)
                0342 
                0343     t2 = t*t
                0344     t3 = t2*t
                0345     t4 = t3*t
                0346     s3o2 = s*np.sqrt(s)
                0347 
                0348     #p = pressure(i,j,k,bi,bj)*SItoBar
                0349     p2 = p*p
                0350     # secant bulk modulus of fresh water at the surface
                0351     bulkmod = ( eosJMDCKFw[0]
                0352               + eosJMDCKFw[1]*t
                0353               + eosJMDCKFw[2]*t2
                0354               + eosJMDCKFw[3]*t3
                0355               + eosJMDCKFw[4]*t4
                0356               )
                0357     # secant bulk modulus of sea water at the surface
                0358     bulkmod = ( bulkmod
                0359               + s*(      eosJMDCKSw[0]
                0360                        + eosJMDCKSw[1]*t
                0361                        + eosJMDCKSw[2]*t2
                0362                        + eosJMDCKSw[3]*t3
                0363                        )
                0364               + s3o2*(   eosJMDCKSw[4]
                0365                        + eosJMDCKSw[5]*t
                0366                        + eosJMDCKSw[6]*t2
                0367                        )
                0368                )
                0369     # secant bulk modulus of sea water at pressure p
                0370     bulkmod = ( bulkmod
                0371               + p*(   eosJMDCKP[0]
                0372                     + eosJMDCKP[1]*t
                0373                     + eosJMDCKP[2]*t2
                0374                     + eosJMDCKP[3]*t3
                0375                   )
                0376               + p*s*(   eosJMDCKP[4]
                0377                       + eosJMDCKP[5]*t
                0378                       + eosJMDCKP[6]*t2
                0379                     )
                0380               + p*s3o2*eosJMDCKP[7]
                0381               + p2*(   eosJMDCKP[8]
                0382                      + eosJMDCKP[9]*t
                0383                      + eosJMDCKP[10]*t2
                0384                    )
                0385               + p2*s*(  eosJMDCKP[11]
                0386                       + eosJMDCKP[12]*t
                0387                       + eosJMDCKP[13]*t2
                0388                      )
                0389                )
                0390 
                0391     return bulkmod
                0392 
                0393 def unesco(salt,theta,p):
                0394     """
                0395     Computes in-situ density of sea water
                0396 
                0397     Density of Sea Water using Fofonoff and Millard (1983)
                0398     polynomial.
                0399 
                0400     Parameters
                0401     ----------
                0402     salt : array_like
                0403            salinity [psu (PSS-78)]
                0404     theta : array_like
                0405         potential temperature [degree C (IPTS-68)];
                0406         same shape as s
                0407     p : array_like
                0408         sea pressure [dbar]. p may have dims 1x1,
                0409         mx1, 1xn or mxn for s(mxn)
                0410 
                0411     Returns
                0412     -------
                0413     dens : array
                0414         density [kg/m^3]
                0415 
                0416     Example
                0417     -------
                0418     >>> dens.unesco(35.5, 3., 3000.)
                0419     1041.87663
                0420 
                0421     Notes
                0422     -----
                0423     - Source code written by Martin Losch 2002-08-09
                0424     - Converted to python by Gavilan on 2024-07-18
                0425     """
                0426 
                0427     # make sure arguments are floating point
83a53713c2 Oliv*0428     s = np.asarray(salt, dtype=np.float64)
                0429     t = np.asarray(theta, dtype=np.float64)
                0430     p = np.asarray(p, dtype=np.float64)
58679b5a83 Esta*0431 
                0432     _check_dimensions(s,t,p)
                0433 
                0434     s = _check_salinity(s)
                0435 
                0436     # convert pressure to bar
                0437     p = .1*p
                0438     t2 = t*t
                0439     t3 = t2*t
                0440     t4 = t3*t
                0441     s3o2 = s*np.sqrt(s)
                0442 
                0443     # density of freshwater at the surface
                0444     rho = ( eosJMDCFw[0]
                0445           + eosJMDCFw[1]*t
                0446           + eosJMDCFw[2]*t2
                0447           + eosJMDCFw[3]*t3
                0448           + eosJMDCFw[4]*t4
                0449           + eosJMDCFw[5]*t4*t
                0450           )
                0451     # density of sea water at the surface
                0452     rho = ( rho
                0453            + s*(
                0454                  eosJMDCSw[0]
                0455                + eosJMDCSw[1]*t
                0456                + eosJMDCSw[2]*t2
                0457                + eosJMDCSw[3]*t3
                0458                + eosJMDCSw[4]*t4
                0459                )
                0460            + s3o2*(
                0461                  eosJMDCSw[5]
                0462                + eosJMDCSw[6]*t
                0463                + eosJMDCSw[7]*t2
                0464                )
                0465            + eosJMDCSw[8]*s*s
                0466           )
                0467 
                0468     rho = rho / (1. - p/bulkmodunesco(s,t,p))
                0469 
                0470     return rho
                0471 
                0472 
                0473 def bulkmodunesco(salt,theta,p):
                0474     """ Compute bulk modulus
                0475     """
                0476     # make sure arguments are floating point
83a53713c2 Oliv*0477     s = np.asarray(salt, dtype=np.float64)
                0478     t = np.asarray(theta, dtype=np.float64)
                0479     p = np.asarray(p, dtype=np.float64)
58679b5a83 Esta*0480 
                0481     # 3. secant bulk modulus K of fresh water at p = 0
                0482     eosJMDCKFw = [   1.965221e+04,
                0483                      1.484206e+02,
                0484                    - 2.327105e+00,
                0485                      1.360477e-02,
                0486                    - 5.155288e-05
                0487          ]
                0488     # 4. secant bulk modulus K of sea water at p = 0
                0489     eosJMDCKSw = [   5.467460e+01,
                0490                    - 0.603459e+00,
                0491                      1.099870e-02,
                0492                    - 6.167000e-05,
                0493                      7.944000e-02,
                0494                      1.648300e-02,
                0495                    - 5.300900e-04
                0496              ]
                0497     # 5. secant bulk modulus K of sea water at p
                0498     eosJMDCKP = [   3.239908e+00,
                0499                     1.437130e-03,
                0500                     1.160920e-04,
                0501                   - 5.779050e-07,
                0502                     2.283800e-03,
                0503                   - 1.098100e-05,
                0504                   - 1.607800e-06,
                0505                     1.910750e-04,
                0506                     8.509350e-05,
                0507                  -  6.122930e-06,
                0508                     5.278700e-08,
                0509                  -  9.934800e-07,
                0510                     2.081600e-08,
                0511                     9.169700e-10
                0512                 ]
                0513 
                0514     _check_dimensions(s,t,p)
                0515 
                0516     t2 = t*t
                0517     t3 = t2*t
                0518     t4 = t3*t
                0519 
                0520     sneg = np.where(s < 0 )
                0521 
                0522     s3o2 = s*np.sqrt(s)
                0523 
                0524     #p = pressure(i,j,k,bi,bj)*SItoBar
                0525     p2 = p*p
                0526     # secant bulk modulus of fresh water at the surface
                0527     bulkmod = ( eosJMDCKFw[0]
                0528               + eosJMDCKFw[1]*t
                0529               + eosJMDCKFw[2]*t2
                0530               + eosJMDCKFw[3]*t3
                0531               + eosJMDCKFw[4]*t4
                0532               )
                0533     # secant bulk modulus of sea water at the surface
                0534     bulkmod = ( bulkmod
                0535               + s*(      eosJMDCKSw[0]
                0536                        + eosJMDCKSw[1]*t
                0537                        + eosJMDCKSw[2]*t2
                0538                        + eosJMDCKSw[3]*t3
                0539                        )
                0540               + s3o2*(     eosJMDCKSw[4]
                0541                        + eosJMDCKSw[5]*t
                0542                        + eosJMDCKSw[6]*t2
                0543                        )
                0544                )
                0545     # secant bulk modulus of sea water at pressure p
                0546     bulkmod = ( bulkmod
                0547               + p*(      eosJMDCKP[0]
                0548                     + eosJMDCKP[1]*t
                0549                     + eosJMDCKP[2]*t2
                0550                     + eosJMDCKP[3]*t3
                0551                   )
                0552               + p*s*(    eosJMDCKP[4]
                0553                       + eosJMDCKP[5]*t
                0554                       + eosJMDCKP[6]*t2
                0555                     )
                0556               + p*s3o2*eosJMDCKP[7]
                0557               + p2*(   eosJMDCKP[8]
                0558                      + eosJMDCKP[9]*t
                0559                      + eosJMDCKP[10]*t2
                0560                    )
                0561               + p2*s*(    eosJMDCKP[11]
                0562                       + eosJMDCKP[12]*t
                0563                       + eosJMDCKP[13]*t2
                0564                      )
                0565                )
                0566 
                0567     return bulkmod
                0568 
                0569 def mdjwf(salt,theta,p,epsln=0):
                0570     """
                0571     Computes in-situ density of sea water
                0572 
                0573     Density of Sea Water using the McDougall et al. 2003 (JAOT 20)
                0574     polynomial.
                0575 
                0576     Parameters
                0577     ----------
                0578     salt : array_like
                0579         salinity [psu (PSS-78)]
                0580     theta : array_like
                0581         potential temperature [degree C (IPTS-68)];
                0582         same shape as salt
                0583     p : array_like
                0584         sea pressure [dbar]. p may have dims 1x1,
                0585         mx1, 1xn or mxn for salt(mxn)
                0586 
                0587     Returns
                0588     -------
                0589     dens : array
                0590         density [kg/m^3]
                0591 
                0592     Example
                0593     -------
                0594     >>> dens.mdjwf(35.5, 3., 3000.)
                0595     1041.83305
                0596 
                0597     Notes
                0598     -----
                0599     - McDougall et al., 2003, JAOT 20(5), pp. 730-741
                0600     - Converted to python by Gavilan on 2024-07-18
                0601     """
                0602 
                0603     # make sure arguments are floating point
83a53713c2 Oliv*0604     s = np.asarray(salt, dtype=np.float64)
58679b5a83 Esta*0605     t = np.asarray(theta, dtype=np.float64)
                0606     p = np.asarray(p, dtype=np.float64)
                0607 
                0608     _check_dimensions(s,t,p)
                0609 
                0610     s = _check_salinity(s)
                0611 
                0612     eosMDJWFnum = [   7.35212840e+00,
                0613                     - 5.45928211e-02,
                0614                       3.98476704e-04,
                0615                       2.96938239e+00,
                0616                     - 7.23268813e-03,
                0617                       2.12382341e-03,
                0618                       1.04004591e-02,
                0619                       1.03970529e-07,
                0620                       5.18761880e-06,
                0621                     - 3.24041825e-08,
                0622                     - 1.23869360e-11,
                0623                       9.99843699e+02
                0624                   ]
                0625 
                0626     eosMDJWFden = [   7.28606739e-03,
                0627                     - 4.60835542e-05,
                0628                       3.68390573e-07,
                0629                       1.80809186e-10,
                0630                       2.14691708e-03,
                0631                     - 9.27062484e-06,
                0632                     - 1.78343643e-10,
                0633                       4.76534122e-06,
                0634                       1.63410736e-09,
                0635                       5.30848875e-06,
                0636                     - 3.03175128e-16,
                0637                     - 1.27934137e-17,
                0638                       1.00000000e+00
                0639                   ]
                0640 
                0641     t1    = t
                0642     t2    = t1*t1
                0643     s1    = s
                0644     p1    = p
                0645 
                0646     sp5 = np.sqrt(s1)
                0647     p1t1=p1*t1
                0648 
                0649     num = ( eosMDJWFnum[11]
                0650             + t1*(eosMDJWFnum[0]
                0651                   + t1*(eosMDJWFnum[1] + eosMDJWFnum[2]*t1) )
                0652         + s1*(eosMDJWFnum[3]
                0653                   + eosMDJWFnum[4]*t1  + eosMDJWFnum[5]*s1)
                0654         + p1*(eosMDJWFnum[6] + eosMDJWFnum[7]*t2
                0655                   + eosMDJWFnum[8]*s1
                0656               + p1*(eosMDJWFnum[9] + eosMDJWFnum[10]*t2) )
                0657     )
                0658     den = ( eosMDJWFden[12]
                0659             + t1*(eosMDJWFden[0]
                0660               + t1*(eosMDJWFden[1]
                0661                     + t1*(eosMDJWFden[2] + t1*eosMDJWFden[3] ) ) )
                0662             + s1*(eosMDJWFden[4]
                0663               + t1*(eosMDJWFden[5]
                0664                     + eosMDJWFden[6]*t2)
                0665               + sp5*(eosMDJWFden[7] + eosMDJWFden[8]*t2) )
                0666         + p1*(eosMDJWFden[9]
                0667               + p1t1*(eosMDJWFden[10]*t2 + eosMDJWFden[11]*p1) )
                0668     )
                0669 
                0670     denom = 1.0/(epsln+den)
83a53713c2 Oliv*0671     rho = num*denom
58679b5a83 Esta*0672 
                0673     return rho
                0674 
                0675 def teos10(salt,theta,p,epsln=0):
                0676     """
                0677     Computes in-situ density of sea water
                0678 
                0679     Density of Sea Water using TEOS-10.
                0680 
                0681     Parameters
                0682     ----------
                0683     salt  : array_like
                0684             absolute salinity [g/kg]
                0685     theta : array_like
                0686             conservative temperature [degree C (IPTS-68)];
                0687             same shape as s
                0688     p : array_like
                0689         sea pressure [dbar]. p may have dims 1x1,
                0690         mx1, 1xn or mxn for s(mxn)
                0691 
                0692     Returns
                0693     -------
                0694     dens : array
                0695         density [kg/m^3]
                0696 
                0697     Example
                0698     -------
                0699     >>> dens.teos10(35.5, 3., 3000.)
                0700     1041.70578
                0701 
                0702     Notes
                0703     -----
                0704     - Converted to python by Gavilan on 2024-07-18
                0705     """
                0706 
                0707     # make sure arguments are floating point
83a53713c2 Oliv*0708     sa = np.asarray(salt, dtype=np.float64)
                0709     ct = np.asarray(theta, dtype=np.float64)
                0710     p = np.asarray(p, dtype=np.float64)
58679b5a83 Esta*0711 
                0712     _check_dimensions(sa,ct,p)
                0713 
                0714     sa = _check_salinity(sa)
                0715 
                0716     teos = [   9.998420897506056e+02,
                0717                2.839940833161907e00,
                0718              - 3.147759265588511e-02,
                0719                1.181805545074306e-03,
                0720              - 6.698001071123802e00,
                0721              - 2.986498947203215e-02,
                0722                2.327859407479162e-04,
                0723              - 3.988822378968490e-02,
                0724                5.095422573880500e-04,
                0725              - 1.426984671633621e-05,
                0726                1.645039373682922e-07,
                0727              - 2.233269627352527e-02,
                0728              - 3.436090079851880e-04,
                0729                3.726050720345733e-06,
                0730              - 1.806789763745328e-04,
                0731                6.876837219536232e-07,
                0732              - 3.087032500374211e-07,
                0733              - 1.988366587925593e-08,
                0734              - 1.061519070296458e-11,
                0735                1.550932729220080e-10,
                0736                1.000000000000000e00,
                0737                2.775927747785646e-03,
                0738              - 2.349607444135925e-05,
                0739                1.119513357486743e-06,
                0740                6.743689325042773e-10,
                0741              - 7.521448093615448e-03,
                0742              - 2.764306979894411e-05,
                0743                1.262937315098546e-07,
                0744                9.527875081696435e-10,
                0745              - 1.811147201949891e-11,
                0746              - 3.303308871386421e-05,
                0747                3.801564588876298e-07,
                0748              - 7.672876869259043e-09,
                0749              - 4.634182341116144e-11,
                0750                2.681097235569143e-12,
                0751                5.419326551148740e-06,
                0752              - 2.742185394906099e-05,
                0753              - 3.212746477974189e-07,
                0754                3.191413910561627e-09,
                0755              - 1.931012931541776e-12,
                0756              - 1.105097577149576e-07,
                0757                6.211426728363857e-10,
                0758              - 1.119011592875110e-10,
                0759              - 1.941660213148725e-11,
                0760              - 1.864826425365600e-14,
                0761                1.119522344879478e-14,
                0762              - 1.200507748551599e-15,
                0763                6.057902487546866e-17,
                0764            ]
                0765 
                0766     sqrtsa = np.sqrt(sa)
                0767 
                0768     rhoNum = (teos[0]
                0769               + ct*(teos[1] + ct*(teos[2] + teos[3]*ct))
                0770               + sa*(teos[4] + ct*(teos[5] + teos[6]*ct)
                0771               + sqrtsa*(teos[7] + ct*(teos[8]
                0772               + ct*(teos[9] + teos[10]*ct))))
                0773               + p*(teos[11] + ct*(teos[12] + teos[13]*ct)
                0774               + sa*(teos[14] + teos[15]*ct)
                0775               + p*(teos[16] + ct*(teos[17] + teos[18]*ct) + teos[19]*sa)))
                0776 
                0777     den = (teos[20]
                0778            + ct*(teos[21] + ct*(teos[22] + ct*(teos[23] + teos[24]*ct)))
                0779            + sa*(teos[25] + ct*(teos[26] + ct*(teos[27]
                0780            + ct*(teos[28] + teos[29]*ct)))
                0781            + teos[35]*sa
                0782            + sqrtsa*(teos[30] + ct*(teos[31] + ct*(teos[32]
                0783            + ct*(teos[33] + teos[34]*ct)))))
                0784            + p*(teos[36] + ct*(teos[37] + ct*(teos[38] + teos[39]*ct))
                0785            + sa*(teos[40] + teos[41]*ct)
                0786            + p*(teos[42] + ct*(teos[43] + teos[44]*ct + teos[45]*sa)
                0787            + p*(teos[46] + teos[47]*ct))))
                0788 
                0789     rhoden = 1.0/(epsln+den)
                0790 
                0791     rho = rhoNum*rhoden
                0792 
                0793     return rho