Skip to main content

Gibbs Seawater Oceanographic Package of TEOS-10

Project description

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".

Project details


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.21.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.21-cp311-abi3-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.11+Windows x86-64

gsw-3.6.21-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gsw-3.6.21-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

gsw-3.6.21-cp311-abi3-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

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

Uploaded CPython 3.11+macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: gsw-3.6.21.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gsw-3.6.21.tar.gz
Algorithm Hash digest
SHA256 6e0609d374916b4393484b9c7b32666d36dda74d900a40d19c766484ac295efa
MD5 60c24fe614cf6597ec891f26d99f01b4
BLAKE2b-256 60f965e32588c9b7131850ad0766459e142c4de5daf2f6271be198fa079e961e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsw-3.6.21.tar.gz:

Publisher: cibuildwheel.yml on TEOS-10/GSW-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsw-3.6.21-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: gsw-3.6.21-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gsw-3.6.21-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cc504b9b77e89e50200248d086cd4e2432ee11fda2308b8cdd1e10d70338cbc2
MD5 6912a499beab8b24d5a5ced9d442cf46
BLAKE2b-256 a629ed6fb3f440ab9574e403ed6873ea7463a9109e802ad4ba6590d0e4fc5fe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsw-3.6.21-cp311-abi3-win_amd64.whl:

Publisher: cibuildwheel.yml on TEOS-10/GSW-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsw-3.6.21-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.21-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d0ef1d7490a33a4a69ca3b7d6b60f709c7c4b6c05d31d0286de706835219ac7
MD5 c4e383d667342d4b6d256c75b39b4044
BLAKE2b-256 c53154746aa297ba567345e3a9de489f8d2dd18aa9d2090a10aa641792ce9173

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsw-3.6.21-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: cibuildwheel.yml on TEOS-10/GSW-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsw-3.6.21-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gsw-3.6.21-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 345d20cc0c58c21ccd3754e3695620a988acf1d9b548cb503071247a904fac80
MD5 7407cf3741641ddd87f269934bc67b18
BLAKE2b-256 a1f18ea90d659f35e1cc452b5aa052787ac0e8d908fddba67f9a6c0c36d0199e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsw-3.6.21-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: cibuildwheel.yml on TEOS-10/GSW-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsw-3.6.21-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: gsw-3.6.21-cp311-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.11+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gsw-3.6.21-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59562f4b4cf4abaeab8058b6d90d05fcacc1d027e4d299dabc7ef21d8b6a516a
MD5 ecf556d7adbb52648f1fcfc625e06a53
BLAKE2b-256 204f6a35fe048985495d80a1c5c5e55264747ee1c815d997642f04dc6b3ad71b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsw-3.6.21-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: cibuildwheel.yml on TEOS-10/GSW-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsw-3.6.21-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gsw-3.6.21-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 200dc7bc89195608b16d9a6d24cfe02f33df79ace68309845180000975c82c03
MD5 b3261c60cb9d17290604a3ec4613543f
BLAKE2b-256 de70626fca4a1f03d999489b3601f037e6ecc53250d3a1dcae3833e7dff8e76e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsw-3.6.21-cp311-abi3-macosx_10_9_x86_64.whl:

Publisher: cibuildwheel.yml on TEOS-10/GSW-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page