Physical units interface to xarray using astropy
Project description
astropy-xarray
A convenience wrapper for using astropy with xarray.
Usage
To convert the variables of a Dataset to quantities:
In [1]: import astropy_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> Size: 48B
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) int64 24B 0 1 2
b (y) int64 24B -3 5 1
In [3]: q = ds.astropy.quantify(a="s")
...: q
Out[3]:
<xarray.Dataset> Size: 48B
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 24B [s] 0.0 1.0 2.0
b (y) float64 24B [m] -3.0 5.0 1.0
to convert to different units:
In [4]: c = q.astropy.to({"a": "ms", "b": "km"})
...: c
Out[4]:
<xarray.Dataset> Size: 48B
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 24B [ms] 0.0 1e+03 2e+03
b (y) float64 24B [km] -0.003 0.005 0.001
to convert back to non-quantities:
In [5]: d = c.astropy.dequantify()
...: d
Out[5]:
<xarray.Dataset> Size: 48B
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 24B 0.0 1e+03 2e+03
b (y) float64 24B -0.003 0.005 0.001
For more, see the documentation
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astropy_xarray-0.1.0.tar.gz.
File metadata
- Download URL: astropy_xarray-0.1.0.tar.gz
- Upload date:
- Size: 52.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31dac44b6174a05cd8119df4df65f91bbab74a4e9652dcd238fcbc85188c42d8
|
|
| MD5 |
ce79e88d9412da29ea3820097ad51493
|
|
| BLAKE2b-256 |
582a941f601c10c2c9ff626418b80693c6c485db6080f96f5617b594399ea11a
|
Provenance
The following attestation bundles were made for astropy_xarray-0.1.0.tar.gz:
Publisher:
pypi.yaml on calgray/astropy-xarray
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
astropy_xarray-0.1.0.tar.gz -
Subject digest:
31dac44b6174a05cd8119df4df65f91bbab74a4e9652dcd238fcbc85188c42d8 - Sigstore transparency entry: 281182236
- Sigstore integration time:
-
Permalink:
calgray/astropy-xarray@058d98fb338ab4c4803b794e5d519abf33fb3ca9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/calgray
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@058d98fb338ab4c4803b794e5d519abf33fb3ca9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file astropy_xarray-0.1.0-py3-none-any.whl.
File metadata
- Download URL: astropy_xarray-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cccf94d32aabb3cf39d24b993616b4cf7fd30b909124023bfdcdfa9e5ec611e5
|
|
| MD5 |
8b5231589edc707c5ce09fecec345716
|
|
| BLAKE2b-256 |
f7d2e1e903d79bd14dc92344f80e66cb172ea45c473b2bd0630b5124416aeb63
|
Provenance
The following attestation bundles were made for astropy_xarray-0.1.0-py3-none-any.whl:
Publisher:
pypi.yaml on calgray/astropy-xarray
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
astropy_xarray-0.1.0-py3-none-any.whl -
Subject digest:
cccf94d32aabb3cf39d24b993616b4cf7fd30b909124023bfdcdfa9e5ec611e5 - Sigstore transparency entry: 281182246
- Sigstore integration time:
-
Permalink:
calgray/astropy-xarray@058d98fb338ab4c4803b794e5d519abf33fb3ca9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/calgray
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@058d98fb338ab4c4803b794e5d519abf33fb3ca9 -
Trigger Event:
release
-
Statement type: