Computes the inversion of the cyclogeostrophic balance based on a variational formulation approach, using JAX
Project description
jaxparrow
jaxparrow implements a novel approach based on a variational formulation to compute the inversion of the cyclogeostrophic balance.
It leverages the power of JAX, to efficiently solve the inversion as an optimization problem. Given the Sea Surface Height (SSH) field of an ocean system, jaxparrow estimates the velocity field that best satisfies the cyclogeostrophic balance.
Installation
The package is Pip-installable:
pip install jaxparrow
However, users with access to GPUs or TPUs should first install JAX separately in order to fully benefit from its high-performance computing capacities.
See JAX instructions.
By default, jaxparrow will install a CPU-only version of JAX if no other version is already present in the Python environment.
Usage
As a package
Two functions are directly available from jaxparrow
:
geostrophy
computes the geostrophic velocity field (returns two2darray
) from:- a SSH field (a
2darray
), - the latitude and longitude at the T points (two
2darray
), - an optional mask grid (one
2darray
).
- a SSH field (a
cyclogeostrophy
computes the cyclogeostrophic velocity field (returns two2darray
) from:- a SSH field (a
2darray
), - the latitude and longitude at the T points (two
2darray
), - an optional mask grid (one
2darray
).
- a SSH field (a
Because jaxparrow uses C-grids the velocity fields are represented on two grids (U and V), and the SSH on one grid (T).
In a Python script, assuming that the input grids have already been initialised / imported, it would resort to:
from jaxparrow import cyclogeostrophy, geostrophy
u_geos, v_geos = geostrophy(ssh_t=ssh,
lat_t=lat, lon_t=lon,
mask=mask)
u_cyclo, v_cyclo = cyclogeostrophy(ssh_t=ssh,
lat_t=lat, lon_t=lon,
mask=mask)
To vectorise the application of the geostrophy
and cyclogeostrophy
functions across an added time dimension, one aims to utilize vmap
.
However, this necessitates avoiding the use of np.ma.masked_array
.
Hence, our functions accommodate mask array
as parameter to effectively consider masked regions.
By default, the cyclogeostrophy
function relies on our variational method.
Its method
argument provides the ability to use an iterative method instead, either the one described by Penven et al., or the one by Ioannou et al..
Additional arguments also give a finer control over the three approaches hyperparameters.
See jaxparrow API documentation for more details.
Notebooks are available as step-by-step examples.
As an executable
jaxparrow is also available from the command line:
jaxparrow --conf_path conf.yml
The YAML configuration file conf.yml
instruct where input netCDF files are locally stored, and how to retrieve variables and coordinates from them.
It also provides the path of the output netCDF file. Optionally, it can specify which cyclogeostrophic approach should be applied and its hyperparameters.
An example configuration file detailing all the required and optional entries can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jaxparrow-0.2.2.tar.gz
.
File metadata
- Download URL: jaxparrow-0.2.2.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5cfcb76de7a7b08011325ae46612d0d0e8a63dcc68e85f66773a0a99310cffb |
|
MD5 | 57280fe57c0d2d68b8a69d8897d6b0ee |
|
BLAKE2b-256 | a9bf960fc85cece1c7b6987b18b44a92a001306aa78ec4c3ce63167ace9554fa |
File details
Details for the file jaxparrow-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: jaxparrow-0.2.2-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e43ae8ce34acecadca3a1e61f96332a9cfb5fc2e468caf315e1b21d273bb6fe5 |
|
MD5 | 849f8b982e92aa475ba17d8c03c449ca |
|
BLAKE2b-256 | 6cfff465e6a46b61cb014f69507428371acb213ffc6d9fdaa7225ac12ebff6fd |