Registry / data / gsw
library3.6.21pypypi✓ verified 84d ago

GSW is a Python implementation of the Thermodynamic Equation of Seawater (TEOS-10) for oceanographic computations. Current version 3.6.21, requires Python >=3.11. It provides over 200 functions for oceanographic variables, including density, salinity, sound speed, potential temperature, etc. Release cadence is sporadic, following updates to the TEOS-10 algorithms.

pip install gsw
INSTALL
IMPORT
SIG · GSW
G
gsw
datapythonv3.6.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gsw
import gsw
There is no common wrong import; just import gsw and use gsw.<function>()

Compute absolute salinity and conservative temperature from practical salinity and pressure.

import numpy as np import gsw # Example: compute absolute salinity from practical salinity SP = np.array([35.0, 35.5, 36.0]) p = np.array([0, 10, 100]) # pressure in dbar lon = np.array([-150, -150, -150]) lat = np.array([30, 30, 30]) SA = gsw.SA_from_SP(SP, p, lon, lat) print(SA) # Example: conservative temperature from potential temperature (0 dbar reference) CT = gsw.CT_from_pt(SA, 15.0) print(CT)
Debug
Known issues
gotchaGSW functions expect numpy arrays; passing plain Python lists may raise errors in some operations.
fix
Convert inputs to numpy arrays (e.g., np.array([...])).
affects: all
breakinggsw 3.0+ dropped support for Python <3.11. If you are on an older Python version, pin to gsw<3.0.
fix
Upgrade Python to 3.11+ or install gsw==2.x with pip install 'gsw<3'.
affects: >=3.0
deprecatedSome older function names (e.g., gsw.rho, gsw.alpha) have been renamed to use TEOS-10 standard names (e.g., gsw.rho_t_exact, gsw.alpha_wrt_CT_exact).
fix
Check the documentation for the exact function name; the old names are still available but may be removed in future.
affects: >=2.0
gotchaPressure must be in dbar (decibars), not in Pa. Many newcomers mistakenly pass pressure in Pa.
fix
Convert Pa to dbar by dividing by 10000.
affects: all
Errors
Common errors & fixes
ImportError: No module named gsw
gsw not installed or Python environment not activated.
fix
Run 'pip install gsw' in the correct environment.
TypeError: ufunc '...' not supported for the input types
Inputs are not numpy arrays or have incompatible dtypes (e.g., strings).
fix
Ensure all inputs are numeric numpy arrays: e.g., SP = np.array([34, 35], dtype=float).
ValueError: Invalid input: pressure must be non-negative
Negative pressure values are not physically meaningful for ocean depths.
fix
Check data; pressure must be >=0 dbar. For surface pressure use 0.
Upgrade
Version history
3.6.21latest on PyPI · released Feb 24, 2026
Audit
Dependencies
numpyrequiredAll array operations depend on numpy arrays
Agent activity
8 hits · last 30 days
node
8
Resources
gsw — pip install gsw · libregistry