eos80_conversion.py#
EOS80 functions to support legacy conversions
- seabirdscientific.eos80_conversion.adiabatic_temperature_gradient(salinity: ndarray, temperature: ndarray, pressure: ndarray) ndarray#
EOS-80 adiabatic lapse rate calculation.
This was ported from CSharedCalc::ATG()
- Parameters:
salinity – salinity data
temperature – temperature data
pressure – pressure data
- Returns:
the resulting adiabatic lapse rate
- seabirdscientific.eos80_conversion.bouyancy_frequency(temperature: ndarray, salinity: ndarray, pressure: ndarray, gravity: float)#
Calculates an N^2 value (buoyancy frequency) for the given window of temperature, salinity, and pressure, at the given latitude.
Expects temperature as ITS-90 temperature, salinity as practical salinity, and pressure as dbar, all of the same length. Performs the calculation following the SBE Data Processing formula using E0S-80 calculations for potential temp and density
- Parameters:
temperature – ITS-90 temperature values for the given window
salinity – PSS-78 practical salinity values for the given window
pressure – pressure values for the given window
gravity – gravity value
- Returns:
A single N^2 [Brunt-Väisälä (buoyancy) frequency]
- seabirdscientific.eos80_conversion.buoyancy_eos80(temperature: ndarray, salinity: ndarray, pressure: ndarray, latitude: ndarray, longitude: ndarray, window_size: float, flag_value=-9.99e-29) tuple[ndarray, ndarray, ndarray, ndarray]#
Calculates the 4 buoyancy values using the EOS-80 formula.
Same as buoyancy, but uses eos80_conversion.bouyancy_frequency (the SBE Data Processing EOS-80 calculation) instead of the TEOS-10 formula.
Data is expected to have already been binned via Bin_Average using decibar pressure bins. All arrays are expected to be the same length, except for latitude and longitude, which can be length 1.
- Parameters:
temperature – Temperature in ITS-90 degrees C
salinity – Practical salinity in PSS-78 PSU
pressure – Pressure in dbar
latitude – latitude values. If length 1, gets applied to all values.
longitude – longitude values. If length 1, gets applied to all values.
window_size – window size to use. If this number is smaller than the binned window size, round up to a minimum of 3 scans.
flag_value – Bad Flag value to use for marking bad scans. Defaults to -9.99e-29
- Returns:
a tuple of ndarrays including: buoyancy frequency squared, buoyancy frequency, stability, and scaled stability
- seabirdscientific.eos80_conversion.derive_average_sound_velocity(depth_m: ndarray, pressure: ndarray, salinity: ndarray, sound_velocity_mps: ndarray, min_pressure: float = -inf, min_salinity: float = -inf, delta_d_min: float = 0.5) ndarray#
Compute Average Sound Velocity (ASV) over a profile using EOS-80.
Data is expected to be binned by depth prior to running this function, but utilizes delta_d_min (hardcoded to 0.5 m in SBE Data Processing) to determine when to update the ASV value. Uses EOS-80 formulations for sound velocity calculations.
- Parameters:
depth_m – Depth in meters
pressure – Pressure series (used for validity and min_pressure threshold)
salinity – Salinity series (used for min_salinity threshold)
sound_velocity_mps – Sound velocity in m/s (precomputed)
min_pressure – Ignore rows where pressure < min_pressure, defaults to -inf
min_salinity – Ignore rows where salinity < min_salinity, defaults to -inf
delta_d_min – Minimum depth increment (m) from the last accepted depth to update ASV, defaults to 0.5
- Returns:
ASV in m/s at each sample. NaN before first valid ASV point
- seabirdscientific.eos80_conversion.derive_gpa(sva: ndarray, pressure: ndarray) ndarray#
Derive Geopotential Anomaly from specific volume anomaly and pressure using EOS-80.
This is a vectorized port of the legacy C++
CompGPAlogic: - For each scan, compute the change in GPA based on SVA and pressure changes - GPA is accumulated when pressure increases - Uses the average SVA between consecutive points and the pressure delta - Based on EOS-80 specific volume anomaly calculations- Parameters:
sva – specific volume anomaly values
pressure – pressure values in dbar
- Returns:
geopotential anomaly values
- seabirdscientific.eos80_conversion.derive_potential_temperature_anomaly(salinity: ndarray, temperature: ndarray, pressure: ndarray, a0: float = 0.0, a1: float = 0.0, a1multiplier: Literal['salinity', 'sigma-theta'] = 'salinity', to_standard: Literal['ITS90', 'IPTS68'] = 'ITS90', to_units: Literal['C', 'F'] = 'C') ndarray#
Derive potential temperature anomaly from practical salinity, temperature, and pressure using EOS-80 calculations.
Calculates potential temperature at reference pressure (0 dbar) and applies anomaly corrections based on the provided coefficients a0 and a1. Uses EOS-80 formulas for potential temperature and density calculations. Note that termperature uses ITS-90 C, as the seawater library converts it to IPTS-68 internally
To match SeaSoft, potential temperature is converted to the output standard and units before a0 and a1 are applied, so a0 and a1 are in the output units (e.g. deg F for to_units=’F’) and are not converted.
- Parameters:
salinity – Practical salinity in PSU (ndarray)
temperature – Temperature in ITS-90 degrees C (ndarray)
pressure – Pressure in decibars (ndarray)
a0 – Anomaly constant coefficient (float)
a1 – Anomaly multiplicative coefficient (float)
a1multiplier – Either ‘salinity’ to use salinity as the multiplier, or ‘sigma-theta’ to use density (sigma-theta) as the multiplier. Defaults to ‘salinity’.
to_standard – Output temperature standard, defaults to ITS90
to_units – Output temperature units, defaults to C
- Returns:
Potential temperature anomaly in the requested standard and units (ndarray)
- seabirdscientific.eos80_conversion.derive_sound_velocity(salinity: ndarray, temperature: ndarray, pressure: ndarray, formula: Literal['c', 'd', 'w'] = 'c') ndarray#
Derive sound velocity using the specified formula with EOS-80.
Calculates sound velocity in seawater from salinity, temperature, and pressure using the specified algorithm.
- Parameters:
salinity – Measured salinity in practical salinity units (PSU)
temperature – Temperature in IPTS-68 degrees C
pressure – Measured pressure in decibars
formula – Formula to use for calculation (‘c’, ‘d’, or ‘w’)
- Returns:
Sound velocity in m/s
- seabirdscientific.eos80_conversion.derive_specific_conductance(temperature: ndarray, conductivity: ndarray, to_units: Literal['uS/cm', 'umhos/cm', 'mS/cm', 'mmhos/cm']) ndarray#
Derive specific conductance from temperature and conductivity using EOS-80.
Calculates specific conductance using temperature and conductivity values with EOS-80 formulations. Note: ‘uS/cm’ and ‘umhos/cm’ are equivalent, as are ‘mS/cm’ and ‘mmhos/cm’. All equation information comes from SBE Data Processing code. It is intentional that ‘uS/cm’ and ‘umhos/cm’ map to the same value, same with ‘mS/cm’ and ‘mmhos/cm’
- Parameters:
temperature – Temperature values in IPTS-68 degrees C
conductivity – Conductivity values in S/m
to_units – Target units for output (uS/cm, umhos/cm, mS/cm, or mmhos/cm)
- Returns:
Specific conductance in the specified units
- seabirdscientific.eos80_conversion.derive_thermosteric_anomaly(salinity: ndarray, temperature: ndarray) ndarray#
Derive thermosteric anomaly from salinity and temperature using EOS-80.
Calculates the specific volume anomaly using EOS-80 formulations.
- Parameters:
salinity – Measured salinity in practical salinity units (PSU)
temperature – Temperature in IPTS-68 degrees C
- Returns:
Thermosteric anomaly values
- seabirdscientific.eos80_conversion.potential_temperature(salinity: ndarray, temperature: ndarray, pressure: ndarray, mean_pressure: ndarray) ndarray#
EOS-80 potential temperature calculation.
Delegates to the seawater library (seawater.ptmp).
- Parameters:
salinity – sainity data
temperature – temperature data
pressure – subset pressure data
mean_pressure – pressure data
- Returns:
calculated potential temperature data