pyglider.utils#
Utilities that are used for processing scripts.
Functions#
get_distance_over_ground(): Add a distance over ground variable to a netcdf structureget_glider_depth(): Get glider depth from pressure sensor.get_profiles_new(): Find profiles in a glider timeseries:get_derived_eos_raw(): Calculate salinity, potential density, density, and potential temperaturefill_metadata(): Add metadata to a Datasetnmea2deg(): Convert a NMEA float to a decimal degree float. e.g. -12640.3232 = -126.6721gappy_fill_vertical(): Fill vertical gaps from the first to last bin with data in them.oxygen_concentration_correction(): Correct oxygen signal for salinity signal
- pyglider.utils.get_distance_over_ground(ds)#
Add a distance over ground variable to a netcdf structure
- Parameters:
- dsxarray.Dataset
Must have variable
latitudeandlongitudeindexed bytimedimension.
- Returns:
- ds.xarray.Dataset
With
distance_over_groundkey.
- pyglider.utils.get_glider_depth(ds)#
Get glider depth from pressure sensor.
- Parameters:
- dsxarray.Dataset
Must have variables
pressureandlatitudeindexed bytimedimension. Assume pressure sensor in dbar.
- Returns:
- ds.xarray.Dataset
With
depthkey.
- 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 / dtwhere 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.