Example #1
0
def rho_sp(cond, temp, pres, lat=46.0, lon=-124.5):
    """density and salinity from a CTD.
    
    Returns in-situ density and practical salinity from 
    conductivity, temperature, pressure, latitude, and 
    longitude as reported from any standard CTD.
    
    Usage:
        Rho, SP = rho_sp(cond, temp, pres, lat, lon)
        
        where
        
        Rho = in-situ density, [kg/m^3]
        SP = practical salinity, [pss]
        cond = conductivity, [mS/cm]
        temp = temperature, [deg C]
        pres = pressure, [dbar]
        lat = latitude, decimal degrees +N
        lon = longitude, decimal degrees +E
    """
    SP = gsw.sp_from_c(cond, temp, pres)
    SA = gsw.sa_from_sp(SP, pres, lon, lat)
    CT = gsw.ct_from_t(SA, temp, pres)
    Rho = gsw.rho(SA, CT, pres)
    return Rho, SP
Example #2
0
def data_l2_density(conductivity, temp,pressure, lat, lon):
    '''
    '''
    from pygsw import vectors as gsw
    # 
    sp = gsw.sp_from_c(conductivity, temp, pressure)
    sa = gsw.sa_from_sp(sp, pressure, lon, lat)
    rho = gsw.rho(sa, temp, pressure)
    return rho
Example #3
0
def data_l2_density(conductivity, temp, pressure, lat, lon):
    '''
    '''
    from pygsw import vectors as gsw
    #
    sp = gsw.sp_from_c(conductivity, temp, pressure)
    sa = gsw.sa_from_sp(sp, pressure, lon, lat)
    rho = gsw.rho(sa, temp, pressure)
    return rho
