pyglider.utils#

Utilities that are used for processing scripts.

Functions#

pyglider.utils.get_distance_over_ground(ds)#

Add a distance over ground variable to a netcdf structure

Parameters:
dsxarray.Dataset

Must have variable latitude and longitude indexed by time dimension.

Returns:
ds.xarray.Dataset

With distance_over_ground key.

pyglider.utils.get_glider_depth(ds)#

Get glider depth from pressure sensor.

Parameters:
dsxarray.Dataset

Must have variables pressure and latitude indexed by time dimension. Assume pressure sensor in dbar.

Returns:
ds.xarray.Dataset

With depth key.

pyglider.utils.get_profiles_new(ds, min_dp=10.0, filt_time=100, profile_min_time=300)#

Find profiles in a glider timeseries:

Parameters:
dsxarray.Dataset

Must have time coordinate and pressure as a variable

min_dpfloat, default=10.0

Minimum distance a profile must transit to be considered a profile, in dbar.

filt_timefloat, default=100

Approximate length of time filter, in seconds. Note that the filter is really implemented by sample, so the number of samples is filt_time / dt where dt is the median time between samples in the time series.

profile_min_timefloat, default=300

Minimum time length of profile in s.

pyglider.utils.get_derived_eos_raw(ds)#

Calculate salinity, potential density, density, and potential temperature

Parameters:
dsxarray.Dataset

Must have time coordinate and temperature, conductivity, pressure, and latitude and longitude as variables.

Returns:
dsxarray.Dataset

with salinity, potential_density, density, and potential_temperature as new variables.

Notes

Thermodynamic variables derived from the Gibbs seawater toolbox import gsw.

  • salinity::

    gsw.conversions.SP_from_C(r, ds.temperature, ds.pressure)

  • potential_density::
    sa = gsw.SA_from_SP(ds[‘salinity’], ds[‘pressure’],

    ds[‘longitude’], ds[‘latitude’])

    ct = gsw.CT_from_t(sa, ds[‘temperature’], ds[‘pressure’]) ds[‘potential_density’] = ((‘time’),

    1000 + gsw.density.sigma0(sa, ct).values)

  • density::
    ds[‘density’] = ((‘time’), gsw.density.rho(

    ds.salinity, ds.temperature, ds.pressure).values)

  • potential_temperature::
    ds[‘potential_temperature’] = ((‘time’), gsw.conversions.pt0_from_t(

    ds.salinity, ds.temperature, ds.pressure).values)

pyglider.utils.fill_metadata(ds, metadata, sensor_data)#

Add metadata to a Dataset

Parameters:
dsxarray.Dataset

Dataset must have longtidue, latitude, and time values

metadatadict

dictionary of attributes to add to the global attributes. Usually taken from deployment.yml file.

sensor_datadict

dictionary of device data to add to the global attributes.

Returns:
dsxarray.Dataset

Dataset with attributes filled out.

pyglider.utils.nmea2deg(nmea)#

Convert a NMEA float to a decimal degree float. e.g. -12640.3232 = -126.6721

pyglider.utils.gappy_fill_vertical(data)#

Fill vertical gaps from the first to last bin with data in them. Applied column-wise.

data = gappy_fill_vertical(data)

pyglider.utils.oxygen_concentration_correction(ds, ncvar)#

Correct oxygen signal for salinity signal

Parameters:
dsxarray.Dataset

Should have oxygen_concentration, potential_temperature, salinity, on a time coordinate.

ncvardict

dictionary with netcdf variable definitions in it. Should have oxygen_concentration as a key, which itself should specify a reference_salinity and have correct_oxygen set to "True".

Returns:
dsxarray.Dataset

With oxygen_concentration corrected for the salinity effect.