Skip to main content

GSW-Python

Tests Wheels DOI

This Python implementation of the Thermodynamic Equation of Seawater 2010 (TEOS-10) is based primarily on numpy ufunc wrappers of the GSW-C implementation. This library replaces the original python-gsw pure-python implementation. The primary reasons for this change are that by building on the C implementation we reduce code duplication and we gain an immediate update to the 75-term equation.
Additional benefits include a major increase in speed, a reduction in memory usage, and the inclusion of more functions. The penalty is that a C (or MSVC C++ for Windows) compiler is required to build the package from source.

Warning: this is for Python >=3.8 only.

Documentation is provided at https://teos-10.github.io/GSW-Python/.

For the core functionality, we use an auto-generated C extension module to wrap the C functions as numpy ufuncs, and then use an autogenerated Python module to add docstrings and handle masked arrays. 165 scalar C functions with only double-precision arguments and return values are wrapped as ufuncs, and 158 of these are exposed in the gsw namespace with an additional wrapper in Python.

A hand-written wrapper is used for one C function, and others are re-implemented directly in Python instead of being wrapped. Additional functions present in GSW-Matlab but not in GSW-C may be re-implemented in Python, but there is no expectation that all such functions will be provided.

Installation

Pip users can install the pre-built wheels with:

pip install gsw

conda users will find binaries on conda-forge,

conda install gsw --channel conda-forge

The development version of the package can be installed from a clone of the repo using

pip install .

Citation

If you use GSW-Python, please cite: McDougall, T.J. and P.M. Barker, 2011: Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox, 28pp., SCOR/IAPSO WG127, ISBN 978-0-646-55621-5

@book{mcdougall2011getting,
  author = {McDougall, T. J. and Barker, P. M.},
  title = {Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox},
  year = {2011},
  pages = {28},
  publisher = {SCOR/IAPSO WG127},
  isbn = {978-0-646-55621-5}
}

Note for xarray users

A wrapper around gsw called gsw-xarray exists for xarray. It adds CF compliant attributes when possible, units, and name.

Note on generating the docstrings

The autogenerated docstrings are checked with codespell in the CIs. When autogenerating them we need to run pre-commit run --all-files and fix the documentation issues found.

Development notes

You will need a suitable compiler: gcc or clang for unix-like systems, or the MSVC compiler set used for Python itself on Windows. For Windows, some of the source code has been modified to C++ because the MSVC C compiler does not support the C99 complex data type used in original GSW-C.

The subdirectory ('tools') contains modules and scripts for maintaining the code that is autogenerated from the upstream GSW-Matlab and GSW-C repos. The scripts are to be run from this directory; they make assumptions about where they are, and about where upstream repos are. Specifically, it is assumed that GSW-Matlab, GSW-C, and GSW-Python git repos are all in the same base directory.

Scripts

  • copy_from_GSW-C.py: copies the relevant .c and .h files from a sibling GSW-C repo, if the latter are newer.
  • mat2npz.py: generates an npz file in gsw/tests containing the test data and check values from the gsw_data_v3_0.mat file in the sibling GSW-Matlab repo.
  • make_ufuncs.py: Generates the src/_ufuncs.c file to turn the scalar C functions into numpy ufuncs. It writes ufuncs.list in the current directory as a record of the ufunc names. Functions are identified as ufunc candidates based on their signatures, parsed from src/c_gsw/gswteos-10.h.
  • make_wrapped_ufuncs.py: Generates gsw/_wrapped_ufuncs.py based on the output of make_ufuncs.py. It adds docstrings constructed from the Matlab help text.
  • fix_wrapped_ufunc_typos.py: Fixes docstring typos that have been identified, but not yet fixed, in the GSW-Matlab repo.
  • codegen: Runs the last three python scripts.

