Gibbs Sea Water Oceanographic Toolbox of TEOS-10 implemented in Rust
Gibbs Sea Water Oceanographic Toolbox of TEOS-10 implemented in Rust - Published in JOSS (2024)
Science Score: 98.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 9 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Keywords from Contributors
Repository
Unofficial Gibbs Sea Water Oceanographic Toolbox of TEOS-10 in Rust
Basic Info
- Host: GitHub
- Owner: castelao
- License: other
- Language: Rust
- Default Branch: main
- Homepage: https://docs.rs/gsw/
- Size: 898 KB
Statistics
- Stars: 20
- Watchers: 5
- Forks: 5
- Open Issues: 3
- Releases: 5
Topics
Metadata Files
README.md
Unofficial TEOS-10 GSW Oceanographic Toolbox in Rust
GSW for microcontrollers and full computers.
Note that we do follow TEOS-10 manual and references, but this library is not endorsed by TEOS-10 committee.
The initial motivation for developing GSW-rs was to support pure Rust firmware for microcontrollers used in autonomous oceanography platforms -- such as underwater gliders and Argo floats. Rust stands out as an ideal solution due to its robustness and reliability complemented by an integrated testing system and a robust package manager to handle dependencies. Our Rust implementation achieves speeds comparable with C while capitalizing on Rust's explicit and intuitive syntax which makes it an optimal choice for scientific applications.
We have already implemented approximately 53 of the public functions described on TEOS-10, and we do intend to eventually cover all of them. While we're working on that, we'll keep an inventory list.
Talks
We presented about goals and progress (as of Apr 2022) at the SEA Improving Scientific Software 2022, slides available here.
Minimum supported Rust version
Currently the minimum supported Rust version is 1.74.0
Installing
This crate was developed as a library, thus it is intended to be 'imported' by
other libraries or used by applications. The recommended way to install Rust is
using rustup. Check the book
Rust Programming Language for more details.
To include GSW in another crate:
shell
cargo add gsw
To be sure it works properly in your platform, clone this repository and run:
cargo test
which will compile the library and run all the tests.
Features
From the Cargo Book: "Cargo 'features' provide a mechanism to express conditional compilation and optional dependencies.". The features defined in GSW-rs are:
- capi: Include the C-API so that GSW-rs can be accessed as it was a C-library. For instance, the other GSW implementations based on GSW-C could be linked with GSW-rs instead by using this feature.
- compat: Reproduces the GSW-Matlab implementation for compatibility.
- invalidasnan: Returns NaN values on failure. The default behavior is to return an error.
- nodgdz: Ignores vertical variations of gravity, i.e. no dependency on z. This might be useful on some numerical models.
- std: Activate the Rust standard library. The default implementation does not rely on std so it can run in embedded systems.
For example, to compile it compatible with the official Matlab library:
shell
cargo build --features compat
Repository structure
For anyone learning Rust, this repository might be overwhelming. We are doing many things here, hence more files and directories that would be strictly necessary.
- The
Cargo.tomlandsrcare the fundamental Rust components. The first one contains some metadata describing the crate, while the second one groups the source code. This is the core of the crate.- Note that in
srcwe group the modules following the TEOS-10 library card. We also isolate the constants, while avoiding repetition. - The
src/lib.rsis the starting point of the library. - We split the tests so that those are close to the target functions. Usually all the unit tests would go together somewhere, but here, each function has so many tests that it would be an extra work to debug and maintain. Also, we add reference cases described in the scientific literature.
- Note that in
- Validation tests are grouped outside the
src, in thetests, which uses the referencedata. convert_refdatais an auxiliary crate. We don't intend to publish that one since it is only used to support GSW-rs. The GSW-Matlab provides a reference dataset, which we can use to validate our library. Since our goal is to also work with microcontrollers, we have to format that dataset in such a way that it can be used in microcontrollers, thus validated. There you'll find its ownCargo.tomlandsrc. We use postcard to encode it.- We use FFI to expose our library, so it can be used outside as if it was a
C-library. For instance, to test it, we link the official GSW-Python with our
Rust library (GSW-rs) instead of the traditional GSW-C, and run the Python
tests. Take a look on
.github/workflows/gsw-python.ymlto see how we link GSW-Python with GSW-rs. The directoriesutils,include,assets, andexamples/usage-from-care all related to that. - Integration tests are developed in
tests, using the specially encoded verification values (usingconvert_refdata) intests/datato validate our results. Note that there is one file per module, which are small enough to fit in the stack memory of resource-limited systems.
License
Licensed under the 3-Clause BSD License (LICENSE)
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the LICENSE, shall be licensed as above, without any additional terms or conditions.
Contributions should be done through GitHub, by forking the repository, creating a new branch, and pushing that new branch back as a Pull Request. Tests covering the new feature or bugfix must be included, and if relevant, the documentation updated. If not familiar with the procedure, we encourage to contact us and we will walk you through the process. Every contribution is valuable and will be recognized.
A note on tests. We don't follow the typical Rust pattern of grouping all the tests of the module together. As a scientific library, and a large one, we tend to keep tests right after the target tested, so it is easy to verify if a certain function covers the desired behavior. Whenever possible, we also add tests confirming specific values described in the literature.
A note on references: Please review and add the relevant literature for each function. It is particularly important to verify the coefficients and the valid range in the original literature.
Citation
If you use this library we kindly ask to cite all the three following references:
Castelao, G., & Irber, L. (2024). Gibbs Sea Water Oceanographic Toolbox of TEOS-10 implemented in Rust. Journal of Open Source Software, 9(93), 5988, https://doi.org/10.21105/joss.05988
text
@article{Castelao2024,
doi = {10.21105/joss.05988},
url = {https://doi.org/10.21105/joss.05988},
year = {2024},
publisher = {The Open Journal},
volume = {9},
number = {93},
pages = {5988},
author = {Guilherme P. Castelao and Luiz Irber},
title = {Gibbs Sea Water Oceanographic Toolbox of TEOS-10 implemented in Rust},
journal = {Journal of Open Source Software}
}
Why should you also cite the two following references? We do appreciate you recognizing our efforts developing this library citing the reference above, but we can't take any credit for the theory behind it. There is a long list of publications that resulted in all these relations explored in this library. Although we encourage you to study and cite the ones relevant to your work, you should at least cite the two following ones. The manual 56 that summarizes all those publications, and the 'Getting started' publication which presents how to use the Toolbox.
IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of seawater - 2010: Calculation and use of thermodynamic properties. Intergovernmental - Oceanographic Commission, Manuals and Guides No. 56, UNESCO (English), 196 pp.
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.
As we review and expand this library, we add the relevant specific references within each function. You can find those in our source code or the manual.
Owner
- Name: Guilherme Castelão
- Login: castelao
- Kind: user
- Location: CO
- Company: @NREL
- Website: www.castelao.net
- Repositories: 80
- Profile: https://github.com/castelao
multi-class: PhD in Physical Oceanography, offshore solo sailor, Rustacean and Pythonista.
JOSS Publication
Gibbs Sea Water Oceanographic Toolbox of TEOS-10 implemented in Rust
Tags
oceanographyCitation (CITATION.cff)
cff-version: 1.2.0
message: If you use this software, please cite it using these metadata.
title: 'Gibbs Sea Water Oceanographic Toolbox of TEOS-10 implemented in Rust'
authors:
- given-names: Guilherme
family-names: Castelao
affiliation: Scripps Institution of Oceanography - UC San Diego
orcid: https://orcid.org/0000-0002-6765-0708
- given-names: Luiz
family-names: Irber
affiliation: UC Davis
orcid: https://orcid.org/0000-0003-4371-9659
version: 0.2.0
doi: 10.21105/joss.05988
date-released: 2023-12-21
repository-code: https://github.com/castelao/GSW-rs
license: BSD-3-Clause
GitHub Events
Total
- Watch event: 3
- Delete event: 2
- Push event: 27
- Pull request review event: 1
- Pull request event: 3
- Create event: 3
Last Year
- Watch event: 3
- Delete event: 2
- Push event: 27
- Pull request review event: 1
- Pull request event: 3
- Create event: 3
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Guilherme Castelão | g****e@c****t | 60 |
| Luiz Irber | l****r | 10 |
| Jacob Wood | 7****U | 5 |
| dependabot[bot] | 4****] | 3 |
| brycemines | 1****s | 1 |
| Michal Sojka | m****a@c****z | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 3
- Total pull requests: 81
- Average time to close issues: 14 days
- Average time to close pull requests: about 1 month
- Total issue authors: 2
- Total pull request authors: 7
- Average comments per issue: 3.67
- Average comments per pull request: 1.19
- Merged pull requests: 73
- Bot issues: 0
- Bot pull requests: 2
Past Year
- Issues: 0
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: about 2 hours
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.5
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- wentasah (2)
- efiring (1)
Pull Request Authors
- castelao (61)
- luizirber (14)
- JMdoubleU (12)
- dependabot[bot] (3)
- brycemines (1)
- castelao-scoot (1)
- wentasah (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cargo 22,367 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 18
- Total maintainers: 2
crates.io: gsw
TEOS-10 v3.06.12 Gibbs Seawater Oceanographic Toolbox in Rust
- Documentation: https://docs.rs/gsw/
- License: BSD-3-Clause
-
Latest release: 0.2.3
published 5 months ago
Rankings
Dependencies
- 153 dependencies
- criterion 0.3 development
- heapless 0.7 development
- inline-c 0.1 development
- postcard 0.7.0 development
- serde 1.0.126 development
- libc 0.2
- libm 0.2.1
- thiserror 1.0.24
- actions/checkout v2 composite
- benchmark-action/github-action-benchmark v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions-rs/cargo v1 composite
- actions-rs/toolchain v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- codecov/codecov-action v3 composite
- actions-rs/toolchain v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v3 composite
- actions/upload-artifact v1 composite
- openjournals/openjournals-draft-action master composite
