pint-xarray-0.6.0
توضیحات
Physical units interface to xarray using Pint
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | pint-xarray-0.6.0 |
| نام | pint-xarray |
| نسخه کتابخانه | 0.6.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Tom Nicholas <tomnicholas1@googlemail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/pint-xarray/ |
| مجوز | - |
[](https://github.com/xarray-contrib/pint-xarray/actions/workflows/ci.yml)
[](https://codecov.io/gh/xarray-contrib/pint-xarray)
[](https://pint-xarray.readthedocs.io)
[](https://pypi.org/project/pint-xarray)
[](https://github.com/python/black)
[](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)
نیازمندی
| مقدار | نام |
|---|---|
| - | xarray>=2023.07.0 |
| - | numpy>=1.26 |
| - | pint>=0.24 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.11 | Python |
نحوه نصب
نصب پکیج whl pint-xarray-0.6.0:
pip install pint-xarray-0.6.0.whl
نصب پکیج tar.gz pint-xarray-0.6.0:
pip install pint-xarray-0.6.0.tar.gz