Python implementation of the CSIRO seawater toolbox for calculating properties of sea water using EOS-80 equation of state
npx @tessl/cli install tessl/pypi-seawater@3.3.0A Python implementation of the CSIRO seawater toolbox for calculating properties of sea water using the EOS-80 equation of state. The package provides oceanographic calculations based on UNESCO 1981 and UNESCO 1983 formulas, supporting the fundamental properties and derived quantities needed for oceanographic research and marine science applications.
pip install seawaterimport seawater as swImport specific functions:
from seawater import dens, svel, ptmp, saltimport seawater as sw
import numpy as np
# Define oceanographic conditions
salinity = 35.0 # psu (PSS-78)
temperature = 15.0 # °C (ITS-90)
pressure = 100.0 # db (decibars)
latitude = 45.0 # degrees
# Calculate basic seawater properties
density = sw.dens(salinity, temperature, pressure)
sound_velocity = sw.svel(salinity, temperature, pressure)
potential_temperature = sw.ptmp(salinity, temperature, pressure)
print(f"Density: {density:.3f} kg/m³")
print(f"Sound velocity: {sound_velocity:.2f} m/s")
print(f"Potential temperature: {potential_temperature:.3f} °C")
# Calculate depth from pressure
depth = sw.dpth(pressure, latitude)
print(f"Depth: {depth:.1f} m")
# Calculate potential density at surface reference
pot_density = sw.pden(salinity, temperature, pressure, pr=0)
print(f"Potential density: {pot_density:.3f} kg/m³")The seawater library organizes oceanographic calculations into distinct functional modules:
All functions support NumPy array inputs with broadcasting, enabling efficient processing of oceanographic datasets while maintaining compatibility with MATLAB's SEAWATER-3.3 toolbox.
Fundamental equation of state calculations for seawater density, temperature, pressure, and salinity relationships. These functions implement the UNESCO 1983 algorithms that form the foundation of oceanographic property calculations.
def dens(s, t, p): ...
def dens0(s, t): ...
def pden(s, t, p, pr=0): ...
def ptmp(s, t, p, pr=0): ...
def temp(s, pt, p, pr=0): ...
def salt(r, t, p): ...
def svel(s, t, p): ...
def cp(s, t, p): ...
def alpha(s, t, p, *, pt=False): ...
def beta(s, t, p, *, pt=False): ...Ocean circulation and dynamic oceanography calculations including geostrophic velocities, Brünt-Väisälä frequency, and potential vorticity analysis for understanding ocean currents and stability.
def bfrq(s, t, p, lat=None): ...
def svan(s, t, p=0): ...
def gpan(s, t, p): ...
def gvel(ga, lat, lon): ...Additional oceanographic calculations including distance and bearing calculations, gas solubilities, Coriolis effects, and wave velocities for comprehensive marine environment analysis.
def dist(lat, lon, units="km"): ...
def f(lat): ...
def satO2(s, t): ...
def satN2(s, t): ...
def satAr(s, t): ...
def swvel(length, depth): ...Low-level support functions for conductivity calculations, temperature scale conversions, and specialized oceanographic computations that support the main EOS-80 calculations.
def cndr(s, t, p): ...
def salds(rtx, delt): ...
def salrp(r, t, p): ...
def salrt(t): ...
def sals(rt, t): ...
def smow(t): ...
def seck(s, t, p=0): ...
def T68conv(T90): ...
def T90conv(t, t_type="T68"): ...Physical and oceanographic constants used throughout the calculations:
# Gravity and Earth parameters
gdef = 9.8 # m/s²
earth_radius = 6371000.0 # m
OMEGA = 7.292e-5 # rad/s
# Unit conversions
db2Pascal = 1e4
Kelvin = 273.15
DEG2NM = 60.0
NM2KM = 1.8520
deg2rad = π/180.0
rad2deg = 180.0/π
# Reference conductivity
c3515 = 42.914 # S/m at S=35 psu, T=15°C, P=0 dbarStandard parameter conventions used across all functions:
s - Salinity [psu (PSS-78)]t - Temperature [°C (ITS-90)]p - Pressure [db (decibars)]lat - Latitude [decimal degrees]lon - Longitude [decimal degrees]depth - Depth [meters]pr - Reference pressure [db], defaults to 0 (surface)The library uses the ITS-90 temperature scale for all input and output temperatures. Temperature scale conversions from legacy oceanographic data (IPTS-68, IPTS-48) are handled internally by the library functions when needed for compatibility with historical algorithms.
Important: The seawater library is deprecated in favor of the GSW (Gibbs SeaWater) library which implements the more modern TEOS-10 equation of state. This library is maintained for compatibility with legacy scripts and to facilitate transition to TEOS-10.