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.19.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

gsw-3.6.19-cp312-cp312-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

gsw-3.6.19-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.12 macOS 10.9+ x86-64

gsw-3.6.19-cp311-cp311-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

gsw-3.6.19-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

gsw-3.6.19-cp310-cp310-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

gsw-3.6.19-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

gsw-3.6.19-cp39-cp39-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

gsw-3.6.19-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for gsw-3.6.19.tar.gz
Algorithm Hash digest
SHA256 3595b686458d852444ae6f1946d260a7c8f16ba457e9061aa953cf417927423f
MD5 4683e9bb66b8ab79121db5d069d7584e
BLAKE2b-256 3a23ffb0b0622ad5f5898f1dc07786f95787704ce9e9540017b756722dc66919

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: gsw-3.6.19-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for gsw-3.6.19-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bcf0eb380f22eb22e44c9521db78be760a1126fbffd1af21b317726968eca90c
MD5 cc6eb6b7a8bf6891e7b3f83ba5189bbf
BLAKE2b-256 e079325e670fe4a91125e5aa5f7c0a3d4b8d74388012e635a97c4bf6613ac719

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5a570e4439725e8d2667e1037a053a7911128e76aee15882a058a459cf806cac
MD5 1ff0c9cd55c32a344285023db33f55cb
BLAKE2b-256 c8a3c5efa3fd211c05632a8b90c6a3d380ffc698920a9fb3e9025dc43cd025bc

See more details on using hashes here.

Provenance

File details

Details for the file gsw-3.6.19-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for gsw-3.6.19-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 320b93696d54659d7c0ded7a46911074a5000b65189d6f2d74e9d1f203476d64
MD5 c39e43cd14487b946274c521cfb2bee9
BLAKE2b-256 c6634d044aa5a6085bfac92bf823f1fe152408c7e3189a1114b2c03abe2fcf1d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ae0000fe6a4802c2767ccb4cc77fc21c1e80d39fd5102f9ecae66ad9607a92d
MD5 7756c6c5fbdaada0e9fc238ca24e703b
BLAKE2b-256 c4f1cf4c83d52dd1ba78cc3db5de29f3b518ce561583e542a919ebf52127c817

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5dff941ad55d2342b037ae3afdf74fd08ddb4f6db76a66fc543c9110e738606b
MD5 247490f8045e968989594bdb537eb9dd
BLAKE2b-256 9fa223d3f0e35bdd11f9342f843e638c3e2a8e93fb302a7c51984797a6b66446

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: gsw-3.6.19-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for gsw-3.6.19-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e660b0218806e1651a776b311eb63c17d8175259cf31f226894dd0c024d56942
MD5 7cc9165a2be8378bb1d736c31c4a3910
BLAKE2b-256 30b91fb74bc79a503215488c5fbecd0c7561e8e9e2c1fcb00c1d0c643d147e3e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fdedb58ab2f0a33cc5c00e1de672cb37621ec975232b9df1dbae5c1e89f1c57e
MD5 a5dea885e53b3c71cec29e4b455fff9d
BLAKE2b-256 3fb9f5adac68ac3d62d9069ef3b2c7086d2aff65d098702e5db2e42583e05c8d

See more details on using hashes here.

Provenance

File details