Modules

  • c_header_parser.py: Functions for taking apart the function declarations in gswteos-10.h.
  • matlab_parser.py: Functions specifically for reading the GSW-Matlab function signatures and for splitting out the help text.
  • docstring_parts.py: Blocks of text for assembling docstrings.
  • docstring_utils.py: Functions for assembling docstrings in numpydoc format.
  • categories.py: Functions for listing gsw function names by category. This is not used by any of the other functions or scripts, but was used when initially categorizing the functions for inclusion in submodules.

Notes

  • In addition to the generated src/_ufuncs.c, there are two C files that are hand-written: src/method_bodies.c and src/method_def_entries.c. These are imported by src/_ufuncs.c. They handle some C functions that are not suitable for ufuncs.
  • Specialized Matlab parsing is also done in gsw/tests/check_functions.py, which is used by gsw/tests/test_check_functions.py; see the docstring of the former for more info.

Testing

To test, after installation, run "pytest --pyargs gsw".

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsw-3.6.18.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gsw-3.6.18-cp312-cp312-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows x86-64

gsw-3.6.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

gsw-3.6.18-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gsw-3.6.18-cp312-cp312-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

gsw-3.6.18-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

gsw-3.6.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

gsw-3.6.18-cp311-cp311-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gsw-3.6.18-cp311-cp311-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

gsw-3.6.18-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10Windows x86-64

gsw-3.6.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

gsw-3.6.18-cp310-cp310-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

gsw-3.6.18-cp310-cp310-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

gsw-3.6.18-cp39-cp39-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.9Windows x86-64

gsw-3.6.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

gsw-3.6.18-cp39-cp39-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

gsw-3.6.18-cp39-cp39-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file gsw-3.6.18.tar.gz.

File metadata

  • Download URL: gsw-3.6.18.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18.tar.gz
