gsw-python

Python implementation of TEOS-10 GSW based on ufunc wrappers of GSW-C

https://github.com/teos-10/gsw-python

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 9 committers (22.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.6%) to scientific vocabulary

Keywords from Contributors

oceanography argo-floats argo argo-data closember mesh ocean networks physical-oceanography

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 83% confidence
Last synced: 4 months ago · JSON representation

Repository

Python implementation of TEOS-10 GSW based on ufunc wrappers of GSW-C

Basic Info
Statistics
  • Stars: 159
  • Watchers: 18
  • Forks: 33
  • Open Issues: 4
  • Releases: 18
Created almost 9 years ago · Last pushed 5 months ago
Metadata Files
Readme License Zenodo

README.md

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:

shell pip install gsw

conda users will find binaries on conda-forge,

shell conda install gsw --channel conda-forge

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

shell 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

bibtex @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 gswdatav3_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/cgsw/gswteos-10.h.
  • make_wrapped_ufuncs.py: Generates gsw/wrappedufuncs.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/methodbodies.c and src/methoddefentries.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/checkfunctions.py, which is used by gsw/tests/testcheck_functions.py; see the docstring of the former for more info.

Testing

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

Owner

  • Name: Thermodynamic Equation Of Seawater - 2010 (TEOS-10)
  • Login: TEOS-10
  • Kind: organization
  • Email: help@TEOS-10.org

GitHub Events

Total
  • Create event: 10
  • Release event: 1
  • Issues event: 3
  • Watch event: 13
  • Delete event: 11
  • Issue comment event: 18
  • Push event: 9
  • Pull request review comment event: 1
  • Pull request event: 27
  • Pull request review event: 4
  • Fork event: 3
Last Year
  • Create event: 10
  • Release event: 1
  • Issues event: 3
  • Watch event: 13
  • Delete event: 12
  • Issue comment event: 18
  • Push event: 9
  • Pull request review comment event: 1
  • Pull request event: 28
  • Pull request review event: 4
  • Fork event: 3

Committers

Last synced: 4 months ago

All Time
  • Total Commits: 387
  • Total Committers: 9
  • Avg Commits per committer: 43.0
  • Development Distribution Score (DDS): 0.506
Past Year
  • Commits: 58
  • Committers: 5
  • Avg Commits per committer: 11.6
  • Development Distribution Score (DDS): 0.655
Top Committers
Name Email Commits
Filipe Fernandes o****f@g****m 191
Eric Firing e****g@h****u 114
dependabot[bot] 4****] 43
mauzey1 m****1@l****v 17
Andrew Barna a****a@g****m 10
Romain Caneill r****l@e****g 9
Ryan Abernathey r****y@g****m 1
Hood Chatham r****m@g****m 1
Guilherme Castelão g****e@c****t 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 38
  • Total pull requests: 124
  • Average time to close issues: 7 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 26
  • Total pull request authors: 11
  • Average comments per issue: 5.34
  • Average comments per pull request: 1.42
  • Merged pull requests: 109
  • Bot issues: 0
  • Bot pull requests: 46
Past Year
  • Issues: 1
  • Pull requests: 19
  • Average time to close issues: 1 day
  • Average time to close pull requests: 2 days
  • Issue authors: 1
  • Pull request authors: 4
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.68
  • Merged pull requests: 17
  • Bot issues: 0
  • Bot pull requests: 12
Top Authors
Issue Authors
  • rcaneill (5)
  • ocefpaf (5)
  • mcepl (2)
  • efiring (2)
  • FudgeMunkey (2)
  • pvthinker (2)
  • eldobbins (1)
  • ratnaksha (1)
  • breichl (1)
  • bkatiemills (1)
  • jbusecke (1)
  • ggardet (1)
  • davjfish (1)
  • hoodmane (1)
  • emmaworthington (1)
Pull Request Authors
  • dependabot[bot] (72)
  • ocefpaf (62)
  • efiring (18)
  • rcaneill (4)
  • DocOtak (3)
  • mauzey1 (2)
  • castelao (1)
  • janjaapmeijer (1)
  • FudgeMunkey (1)
  • hoodmane (1)
  • pvthinker (1)
Top Labels
Issue Labels
Pull Request Labels
Bot (70)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 18,708 last-month
  • Total docker downloads: 325
  • Total dependent packages: 40
    (may contain duplicates)
  • Total dependent repositories: 159
    (may contain duplicates)
  • Total versions: 58
  • Total maintainers: 3
pypi.org: gsw

Gibbs Seawater Oceanographic Package of TEOS-10

  • Versions: 20
  • Dependent Packages: 24
  • Dependent Repositories: 93
  • Downloads: 18,708 Last month
  • Docker Downloads: 325
Rankings
Dependent packages count: 0.6%
Dependent repos count: 1.5%
Average: 2.2%
Docker downloads count: 2.5%
Downloads: 4.3%
Maintainers (3)
Last synced: 4 months ago
proxy.golang.org: github.com/teos-10/gsw-python
  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 4 months ago
proxy.golang.org: github.com/TEOS-10/GSW-Python
  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 4 months ago
conda-forge.org: gsw
  • Versions: 10
  • Dependent Packages: 16
  • Dependent Repositories: 66
Rankings
Dependent packages count: 4.0%
Dependent repos count: 4.3%
Average: 18.2%
Stargazers count: 32.2%
Forks count: 32.5%
Last synced: 4 months ago

Dependencies

requirements-dev.txt pypi
  • check-manifest * development
  • dask * development
  • doctr * development
  • numpydoc * development
  • pytest * development
  • setuptools_scm * development
  • sphinx * development
  • sphinx_rtd_theme * development
  • twine * development
  • xarray * development
.github/workflows/cibuildwheel.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/upload-artifact v3 composite
  • pypa/cibuildwheel v2.12.0 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/deploy-docs.yml actions
  • actions/checkout v3 composite
  • mamba-org/provision-with-micromamba v15 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/pre-commit.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pre-commit/action v3.0.0 composite
.github/workflows/tarball-tests.yml actions
  • actions/checkout v3 composite
  • mamba-org/provision-with-micromamba v15 composite
.github/workflows/tests.yml actions
  • actions/checkout v3 composite
  • mamba-org/provision-with-micromamba v15 composite