Example #4
0
 def test_vector_values(self):
     self.assertTrue( self.validate('gswv.alpha', C.alpha_ca,gswv.alpha(sa,ct,p),2.62460550806784356e-4))
     self.assertTrue( self.validate("gswv.sa_from_sp", C.sa_from_sp_ca, gswv.sa_from_sp(sp,p,lon,lat), 35.671358392019094e0))
     self.assertTrue( self.validate("gswv.sstar_from_sp", C.sstar_from_sp_ca, gswv.sstar_from_sp(sa,p,lon,lat), 35.866946753006239e0))
     self.assertTrue( self.validate("gswv.ct_from_t", C.ct_from_t_ca, gswv.ct_from_t(sa,t,p),  14.930280459895560e0))
     self.assertTrue( self.validate("gswv.deltasa_from_sp", C.deltasa_from_sp_ca, gswv.deltasa_from_sp(sp,p,lon,lat),  3.96067773336028495e-3))
     self.assertTrue( self.validate("gswv.sr_from_sp", C.sr_from_sp_ca, gswv.sr_from_sp(sp),  35.667397714285734e0))
     self.assertTrue( self.validate("gswv.sp_from_sr", C.sp_from_sr_ca, gswv.sp_from_sr(sr),  35.333387933015295e0))
     self.assertTrue( self.validate("gswv.sp_from_sa", C.sp_from_sa_ca, gswv.sp_from_sa(sa,p,lon,lat), 35.528504019167094e0))
     self.assertTrue( self.validate("gswv.sstar_from_sa", C.sstar_from_sa_ca, gswv.sstar_from_sa(sa,p,lon,lat), 35.694648791860907e0))
     self.assertTrue( self.validate("gswv.sp_from_sstar", C.sp_from_sstar_ca, gswv.sp_from_sstar(sstar,p,lon,lat), 35.334761242083573e0))
     self.assertTrue( self.validate("gswv.sa_from_sstar", C.sa_from_sstar_ca, gswv.sa_from_sstar(sstar,p,lon,lat), 35.505322027120805e0))
     self.assertTrue( self.validate("gswv.pt_from_ct", C.pt_from_ct_ca, gswv.pt_from_ct(sa,ct), 20.023899375975017e0))
     self.assertTrue( self.validate("gswv.t_from_ct", C.t_from_ct_ca, gswv.t_from_ct(sa,ct,p), 20.079820359223014e0))
     self.assertTrue( self.validate("gswv.ct_from_pt", C.ct_from_pt_ca, gswv.ct_from_pt(sa,pt), 14.976021403957613e0))
     self.assertTrue( self.validate("gswv.pt0_from_t", C.pt0_from_t_ca, gswv.pt0_from_t(sa,t,p),  14.954241363902305e0))
     self.assertTrue( self.validate("gswv.pt_from_t", C.pt_from_t_ca, gswv.pt_from_t(sa,t,p,p_ref), 14.969381237883740e0))
     self.assertTrue( self.validate("gswv.rho", C.rho_ca, gswv.rho(sa,ct,p), 1026.4562376198473e0))
     self.assertTrue( self.validate("gswv.alpha", C.alpha_ca, gswv.alpha(sa,ct,p), 2.62460550806784356e-4))
     self.assertTrue( self.validate("gswv.beta", C.beta_ca, gswv.beta(sa,ct,p), 7.29314455934463365e-4 ))
     self.assertTrue( self.validate("gswv.specvol", C.specvol_ca, gswv.specvol(sa,ct,p), 9.74225654586897711e-4 ))
     self.assertTrue( self.validate("gswv.specvol_anom", C.specvol_anom_ca, gswv.specvol_anom(sa,ct,p), 2.90948181201264571e-6 ))
     self.assertTrue( self.validate("gswv.sound_speed", C.sound_speed_ca, gswv.sound_speed(sa,ct,p), 1527.2011773569989e0 ))
     self.assertTrue( self.validate("gswv.internal_energy", C.internal_energy_ca, gswv.internal_energy(sa,ct,p), 79740.482561720783e0 ))
     self.assertTrue( self.validate("gswv.enthalpy", C.enthalpy_ca, gswv.enthalpy(sa,ct,p), 82761.872939932495e0 ))
     self.assertTrue( self.validate("gswv.dynamic_enthalpy", C.dynamic_enthalpy_ca, gswv.dynamic_enthalpy(sa,ct,p),  2924.5137975399025e0 ))
     self.assertTrue( self.validate("gswv.ct_freezing", C.ct_freezing_ca, gswv.ct_freezing(sa,p,saturation_fraction), -2.1801450326174852e0))
     self.assertTrue( self.validate("gswv.t_freezing", C.t_freezing_ca, gswv.t_freezing(sa,p,saturation_fraction), -2.1765521998023516e0))
     self.assertTrue( self.validate("gswv.latentheat_melting", C.latentheat_melting_ca, gswv.latentheat_melting(sa,p), 329330.54839618353e0))
     self.assertTrue( self.validate("gswv.latentheat_evap_ct", C.latentheat_evap_ct_ca, gswv.latentheat_evap_ct(sa,ct), 2450871.0228523901e0))
     self.assertTrue( self.validate("gswv.latentheat_evap_t", C.latentheat_evap_t_ca, gswv.latentheat_evap_t(sa,t), 2462848.2895522709e0))
     self.assertTrue( self.validate("gswv.rho_t_exact", C.rho_t_exact_ca, gswv.rho_t_exact(sa,t,p), 1027.7128170207150e0))
     self.assertTrue( self.validate("gswv.pot_rho_t_exact", C.pot_rho_t_exact_ca, gswv.pot_rho_t_exact(sa,t,p,p_ref), 1026.8362655887486e0))
     self.assertTrue( self.validate("gswv.alpha_wrt_t_exact", C.alpha_wrt_t_exact_ca, gswv.alpha_wrt_t_exact(sa,t,p), 2.19066952410728916e-4))
     self.assertTrue( self.validate("gswv.beta_const_t_exact", C.beta_const_t_exact_ca, gswv.beta_const_t_exact(sa,t,p),  7.44744841648729426e-4))
     self.assertTrue( self.validate("gswv.specvol_t_exact", C.specvol_t_exact_ca, gswv.specvol_t_exact(sa,t,p), 9.73034473676164815e-4))
     self.assertTrue( self.validate("gswv.sound_speed_t_exact", C.sound_speed_t_exact_ca, gswv.sound_speed_t_exact(sa,t,p), 1512.2053940303056e0))
     self.assertTrue( self.validate("gswv.kappa_t_exact", C.kappa_t_exact_ca, gswv.kappa_t_exact(sa,t,p), 4.25506953386609075e-010))
     self.assertTrue( self.validate("gswv.enthalpy_t_exact", C.enthalpy_t_exact_ca, gswv.enthalpy_t_exact(sa,t,p), 62520.680485510929e0))
     self.assertTrue( self.validate("gswv.entropy_t_exact", C.entropy_t_exact_ca, gswv.entropy_t_exact(sa,t,p), 212.30166821093002e0))
     self.assertTrue( self.validate("gswv.cp_t_exact", C.cp_t_exact_ca, gswv.cp_t_exact(sa,t,p), 3982.7832563441461e0))
     self.assertTrue( self.validate("gswv.delta_sa_ref", C.delta_sa_ref_ca, gswv.delta_sa_ref(p,lon,lat), 3.87660373016291727e-3))
     self.assertTrue( self.validate("gswv.fdelta", C.fdelta_ca, gswv.fdelta(p,lon,lat), 1.49916256924158942e-004))
     self.assertTrue( self.validate("gswv.sa_from_sp_baltic", C.sa_from_sp_ca, gswv.sa_from_sp_baltic(sp,long_bs,lat_bs) , 35.666154857142850e0))
     self.assertTrue( self.validate("gswv.sp_from_sa_baltic", C.sp_from_sa_ca, gswv.sp_from_sa_baltic(sa,long_bs,lat_bs), 35.533769845749660e0))
    def execute(input=None, context=None, config=None, params=None, state=None):
        """
        Dependencies
        ------------
        PRACSAL, PRESWAT_L1, longitude, latitude, TEMPWAT_L1

        Algorithms used
        ------------
        1. PRACSAL = gsw_SP_from_C((CONDWAT_L1 * 10),TEMPWAT_L1,PRESWAT_L1)
        2. absolute_salinity = gsw_SA_from_SP(PRACSAL,PRESWAT_L1,longitude,latitude)
        3. conservative_temperature = gsw_CT_from_t(absolute_salinity,TEMPWAT_L1,PRESWAT_L1)
        4. DENSITY = gsw_rho(absolute_salinity,conservative_temperature,PRESWAT_L1)

        Reference
        ------------
        The calculations below are based on the following spreadsheet document:
        https://docs.google.com/spreadsheet/ccc?key=0Au7PUzWoCKU4dDRMeVI0RU9yY180Z0Y5U0hyMUZERmc#gid=0

        """
        lat = params['lat']
        lon = params['lon']
        stream_def_id = params['stream_def']


        rdt = RecordDictionaryTool.load_from_granule(input)
        out_rdt = RecordDictionaryTool(stream_definition_id=stream_def_id)

        out_rdt['time'] = rdt['time']

        conductivity = rdt['conductivity']
        pressure = rdt['pressure']
        temperature = rdt['temp']
        log.debug('L2 transform using L1 values: temp %s, pressure %s, conductivity %s',
                  temperature, pressure, conductivity)

        latitude = np.ones(conductivity.shape) * lat
        longitude = np.ones(conductivity.shape) * lon

        log.debug("Using latitude: %s, longitude: %s", latitude, longitude)

        # Doing: PRACSAL = gsw_SP_from_C((CONDWAT_L1 * 10),TEMPWAT_L1,PRESWAT_L1)
        pracsal = gsw.sp_from_c(conductivity * 10, temperature, pressure)
        old_pracsal = SP_from_cndr(conductivity * 10, t=temperature, p=pressure)

        log.debug("CTDBP Density algorithm calculated the pracsal (practical salinity) values: %s (old: %s)", pracsal, old_pracsal)

        # Doing: absolute_salinity = gsw_SA_from_SP(PRACSAL,PRESWAT_L1,longitude,latitude)
        absolute_salinity = gsw.sa_from_sp(pracsal, pressure, longitude, latitude)
        old_absolute_salinity = SA_from_SP(old_pracsal, pressure, longitude, latitude)
        log.debug('absolute_salinity = SA_from_SP(pracsal=%s, pressure=%s, longitude=%s, latitude=%s)=%s (old value: %s)',
                  pracsal, pressure, longitude, latitude, absolute_salinity, old_absolute_salinity)

        log.debug("CTDBP Density algorithm calculated the absolute_salinity (actual salinity) values: %s", absolute_salinity)

        conservative_temperature = gsw.ct_from_t(absolute_salinity, temperature, pressure)
        old_conservative_temperature = conservative_t(old_absolute_salinity, temperature, pressure)
        log.debug("CTDBP Density algorithm calculated the conservative temperature values: %s (old value: %s)",
                  conservative_temperature, old_conservative_temperature)

        # Doing: DENSITY = gsw_rho(absolute_salinity,conservative_temperature,PRESWAT_L1)
        dens_value = gsw.rho(absolute_salinity, conservative_temperature, pressure)
        old_dens_value = rho(old_absolute_salinity, old_conservative_temperature, pressure)
        log.debug("Calculated density values: %s (old: %s)", dens_value, old_dens_value)

        for key, value in rdt.iteritems():
            if key in out_rdt:
                if key=='conductivity' or key=='temp' or key=='pressure':
                    continue
                out_rdt[key] = value[:]

        out_rdt['density'] = dens_value

        return out_rdt.to_granule()
