Skip to content

Commit

Permalink
feat(gsw): upgrade gsw to node 20
Browse files Browse the repository at this point in the history
  • Loading branch information
blake-gr authored Dec 19, 2024
2 parents 4f09887 + 5701802 commit 956555e
Show file tree
Hide file tree
Showing 87 changed files with 20,570 additions and 19,785 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tag & Release

on:
workflow_dispatch:

jobs:
release:
name: Release ${{ github.event.inputs.TAG_NAME }}
runs-on: ubuntu-latest
steps:
- uses: Greenroom-Robotics/workflow-telemetry-action@main

- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: 'true'

- uses: pnpm/action-setup@v4

- name: Login to npm github packages
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
registry-url: https://npm.pkg.github.com
scope: '@greenroom-robotics'
token: ${{ secrets.API_TOKEN_GITHUB }}

- name: Install npm dependencies
run: pnpm install --frozen-lockfile
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}

- name: Release
id: release
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.API_TOKEN_GITHUB }}
MATRIX_ARCH: ${{ matrix.job.arch }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm run --stream release
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/GSW-node.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

483 changes: 483 additions & 0 deletions .idea/editor.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .idea/gsw.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file removed .npmignore
Empty file.
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//npm.pkg.github.com/:_authToken=${API_TOKEN_GITHUB}
registry=https://registry.npmjs.org
@greenroom-robotics:registry=https://npm.pkg.github.com
62 changes: 0 additions & 62 deletions CHANGELOG.md

This file was deleted.

81 changes: 28 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,60 @@ Nodejs interface to Gibbs-SeaWater (GSW) Oceanographic Toolbox in C++.

Link to the homepage: [Teos-10.org](https://www.teos-10.org/)

This library includes all modules:
This library includes all modules:

- TeosBase
- TeosIce
- TeosSea

## Requirments
- Node: 12
## Requirements

- Node: 20
- cmake
- gcc
- python (2 or 3)

Unfortunatly this library is only compatable with Node versions up to 12. It may build on later versions but tested working on node 12.
- python 3

Currently this has only been tested on linux Ubuntu 20.
Currently, this has only been tested on linux Ubuntu 24.04.

## TeosNode
Install with

Install with

```bash
$ npm i gsw-node # or
$ yarn add gsw-node
$ pnpm add @greenroom-robotics/gsw_cpp
$ pnpm add @greenroom-robotics/gsw_node
```

If you clone this repo you can install using:

```bash
$ yarn
$ pnpm i
```

Then test with:

```
$ yarn test
$ pnpm test
```

### Use

Avaliable functions are generated and avaliable in: [lib-types.d.ts](lib-types.d.ts)

The use of gsw_z_from_p is shown in the below example, this is an example from https://www.teos-10.org/pubs/gsw/html/gsw_z_from_p.html
The use of `gsw_z_from_p` is shown in the below example, this is an example
from https://www.teos-10.org/pubs/gsw/html/gsw_z_from_p.html

**Note** if you see the definition of `gsw_z_from_p` in the source code you will notice that there are two optional
arguments, in the bindings of this function these defaults do not transfer over, in the following typescript code you
can see that these defaults need to be added .

**Note** if you see the definition of gsw_z_from_p in the source code you will notice that there are two optional arguments, in the bindings of this function these defaults do not transfer over, in the following typescript code you can see that these defaults need to be added .
```c++
double gsw_z_from_p(double p, double lat, double geo_strf_dyn_height=0.0,
double sea_surface_geopotential=0.0);
```
```ts
import { TeosBase } from 'gsw-node'
```typescript
import {TeosBase} from '@greenroom-robotics/gsw_node'
const teosBase = new TeosBase()
const p = 10
Expand All @@ -59,44 +68,10 @@ const result = teosBase.gsw_z_from_p(p, lat, 0, 0)
```

## TeosCpp
This is a copy of the source code from Teos-10, downloadable from https://www.teos-10.org/software.htm

This has been converted from use with codeblocks build chain to use cmake, which may be of use to others. You can build this with the following steps
### Building
```bash
$ cd TeosCpp && mkdir build
$ cd build
$ cmake ..
$ make
```
Run very very basic the example code using:
```bash
./test-teos
```
This is a copy of the source code from Teos-10, downloadable from https://www.teos-10.org/software.htm

## Other notes
It seems that some of the functions are missing or not complete in the Cpp source code, these are listed below.

### TeosBase
```c++
method(gsw_CT_freezing); Not implemented fully in source
method(gsw_Hill_ratio_at_SP2); Seems to be an error in code, looks like the capitals are different in c++ code.
method(gsw_internal_energy_second_derivatives); Not implemented in source
method(gsw_rho_second_derivatives_wrt_enthalpy_CT_exact); Not implemented in source
method(gsw_SA_freezing_from_CT_poly); Not implemented in source, only in header definition.
method(gsw_SSO); Dosent seem to be implemented in c++ code
```

### TeosSea
```c++
method(gsw_geo_strf_dyn_height); # Currently contains errors TODO: Look into @zacpullen
method(gsw_geo_strf_dyn_height_1);
method(gsw_linear_interp_SA_CT_for_dh);
```

### TeosIce
```c++
method(gsw_pressure_coefficient_ice);
method(gsw_t_freezing_poly); // There are two definitions here, this is not compatable with nbind binding. If you need this you can change the funcitons to have different names in the source code.
method(gsw_t_freezing_poly); // See above
```
Not all functions have been implemented for node js.
To add new functions update [gsw-node](packages/gsw_cpp/gsw-node)
Loading

0 comments on commit 956555e

Please sign in to comment.