jaxparrow


Namejaxparrow JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryComputes the inversion of the cyclogeostrophic balance based on a variational formulation approach, using JAX
upload_time2024-04-16 07:11:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache-2.0
keywords cyclogeostrophy eddy flow geostrophy jax swirl velocity
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jaxparrow

![Python](https://img.shields.io/badge/dynamic/yaml?url=https://raw.githubusercontent.com/meom-group/jaxparrow/master/.github/workflows/python-package.yml&label=Python&query=$.jobs.build.strategy.matrix["python-version"])
[![PyPi](https://img.shields.io/badge/dynamic/xml?url=https://pypi.org/rss/project/jaxparrow/releases.xml&label=PyPi&query=/rss/channel/item[1]/title)](https://pypi.org/project/jaxparrow/)
![Tests](https://github.com/meom-group/jaxparrow/actions/workflows/python-package.yml/badge.svg)
[![Docs](https://github.com/meom-group/jaxparrow/actions/workflows/python-documentation.yml/badge.svg)](https://jaxparrow.readthedocs.io/)

***jaxparrow*** implements a novel approach based on a variational formulation to compute the inversion of the cyclogeostrophic balance.

It leverages the power of [JAX](https://jax.readthedocs.io/en/latest/), 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:
```shell
pip install jaxparrow
```

**<ins>However</ins>**, 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](https://jax.readthedocs.io/en/latest/installation.html). \
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 two `2darray`) from:
  - a SSH field (a `2darray`), 
  - the latitude and longitude at the T points (two `2darray`), 
  - an optional mask grid (one `2darray`).
- `cyclogeostrophy` computes the cyclogeostrophic velocity field (returns two `2darray`) from:
  - a SSH field (a `2darray`), 
  - the latitude and longitude at the T points (two `2darray`), 
  - an optional mask grid (one `2darray`).

*Because **jaxparrow** uses [C-grids](https://xgcm.readthedocs.io/en/latest/grids.html) 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:

```python
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.*](https://doi.org/10.1016/j.dsr2.2013.10.015), or the one by [Ioannou *et al.*](https://doi.org/10.1029/2019JC015031).
Additional arguments also give a finer control over the three approaches hyperparameters. \
See **jaxparrow** [API documentation](https://jaxparrow.readthedocs.io/en/latest/api.html) for more details.

[Notebooks](https://jaxparrow.readthedocs.io/en/latest/examples.html) are available as step-by-step examples.

### As an executable

**jaxparrow** is also available from the command line:
```shell
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](https://github.com/meom-group/jaxparrow/blob/main/docs/example-conf.yml).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jaxparrow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "cyclogeostrophy, eddy, flow, geostrophy, jax, swirl, velocity",
    "author": null,
    "author_email": "Vadim Bertrand <vadim.bertrand@univ-grenoble-alpes.fr>, Victor E V Z De Almeida <victorzaia@outlook.com>, Julien Le Sommer <julien.lesommer@univ-grenoble-alpes.fr>, Emmanuel Cosme <emmanuel.cosme@univ-grenoble-alpes.fr>",
    "download_url": "https://files.pythonhosted.org/packages/af/42/9db17f282feb51f86af1e6a3eac86f070d1d4f1807613749d7c8533dfe4b/jaxparrow-0.1.4.tar.gz",
    "platform": null,
    "description": "# jaxparrow\n\n![Python](https://img.shields.io/badge/dynamic/yaml?url=https://raw.githubusercontent.com/meom-group/jaxparrow/master/.github/workflows/python-package.yml&label=Python&query=$.jobs.build.strategy.matrix[\"python-version\"])\n[![PyPi](https://img.shields.io/badge/dynamic/xml?url=https://pypi.org/rss/project/jaxparrow/releases.xml&label=PyPi&query=/rss/channel/item[1]/title)](https://pypi.org/project/jaxparrow/)\n![Tests](https://github.com/meom-group/jaxparrow/actions/workflows/python-package.yml/badge.svg)\n[![Docs](https://github.com/meom-group/jaxparrow/actions/workflows/python-documentation.yml/badge.svg)](https://jaxparrow.readthedocs.io/)\n\n***jaxparrow*** implements a novel approach based on a variational formulation to compute the inversion of the cyclogeostrophic balance.\n\nIt leverages the power of [JAX](https://jax.readthedocs.io/en/latest/), to efficiently solve the inversion as an optimization problem. \nGiven the Sea Surface Height (SSH) field of an ocean system, **jaxparrow** estimates the velocity field that best satisfies the cyclogeostrophic balance.\n\n## Installation\n\nThe package is Pip-installable:\n```shell\npip install jaxparrow\n```\n\n**<ins>However</ins>**, users with access to GPUs or TPUs should first install JAX separately in order to fully benefit from its high-performance computing capacities. \nSee [JAX instructions](https://jax.readthedocs.io/en/latest/installation.html). \\\nBy default, **jaxparrow** will install a CPU-only version of JAX if no other version is already present in the Python environment.\n\n## Usage\n\n### As a package\n\nTwo functions are directly available from `jaxparrow`:\n\n- `geostrophy` computes the geostrophic velocity field (returns two `2darray`) from:\n  - a SSH field (a `2darray`), \n  - the latitude and longitude at the T points (two `2darray`), \n  - an optional mask grid (one `2darray`).\n- `cyclogeostrophy` computes the cyclogeostrophic velocity field (returns two `2darray`) from:\n  - a SSH field (a `2darray`), \n  - the latitude and longitude at the T points (two `2darray`), \n  - an optional mask grid (one `2darray`).\n\n*Because **jaxparrow** uses [C-grids](https://xgcm.readthedocs.io/en/latest/grids.html) the velocity fields are represented on two grids (U and V), and the SSH on one grid (T).*\n\nIn a Python script, assuming that the input grids have already been initialised / imported, it would resort to:\n\n```python\nfrom jaxparrow import cyclogeostrophy, geostrophy\n\nu_geos, v_geos = geostrophy(ssh_t=ssh,\n                            lat_t=lat, lon_t=lon,\n                            mask=mask)\nu_cyclo, v_cyclo = cyclogeostrophy(ssh_t=ssh,\n                                   lat_t=lat, lon_t=lon,\n                                   mask=mask)\n```\n\nTo vectorise the application of the `geostrophy` and `cyclogeostrophy` functions across an added time dimension, one aims to utilize `vmap`.\nHowever, this necessitates avoiding the use of `np.ma.masked_array`. \nHence, our functions accommodate mask `array` as parameter to effectively consider masked regions.\n\nBy default, the `cyclogeostrophy` function relies on our variational method.\nIts `method` argument provides the ability to use an iterative method instead, either the one described by [Penven *et al.*](https://doi.org/10.1016/j.dsr2.2013.10.015), or the one by [Ioannou *et al.*](https://doi.org/10.1029/2019JC015031).\nAdditional arguments also give a finer control over the three approaches hyperparameters. \\\nSee **jaxparrow** [API documentation](https://jaxparrow.readthedocs.io/en/latest/api.html) for more details.\n\n[Notebooks](https://jaxparrow.readthedocs.io/en/latest/examples.html) are available as step-by-step examples.\n\n### As an executable\n\n**jaxparrow** is also available from the command line:\n```shell\njaxparrow --conf_path conf.yml\n```\nThe YAML configuration file `conf.yml` instruct where input netCDF files are locally stored, and how to retrieve variables and coordinates from them.\nIt also provides the path of the output netCDF file. Optionally, it can specify which cyclogeostrophic approach should be applied and its hyperparameters.\n\nAn example configuration file detailing all the required and optional entries can be found [here](https://github.com/meom-group/jaxparrow/blob/main/docs/example-conf.yml).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Computes the inversion of the cyclogeostrophic balance based on a variational formulation approach, using JAX",
    "version": "0.1.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/meom-group/jaxparrow/issues",
        "Homepage": "https://jaxparrow.readthedocs.io/"
    },
    "split_keywords": [
        "cyclogeostrophy",
        " eddy",
        " flow",
        " geostrophy",
        " jax",
        " swirl",
        " velocity"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed7c5662c6a92c8e5629bf74750590b5171b4d2f2ea35b2e8c4edf2bf681ac54",
                "md5": "0ffce49600af46a51d24dbff0362c3e8",
                "sha256": "6b8f460a4518904a1ecbf99ea644b3447636ab58ec1c4cd010c37493d9dc7dfe"
            },
            "downloads": -1,
            "filename": "jaxparrow-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0ffce49600af46a51d24dbff0362c3e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 25581,
            "upload_time": "2024-04-16T07:11:01",
            "upload_time_iso_8601": "2024-04-16T07:11:01.919320Z",
            "url": "https://files.pythonhosted.org/packages/ed/7c/5662c6a92c8e5629bf74750590b5171b4d2f2ea35b2e8c4edf2bf681ac54/jaxparrow-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af429db17f282feb51f86af1e6a3eac86f070d1d4f1807613749d7c8533dfe4b",
                "md5": "58b8154b880bbe4c5d1ba0da39927f25",
                "sha256": "c7efe2bbe3a68e8e445a654af3b7b7b476a834c79ea430c1174654610288832a"
            },
            "downloads": -1,
            "filename": "jaxparrow-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "58b8154b880bbe4c5d1ba0da39927f25",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 23036,
            "upload_time": "2024-04-16T07:11:03",
            "upload_time_iso_8601": "2024-04-16T07:11:03.345050Z",
            "url": "https://files.pythonhosted.org/packages/af/42/9db17f282feb51f86af1e6a3eac86f070d1d4f1807613749d7c8533dfe4b/jaxparrow-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-16 07:11:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "meom-group",
    "github_project": "jaxparrow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jaxparrow"
}
        
Elapsed time: 0.23865s