Algorithm Hash digest
SHA256 16011b2a5fb4441c26928ee7aa2f94d02f93c2953ec150e523517cdc654fc927
MD5 2dedc48a66912e7ae8c7aa8e82986a7f
BLAKE2b-256 ea13609e6c0604008c01e6e66af14ec19ca6dd4dfe2a7a50d140183de6523608

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: gsw-3.6.18-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 67a67246ba8c87b33ccb2bd1011ddcc213ad5c2d0874c0c5e35014168f2b992e
MD5 78b24db4d8a4e993076e7192fe6733ef
BLAKE2b-256 5637620d2fe454ac78e2e0fe89cdf100a5f4bd11a20b8677fc568b3c1ea2490d

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2a15d3a54b1e516bba50077518231d9a9aa58d0c42ca494265548ee0275de21
MD5 3e9ca60e5f36200a20e517024d19c205
BLAKE2b-256 5cdd26c1608f752a0a5ea34723b3153dfeef3b57cedc5806feb72db2c1dcd264

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b205a1702dfe7e8d3b3ab13d08c858d4106d9ec3aca7b374e01ccfa9f14b93a
MD5 5a0fb863c9c20abe7d995b50a459f183
BLAKE2b-256 de38b712e9ff1d24aca2b473417a8a69e78cbe8ead9e5b305c540476c8990528

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 206e7202a4cf7d11a18bf40d39728832e2c2f43dce9baa1189c7c3c75a44d40b
MD5 8feb81691c038f4b072315f5cfe235fe
BLAKE2b-256 659070982c124f1e7d8a0b1ab863eac71a2891a30584cc017660a347ab99c71e

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: gsw-3.6.18-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6913c720ad65a7ac268a83a458d022bac945a6a8b61c35ec7302baef55428219
MD5 d12bd627d4801ececc4a758a2fd2f250
BLAKE2b-256 3f7703ca343c689df376939c95c6f77c170110ba0ae52a49b73ca4794b87c443

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7dc7d3f7ae5173d006c43c83bd101f27b8c480b875db5e87ef8ca61e01a8e7dd
MD5 15030b284ea5b4c922753f537b68f3eb
BLAKE2b-256 aa2021be0493c39fde3ae940c41adbb5177e28f86c5b1428c06be44289bd1516

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e16247adbd80e2f72f46cbf44e7498a78827b2483bf451c6ba478acaacf192f1
MD5 da6f56ef2fbd22bc1c50379dabaa9bdb
BLAKE2b-256 a852171d7bbac7b8dc504cd9705b1d4be49b7fc1e1ae36e5663372e6685faede

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0df3c1a73e52aec10c5ca79671a5b9a4df4d8e8607ea7ba9ff11607a4d475955
MD5 5c4d086941560abe263be1f565fb3d7a
BLAKE2b-256 7d16d7a072e7a82bcc6b4e48b4114bc310af283bd163793e732f23b1a1890168

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: gsw-3.6.18-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aacc2e0ac03bf1816cd230093b83eb942ad3f260e9bd547c46651641e7e888f1
MD5 42297413b2feb548c6134006965a96e7
BLAKE2b-256 79a626e5faa2c7c26cd83c74f6c2ec482a8886749d57282cbacaa910e5c1fa0f

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fc4fdb7b0e8f1ea0c0ff7c38f568e1566f9c71e184fefb591aa399a07d150f7
MD5 9a4323b00816860ad1acbf1caa3e0ef7
BLAKE2b-256 33ed2582872e5c5d7acb4115315c5cb4a1e5c1ab3ce922f6717f3483bce7f1a2

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c46d762dbf0734c4f0aad0c63b67c011d8ebb4b764dd405b6deeb1a4f1442a7
MD5 9a09087846c21e7fdf5ec455832f522a
BLAKE2b-256 face656f7e2b9554d62c9a5f5bf2bb4ff2d02bcbcdf1b29935fb9a3076351d21

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b4809a39c661b803323fe7ab59fd4c6348c3aba2bf8cc4c96f9d53e1ecae6256
MD5 e99c63d6a7889dc9591e8599d16fda85
BLAKE2b-256 6b1a1d8459571584025050d40fc5c4fe5ee5eac61199e3d28ed1cfd1a9b85aae

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: gsw-3.6.18-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b84ddce76a68e7c4a83448b1dff70b888de93beaef798769aa2aa05f332e9dba
MD5 28af41ce7b121fbc60b9997fcabca6c6
BLAKE2b-256 82771be879c1c7054c4eca5a93eec805d12814121493df71d49a3430b3faa998

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2aef9d7591343a3ec5d7450da4b36a679c845d3a847be3f2dc03599771a2a705
MD5 c75e4d4a44641b903e305a65f767c9c5
BLAKE2b-256 b2b314f9d32bab63152d3d9cf185352a73de38c0f7c7e98772317c4dedea1dfa

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: gsw-3.6.18-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59c8add06d5fc7809a03c902e4885f82d0a165dc1823b32fa7704b854f63cb19
MD5 68191054117ef6cacb1d9e422052fe85
BLAKE2b-256 ecf7c0a16b59a355d865ad45f0fe04108761ec48c48bb16b401f694a3bf4f23b

See more details on using hashes here.

File details

Details for the file gsw-3.6.18-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: gsw-3.6.18-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gsw-3.6.18-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 421f6c19510dc7e6d0a429853d97ef93217405b4d2e5cca13f4c7651484ea559
MD5 9c44d059a99fc338db51a0458b75f9e5
BLAKE2b-256 952750baff8c7bcf1941bf1ebdd7b664f63161cac29d4a986ae407d1fed3f9b2

See more details on using hashes here.

Release history Release notifications | RSS feed

3.6.23

7 files

3.6.22

6 files

3.6.21

6 files

3.6.20

36 files

3.6.19

21 files

This release

3.6.18 This release

17 files

3.6.17.post1

16 files

3.6.17

17 files

3.6.16.post1

16 files

3.6.16

17 files

3.4.2

16 files

3.4.0

10 files

3.3.1.post1

9 files

3.3.1

1 file

3.3.0

1 file

3.2.1

1 file

3.2.0

1 file

3.1.1

1 file

3.1.0

1 file

3.0.6

1 file

3.0.3

1 file

3.0.2

1 file

3.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page