Exemplo n.º 1
0
Arquivo: ctd.py Projeto: nguyandy/gdm
def calculate_practical_salinity(conductivity, temperature, pressure):
    """Calculates practical salinity given glider conductivity, temperature,
    and pressure using Gibbs gsw SP_from_C function.

    Parameters:
        timestamp, conductivity (S/m), temperature (C), and pressure (bar).

    Returns:
        salinity (psu PSS-78).
    """

    # Convert S/m to mS/cm
    ms_conductivity = conductivity * 10

    return SP_from_C(ms_conductivity, temperature, pressure)
Exemplo n.º 2
0
def calculate_practical_salinity(conductivity, temperature, pressure):
    """Calculates practical salinity given glider conductivity, temperature,
    and pressure using Gibbs gsw SP_from_C function.

    Parameters:
        conductivity (S/m), temperature (C), and pressure (dbar).

    Returns:
        salinity (psu PSS-78).
    """

    correct_sizes = (conductivity.size == temperature.size == pressure.size)
    if correct_sizes is False:
        raise ValueError('Arguments must all be the same length')

    # Convert S/m to mS/cm
    mS_conductivity = conductivity * 10

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        return SP_from_C(mS_conductivity, temperature, pressure)
Exemplo n.º 3
0
            fmt = 'f8'
            key = 'cond'
        if ext[i] in 'p':
            fmt = 'f8'
            key = 'p'
        if ext[i] in 's':
            fmt = 'f8'
            key = 'sal'

        ds[key].values = np.loadtxt(fname, usecols=i, dtype=fmt)

# If salinity was not output by the device, calculate it
if 'c' in ext and 'p' in ext and not 's' in ext:
    print("A : %s" % fname)
    # Multiply by 10 for S/m  ->  mS/cm
    ds['sal'].values = SP_from_C(ds.cond.values * 10, ds.temp.values,
                                 ds.p.values)
    ext += 's'
# If salinity was not output by the device and pressure unavailable
if 'c' in ext and not 'p' in ext and not 's' in ext:
    print("B : %s" % fname)
    # Multiply by 10 for S/m  ->  mS/cm
    ds['sal'].values = SP_from_C(ds.cond.values * 10, ds.temp.values,
                                 args.pressure)
    ext += 's'

# quality control
print(minsal, mindep, maxtemp, ext)
if mindep != 0 and 'p' in ext:
    ds = ds.where(ds.p > mindep, drop=True)
if minsal != 0 and 's' in ext:
    print("QC by salinity")