Name | pint-xarray JSON |
Version |
0.4
JSON |
| download |
home_page | None |
Summary | Physical units interface to xarray using Pint |
upload_time | 2024-06-23 14:17:53 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | Apache-2 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![CI](https://github.com/xarray-contrib/pint-xarray/workflows/CI/badge.svg?branch=main)](https://github.com/xarray-contrib/pint-xarray/actions?query=branch%3Amain)
[![code coverage](https://codecov.io/gh/xarray-contrib/pint-xarray/branch/main/graph/badge.svg)](https://codecov.io/gh/xarray-contrib/pint-xarray)
[![docs](https://readthedocs.org/projects/pint-xarray/badge/?version=latest)](https://pint-xarray.readthedocs.io)
[![PyPI version](https://img.shields.io/pypi/v/pint-xarray.svg)](https://pypi.org/project/pint-xarray)
[![codestyle](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/pint-xarray)](https://github.com/conda-forge/pint-xarray-feedstock)
# pint-xarray
A convenience wrapper for using [pint](https://pint.readthedocs.io) with
[xarray](https://xarray.pydata.org).
## Usage
To convert the variables of a `Dataset` to quantities:
```python
In [1]: import pint_xarray
...: import xarray as xr
In [2]: ds = xr.Dataset({"a": ("x", [0, 1, 2]), "b": ("y", [-3, 5, 1], {"units": "m"})})
...: ds
Out[2]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) int64 0 1 2
b (y) int64 -3 5 1
In [3]: q = ds.pint.quantify(a="s")
...: q
Out[3]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) int64 [s] 0 1 2
b (y) int64 [m] -3 5 1
```
to convert to different units:
```python
In [4]: c = q.pint.to({"a": "ms", "b": "km"})
...: c
Out[4]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 [ms] 0.0 1e+03 2e+03
b (y) float64 [km] -0.003 0.005 0.001
```
to convert back to non-quantities:
```python
In [5]: d = c.pint.dequantify()
...: d
Out[5]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 0.0 1e+03 2e+03
b (y) float64 -0.003 0.005 0.001
```
For more, see the [documentation](https://pint-xarray.readthedocs.io)
Raw data
{
"_id": null,
"home_page": null,
"name": "pint-xarray",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Tom Nicholas <tomnicholas1@googlemail.com>",
"download_url": "https://files.pythonhosted.org/packages/31/97/f2ee67b46ac14073b58e5245946f615cbd2875ea7713405ba960471edef3/pint_xarray-0.4.tar.gz",
"platform": null,
"description": "[![CI](https://github.com/xarray-contrib/pint-xarray/workflows/CI/badge.svg?branch=main)](https://github.com/xarray-contrib/pint-xarray/actions?query=branch%3Amain)\n[![code coverage](https://codecov.io/gh/xarray-contrib/pint-xarray/branch/main/graph/badge.svg)](https://codecov.io/gh/xarray-contrib/pint-xarray)\n[![docs](https://readthedocs.org/projects/pint-xarray/badge/?version=latest)](https://pint-xarray.readthedocs.io)\n[![PyPI version](https://img.shields.io/pypi/v/pint-xarray.svg)](https://pypi.org/project/pint-xarray)\n[![codestyle](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)\n[![conda-forge](https://img.shields.io/conda/vn/conda-forge/pint-xarray)](https://github.com/conda-forge/pint-xarray-feedstock)\n\n# pint-xarray\n\nA convenience wrapper for using [pint](https://pint.readthedocs.io) with\n[xarray](https://xarray.pydata.org).\n\n## Usage\n\nTo convert the variables of a `Dataset` to quantities:\n```python\nIn [1]: import pint_xarray\n ...: import xarray as xr\n\nIn [2]: ds = xr.Dataset({\"a\": (\"x\", [0, 1, 2]), \"b\": (\"y\", [-3, 5, 1], {\"units\": \"m\"})})\n ...: ds\nOut[2]:\n<xarray.Dataset>\nDimensions: (x: 3, y: 3)\nDimensions without coordinates: x, y\nData variables:\n a (x) int64 0 1 2\n b (y) int64 -3 5 1\n\nIn [3]: q = ds.pint.quantify(a=\"s\")\n ...: q\nOut[3]:\n<xarray.Dataset>\nDimensions: (x: 3, y: 3)\nDimensions without coordinates: x, y\nData variables:\n a (x) int64 [s] 0 1 2\n b (y) int64 [m] -3 5 1\n```\nto convert to different units:\n```python\nIn [4]: c = q.pint.to({\"a\": \"ms\", \"b\": \"km\"})\n ...: c\nOut[4]:\n<xarray.Dataset>\nDimensions: (x: 3, y: 3)\nDimensions without coordinates: x, y\nData variables:\n a (x) float64 [ms] 0.0 1e+03 2e+03\n b (y) float64 [km] -0.003 0.005 0.001\n```\nto convert back to non-quantities:\n```python\nIn [5]: d = c.pint.dequantify()\n ...: d\nOut[5]:\n<xarray.Dataset>\nDimensions: (x: 3, y: 3)\nDimensions without coordinates: x, y\nData variables:\n a (x) float64 0.0 1e+03 2e+03\n b (y) float64 -0.003 0.005 0.001\n```\n\nFor more, see the [documentation](https://pint-xarray.readthedocs.io)\n",
"bugtrack_url": null,
"license": "Apache-2",
"summary": "Physical units interface to xarray using Pint",
"version": "0.4",
"project_urls": {
"Documentation": "https://pint-xarray.readthedocs.io/en/stable",
"Home": "https://github.com/xarray-contrib/pint-xarray"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b05c9b205b9acd844c758cb013f22fa9576a043ec9d1819c237030dc29ef3744",
"md5": "5d0ebace1d46bc598bf5a4de12768ee3",
"sha256": "dcbbd6e6257817828b5cf7915254a8031d7a1e94df110218d280f3a1b956d4f5"
},
"downloads": -1,
"filename": "pint_xarray-0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5d0ebace1d46bc598bf5a4de12768ee3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 32677,
"upload_time": "2024-06-23T14:17:52",
"upload_time_iso_8601": "2024-06-23T14:17:52.261688Z",
"url": "https://files.pythonhosted.org/packages/b0/5c/9b205b9acd844c758cb013f22fa9576a043ec9d1819c237030dc29ef3744/pint_xarray-0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3197f2ee67b46ac14073b58e5245946f615cbd2875ea7713405ba960471edef3",
"md5": "17db064454cfc667ffa209c669e70e1c",
"sha256": "b6b737a9c46dfb14a8598c27a71100496994c9d79dab61fd77f0d2685ae7065e"
},
"downloads": -1,
"filename": "pint_xarray-0.4.tar.gz",
"has_sig": false,
"md5_digest": "17db064454cfc667ffa209c669e70e1c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 47835,
"upload_time": "2024-06-23T14:17:53",
"upload_time_iso_8601": "2024-06-23T14:17:53.866768Z",
"url": "https://files.pythonhosted.org/packages/31/97/f2ee67b46ac14073b58e5245946f615cbd2875ea7713405ba960471edef3/pint_xarray-0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-23 14:17:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xarray-contrib",
"github_project": "pint-xarray",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pint-xarray"
}