def do2_salinity_correction(DO, do_t, P, T, SP, lat, lon, pref=0):
    """
    Description:

        Salinity and pressure corrected dissolved oxygen concentration.
        OOI L2 data product DOCONCS.

    Usage:

        DOc = do2_salinity_correction(DO,do_t,P,T,SP,lat,lon, pref=0)

            where

        DOc = corrected dissolved oxygen [micro-mole/kg].
        DO = uncorrected dissolved oxygen [micro-mole/L].
        do_t = Oxygen sensor temperature [deg C].
        P = PRESWAT water pressure [dbar]. (see
            1341-00020_Data_Product_Spec_PRESWAT). Interpolated to the
            same timestamp as DO.
        T = TEMPWAT water temperature [deg C]. (see
            1341-00010_Data_Product_Spec_TEMPWAT). Interpolated to the
            same timestamp as DO.
        SP = PRACSAL practical salinity [unitless]. (see
            1341-00040_Data_Product_Spec_PRACSAL)
        lat, lon = latitude and longitude of the instrument [degrees].
        pref = pressure reference level for potential density [dbar].
            The default is 0 dbar.

    Example:
        DO = 433.88488978325478
        do_t = 1.97
        P = 5.4000000000000004
        T = 1.97
        SP = 33.716000000000001
        lat,lon = -52.82, 87.64

        DOc = do2_salinity_correction(DO,do_t,P,T,SP,lat,lon, pref=0)
        print DO
        > 335.967894709

    Implemented by:
        2013-04-26: Stuart Pearce. Initial Code.

    References:
         OOI (2012). Data Product Specification for Oxygen Concentration
            from "Stable" Instruments. Document Control Number
            1341-00520. https://alfresco.oceanobservatories.org/ (See:
            Company Home >> OOI >> Controlled >> 1000 System Level
            >> 1341-00520_Data_Product_SPEC_DOCONCS_OOI.pdf)

    """

    # density calculation from GSW toolbox
    SA = gsw.sa_from_sp(SP, P, lon, lat)
    CT = gsw.ct_from_t(SA, T, P)
    pdens = gsw.rho(SA, CT, pref)  # potential referenced to p=0

    # Convert from volume to mass units:
    DO = ne.evaluate('1000*DO/pdens')

    # Pressure correction:
    DO = ne.evaluate('(1 + (0.032*P)/1000) * DO')

    # Salinity correction:
    S0 = 0
    ts = ne.evaluate('log((298.15-do_t)/(273.15+do_t))')
    B0 = -6.24097e-3
    B1 = -6.93498e-3
    B2 = -6.90358e-3
    B3 = -4.29155e-3
    C0 = -3.11680e-7
    Bts = ne.evaluate('B0 + B1*ts + B2*ts**2 + B3*ts**3')
    DO = ne.evaluate('exp((SP-S0)*Bts + C0*(SP**2-S0**2)) * DO')
    return DO
