コード例 #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
コード例 #2
0
ファイル: fake_data.py プロジェクト: GaulSJ/ion-functions
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
コード例 #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
コード例 #4
0
ファイル: test_pygsw.py プロジェクト: lukecampbell/pygsw
    def test_pracsal(self):

        C = np.array([34.5487, 34.7275, 34.8605, 34.6810, 34.5680, 34.5600])
        t = np.array([28.7856, 28.4329, 22.8103, 10.2600,  6.8863,  4.4036])
        p = np.array([10, 50, 125, 250, 600, 1000])

        output = gswv.sp_from_c(C,t,p)
        check_values = np.array((20.009869599086951,
                                 20.265511864874270,
                                 22.981513062527689,
                                 31.204503263727982,
                                 34.032315787432829,
                                 36.400308494388170))
        np.testing.assert_array_almost_equal(output, check_values)
コード例 #5
0
    def execute(input=None,
                context=None,
                config=None,
                params=None,
                state=None):
        """
        Dependencies
        ------------
        CONDWAT_L1, TEMPWAT_L1, PRESWAT_L1


        Algorithms used
        ---------------
        PRACSAL = gsw_SP_from_C((CONDWAT_L1 * 10),TEMPWAT_L1,PRESWAT_L1)


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

        """

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

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

        conductivity = rdt['conductivity']
        pressure = rdt['pressure']
        temperature = rdt['temp']
        sal_value = gsw.sp_from_c(conductivity * 10, temperature, pressure)

        log.debug(
            "CTDBP Salinity algorithm calculated the sp (practical salinity) values: %s",
            sal_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['salinity'] = sal_value

        return out_rdt.to_granule()
コード例 #6
0
def ctd_pracsal(c, t, p):
    """
    Description:

        OOI Level 2 Practical Salinity core data product, which is calculated
        using the Thermodynamic Equations of Seawater - 2010 (TEOS-10) Version
        3.0, with data from the conductivity, temperature and depth (CTD)
        family of instruments. This calculation is defined in the Data Product
        Specification for Salinty - DCN 1341-00040.

    Implemented by:

        2013-03-13: Christopher Wingard. Initial code.
        2013-05-10: Christopher Wingard. Minor edits to comments.

    Usage:

        SP = ctd_pracsal(c, t, p)

            where

        SP = Practical Salinity (seawater salinity, PSS-78) [unitless]
        c = conductivity (seawater conductivity) [S m-1], (see
            1341-00010_Data_Product_Spec_CONDWAT) 
        t = temperature (seawater temperature) [deg_C], (see
            1341-00030_Data_Product_Spec_TEMPWAT)
        p = pressure (sea pressure) [dbar], (see
            1341-00020_Data_Product_Spec_PRESWAT)

    References:
    
        OOI (2012). Data Product Specification for Salinty. Document Control
            Number 1341-00040. https://alfresco.oceanobservatories.org/ (See: 
            Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-00040_Data_Product_SPEC_PRACSAL_OOI.pdf)
    """
    # Convert L1 Conductivity from S/m to mS/cm
    C10 = c * 10.0
    
    # Calculate the Practical Salinity (PSS-78) [unitless]
    SP = gsw.sp_from_c(C10, t, p)
    return SP
コード例 #7
0
    def execute(input=None, context=None, config=None, params=None, state=None):
        """
        Dependencies
        ------------
        CONDWAT_L1, TEMPWAT_L1, PRESWAT_L1


        Algorithms used
        ---------------
        PRACSAL = gsw_SP_from_C((CONDWAT_L1 * 10),TEMPWAT_L1,PRESWAT_L1)


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

        """

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

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

        conductivity = rdt['conductivity']
        pressure = rdt['pressure']
        temperature = rdt['temp']
        sal_value = gsw.sp_from_c(conductivity * 10, temperature, pressure)

        log.debug("CTDBP Salinity algorithm calculated the sp (practical salinity) values: %s", sal_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['salinity'] = sal_value

        return out_rdt.to_granule()
コード例 #8
0
def ctd_pracsal(c, t, p):
    """
    Description:

        OOI Level 2 Practical Salinity core data product, which is calculated
        using the Thermodynamic Equations of Seawater - 2010 (TEOS-10) Version
        3.0, with data from the conductivity, temperature and depth (CTD)
        family of instruments.

    Implemented by:

        2013-03-13: Christopher Wingard. Initial code.
        2013-05-10: Christopher Wingard. Minor edits to comments.
        2014-01-31: Russell Desiderio. Standardized comment format.

    Usage:

        SP = ctd_pracsal(c, t, p)

            where

        SP = practical salinity, PSS-78, (PRACSAL_L2) [unitless]
        c = sea water conductivity (CONDWAT_L1) [S m-1]
        t = sea water temperature (TEMPWAT_L1) [deg_C]
        p = sea water pressure (PRESWAT_L1) [dbar]
    References:

        OOI (2012). Data Product Specification for Salinty. Document Control
            Number 1341-00040. https://alfresco.oceanobservatories.org/ (See: 
            Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-00040_Data_Product_SPEC_PRACSAL_OOI.pdf)
    """

    # Convert L1 Conductivity from S/m to mS/cm
    C10 = c * 10.0

    # Calculate the Practical Salinity (PSS-78) [unitless]
    SP = gsw.sp_from_c(C10, t, p)
    return SP
コード例 #9
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']
        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()
コード例 #10
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()
コード例 #11
0
ファイル: fake_data.py プロジェクト: GaulSJ/ion-functions
def data_l2_salinity(conductivity, temp, pressure):
    '''
    '''
    import pygsw.vectors as gsw
    sal_value = gsw.sp_from_c(conductivity, temp, pressure)
    return sal_value
コード例 #12
0
def data_l2_salinity(conductivity, temp, pressure):
    '''
    '''
    import pygsw.vectors as gsw
    sal_value = gsw.sp_from_c(conductivity, temp, pressure)
    return sal_value