Details for the file gsw-3.6.19-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for gsw-3.6.19-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b27fe8cd46bb76a501809e2b12ac7bc6cd343512fc9a15f3e4b20115d11397f8
MD5 da8fc3c5ae5c09ef24c0bf9f6969a401
BLAKE2b-256 632edba931fd87071cf63066994515647fc5387f17f506d75ddcf12a89b87c47

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 037fc1f9dff0176c83ffe1c283ca764771246d9c00b91263dcee5479b91f3dad
MD5 56d344dcbd29aa45be8d1b11dee98921
BLAKE2b-256 2f920af184d503586a59be0f29b2ed3a29c0b7f9107675699a682fbcfd75d90d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 818a2cbe610b9ab34fc05144ea02d836fc85e646f784e992821a5be36474f0dd
MD5 0f2557e840b4d3dc6f0780c81b1054ac
BLAKE2b-256 18909528bdd11984557baee48fe9f63008c4fc02210786b0b5cfc23d79545885

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: gsw-3.6.19-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for gsw-3.6.19-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 36bbabd321666e792785700c52cef8b89fc335767918fbf707c1c74a1147eb29
MD5 1a17c380446d73440c2f21e6b039b257
BLAKE2b-256 b991b6e190c040ad31541e5a9058b49cea1f6c371400ba68e22372564bc54f14

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab63ddf958edf293471a362e1d61b6b15e6977c5a67f2c58313d5c1d301e8d7f
MD5 fc548f0fcb3d6cda15c52a933ff8e83c
BLAKE2b-256 e82bf1ac10b974fb537cccacde51405b9b02a8b46c239c918df5b435c4d411ab

See more details on using hashes here.

Provenance

File details

Details for the file gsw-3.6.19-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for gsw-3.6.19-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 21a1e64233f178954a3be86d47dd7ea65bb0143a1d1f933445da554693cfc3c8
MD5 2f11aa95bff99db22fe62598c9ea0b36
BLAKE2b-256 c686fcde64a64d9a8f4371594b5e7e2774847e336b9cdbc05e89ec4d0707f4be

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b92a2c6dbda72d93d44fb616dfda9715b5209ee510c44b3a87980b094484f19
MD5 87d70f05a3d3ee3ba662b387bae4926e
BLAKE2b-256 192e786253fde9711170f5619005ae09fe89131f938c6d4ed941a6e9092a0a79

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5ed8b28fc4371197f3d680bd0706098ca82de3caed83fcde0f7ea181d06fd859
MD5 36d0165f76fe7bb8874373a427d8f1c1
BLAKE2b-256 eb817c20f283ad734f153cb0c233963dd2f876e0d29e04962e35a50ba6a7aaa5

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: gsw-3.6.19-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for gsw-3.6.19-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ee5a2b2c33cc7a051090988fad0387c629acf2c0be8a00ba9959f440e6d045a5
MD5 32364525200bdb24d7111a7f85314e0a
BLAKE2b-256 dccb3bfaec9e4eb484b6f4bea79c3e95a8158368c96bff010cdefff650e0b867

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 779f81ecd4d68c036446d1951a899f55a707aa1333a687abdd13468360ba8da5
MD5 355242ffc9ed1fa1aa1bb18242665b0d
BLAKE2b-256 3a4c6866104fd6cd41485575d97f95fc92cf0d4d395ec4775eda62b5f523ebe6

See more details on using hashes here.

Provenance

File details

Details for the file gsw-3.6.19-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for gsw-3.6.19-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 623899a96d1c0063ee020bd2ee6553f997b801a59f5271930ddd05e28305255a
MD5 c4d378c3993eeb91fe0c96d6d25caee7
BLAKE2b-256 37b282a535ac1e765773eb0cee7f6777b82644683176c0bf9f479791b7333c4b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c93f1e4856c37a1eb261c5dfe13d5340a0e29fa1e5ac15dc999c0a5d12c2c14
MD5 3a1a46ca975d187e19449a0c3e9df22c
BLAKE2b-256 db9c44f95e73af9290e7e83d62c5ac560f7e9fe0734cdeef7174ffaa16514b67

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gsw-3.6.19-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4ea4050b02bfce185d418c2a3130cce852403e80e0f00e7f4c8d61e26217005e
MD5 a5c35b13a600ae407cac6f773381d417
BLAKE2b-256 fcf4333862b9cd7bafc6ac83fe28f0cd48111e6e6ef3647d887bdf676c9251e4

See more details on using hashes here.

Provenance

Supported by

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