Example #7
0
    def execute(input=None, context=None, config=None, params=None, state=None):
        """
        Dependencies
        ------------
        PRACSAL, PRESWAT_L1, longitude, latitude, TEMPWAT_L1

        Algorithms used
        ------------
        1. PRACSAL = gsw_SP_from_C((CONDWAT_L1 * 10),TEMPWAT_L1,PRESWAT_L1)
        2. absolute_salinity = gsw_SA_from_SP(PRACSAL,PRESWAT_L1,longitude,latitude)
        3. conservative_temperature = gsw_CT_from_t(absolute_salinity,TEMPWAT_L1,PRESWAT_L1)
        4. DENSITY = gsw_rho(absolute_salinity,conservative_temperature,PRESWAT_L1)

        Reference
        ------------
        The calculations below are based on the following spreadsheet document:
        https://docs.google.com/spreadsheet/ccc?key=0Au7PUzWoCKU4dDRMeVI0RU9yY180Z0Y5U0hyMUZERmc#gid=0

        """
        lat = params['lat']
        lon = params['lon']
        stream_def_id = params['stream_def']


        rdt = RecordDictionaryTool.load_from_granule(input)
        out_rdt = RecordDictionaryTool(stream_definition_id=stream_def_id)

        out_rdt['time'] = rdt['time']

        conductivity = rdt['conductivity']
        pressure = rdt['pressure']
        temperature = rdt['temp']

        latitude = np.ones(conductivity.shape) * lat
        longitude = np.ones(conductivity.shape) * lon

        log.debug("Using latitude: %s,\n longitude: %s", latitude, longitude)

        # Doing: PRACSAL = gsw_SP_from_C((CONDWAT_L1 * 10),TEMPWAT_L1,PRESWAT_L1)
        pracsal = gsw.sp_from_c(conductivity * 10, temperature, pressure)

        log.debug("CTDBP Density algorithm calculated the pracsal (practical salinity) values: %s", pracsal)

        # Doing: absolute_salinity = gsw_SA_from_SP(PRACSAL,PRESWAT_L1,longitude,latitude)
        absolute_salinity = gsw.sa_from_sp(pracsal, pressure, longitude, latitude)

        log.debug("CTDBP Density algorithm calculated the absolute_salinity (actual salinity) values: %s", absolute_salinity)

        conservative_temperature = gsw.ct_from_t(absolute_salinity, temperature, pressure)

        log.debug("CTDBP Density algorithm calculated the conservative temperature values: %s", conservative_temperature)

        # Doing: DENSITY = gsw_rho(absolute_salinity,conservative_temperature,PRESWAT_L1)
        dens_value = gsw.rho(absolute_salinity, conservative_temperature, pressure)

        log.debug("Calculated density values: %s", dens_value)

        for key, value in rdt.iteritems():
            if key in out_rdt:
                if key=='conductivity' or key=='temp' or key=='pressure':
                    continue
                out_rdt[key] = value[:]

        out_rdt['density'] = dens_value

        return out_rdt.to_granule()
Example #8
0
def do2_salinity_correction(DO, P, T, SP, lat, lon, pref=0):
    """
    Description:

        Calculates the data product DOXYGEN_L2 (renamed from DOCONCS_L2) from DOSTA
        (Aanderaa) instruments by correcting the the DOCONCS_L1 data product for
        salinity and pressure effects and changing units.

    Usage:

        DOc = do2_salinity_correction(DO,P,T,SP,lat,lon, pref=0)

            where

        DOc = corrected dissolved oxygen [micro-mole/kg], DOXYGEN_L2
        DO = uncorrected dissolved oxygen [micro-mole/L], DOCONCS_L1
        P = PRESWAT water pressure [dbar]. (see
            1341-00020_Data_Product_Spec_PRESWAT). Interpolated to the
            same timestamp as DO.
        T = TEMPWAT water temperature [deg C]. (see
            1341-00010_Data_Product_Spec_TEMPWAT). Interpolated to the
            same timestamp as DO.
        SP = PRACSAL practical salinity [unitless]. (see
            1341-00040_Data_Product_Spec_PRACSAL)
        lat, lon = latitude and longitude of the instrument [degrees].
        pref = pressure reference level for potential density [dbar].
            The default is 0 dbar.

    Example:
        DO = 433.88488978325478
        do_t = 1.97
        P = 5.4000000000000004
        T = 1.97
        SP = 33.716000000000001
        lat,lon = -52.82, 87.64

        DOc = do2_salinity_correction(DO,P,T,SP,lat,lon, pref=0)
        print DO
        > 335.967894709

    Implemented by:
        2013-04-26: Stuart Pearce. Initial Code.
        2015-08-04: Russell Desiderio. Added Garcia-Gordon reference.

    References:
        OOI (2012). Data Product Specification for Oxygen Concentration
            from "Stable" Instruments. Document Control Number
            1341-00520. https://alfresco.oceanobservatories.org/ (See:
            Company Home >> OOI >> Controlled >> 1000 System Level
            >> 1341-00520_Data_Product_SPEC_DOCONCS_OOI.pdf)

        "Oxygen solubility in seawater: Better fitting equations", 1992,
        Garcia, H.E. and Gordon, L.I. Limnol. Oceanogr. 37(6) 1307-1312.
        Table 1, 5th column.
    """

    # density calculation from GSW toolbox
    SA = gsw.sa_from_sp(SP, P, lon, lat)
    CT = gsw.ct_from_t(SA, T, P)
    pdens = gsw.rho(SA, CT, pref)  # potential referenced to p=0

    # Convert from volume to mass units:
    DO = ne.evaluate('1000*DO/pdens')

    # Pressure correction:
    DO = ne.evaluate('(1 + (0.032*P)/1000) * DO')

    # Salinity correction (Garcia and Gordon, 1992, combined fit):
    S0 = 0
    ts = ne.evaluate('log((298.15-T)/(273.15+T))')
    B0 = -6.24097e-3
    B1 = -6.93498e-3
    B2 = -6.90358e-3
    B3 = -4.29155e-3
    C0 = -3.11680e-7
    Bts = ne.evaluate('B0 + B1*ts + B2*ts**2 + B3*ts**3')
    DO = ne.evaluate('exp((SP-S0)*Bts + C0*(SP**2-S0**2)) * DO')
    return DO
Example #9
0
def do2_salinity_correction(DO, P, T, SP, lat, lon, pref=0):
    """
    Description:

        Calculates the data product DOXYGEN_L2 (renamed from DOCONCS_L2) from DOSTA
        (Aanderaa) instruments by correcting the the DOCONCS_L1 data product for
        salinity and pressure effects and changing units.

    Usage:

        DOc = do2_salinity_correction(DO,P,T,SP,lat,lon, pref=0)

            where

        DOc = corrected dissolved oxygen [micro-mole/kg], DOXYGEN_L2
        DO = uncorrected dissolved oxygen [micro-mole/L], DOCONCS_L1
        P = PRESWAT water pressure [dbar]. (see
            1341-00020_Data_Product_Spec_PRESWAT). Interpolated to the
            same timestamp as DO.
        T = TEMPWAT water temperature [deg C]. (see
            1341-00010_Data_Product_Spec_TEMPWAT). Interpolated to the
            same timestamp as DO.
        SP = PRACSAL practical salinity [unitless]. (see
            1341-00040_Data_Product_Spec_PRACSAL)
        lat, lon = latitude and longitude of the instrument [degrees].
        pref = pressure reference level for potential density [dbar].
            The default is 0 dbar.

    Example:
        DO = 433.88488978325478
        do_t = 1.97
        P = 5.4000000000000004
        T = 1.97
        SP = 33.716000000000001
        lat,lon = -52.82, 87.64

        DOc = do2_salinity_correction(DO,P,T,SP,lat,lon, pref=0)
        print DO
        > 335.967894709

    Implemented by:
        2013-04-26: Stuart Pearce. Initial Code.
        2015-08-04: Russell Desiderio. Added Garcia-Gordon reference.

    References:
        OOI (2012). Data Product Specification for Oxygen Concentration
            from "Stable" Instruments. Document Control Number
            1341-00520. https://alfresco.oceanobservatories.org/ (See:
            Company Home >> OOI >> Controlled >> 1000 System Level
            >> 1341-00520_Data_Product_SPEC_DOCONCS_OOI.pdf)

        "Oxygen solubility in seawater: Better fitting equations", 1992,
        Garcia, H.E. and Gordon, L.I. Limnol. Oceanogr. 37(6) 1307-1312.
        Table 1, 5th column.
    """

    # density calculation from GSW toolbox
    SA = gsw.sa_from_sp(SP, P, lon, lat)
    CT = gsw.ct_from_t(SA, T, P)
    pdens = gsw.rho(SA, CT, pref)  # potential referenced to p=0

    # Convert from volume to mass units:
    DO = ne.evaluate('1000*DO/pdens')

    # Pressure correction:
    DO = ne.evaluate('(1 + (0.032*P)/1000) * DO')

    # Salinity correction (Garcia and Gordon, 1992, combined fit):
    S0 = 0
    ts = ne.evaluate('log((298.15-T)/(273.15+T))')
    B0 = -6.24097e-3
    B1 = -6.93498e-3
    B2 = -6.90358e-3
    B3 = -4.29155e-3
    C0 = -3.11680e-7
    Bts = ne.evaluate('B0 + B1*ts + B2*ts**2 + B3*ts**3')
    DO = ne.evaluate('exp((SP-S0)*Bts + C0*(SP**2-S0**2)) * DO')
    return DO