Skip to main content

xarray extension which supports astropy quantities.

Project description

xarray-quantity

PyPI Python Test License

xarray extension which supports astropy quantities.

Features

This library provides:

  • xarray DataArray and Dataset with units.

Installation

pip install xarray-quantity

Usage

QuantityArray

To create a DataArray with units, use QuantityArray class. The arguments are compatible with DataArray, except the keyword argument unit.

>>> qa = QuantityArray([1, 2, 3, 4, 5], unit="km")
>>> qa.data
[1, 2, 3, 4, 5] km
>>> qa.unit
km

QuantitySet

To create a Dataset with units, use QuantitySet class. This class also has compatibility with xarray's Dataset.

>>> arrays = {
...     "qa1": QuantityArray([1, 2, 3, 4, 5], unit="km/s"),
...     "qa2": QuantityArray([11, 12, 13, 14, 15]),
...     "da3": xr.DataArray([111, 112, 113, 114, 115])
... }
>>> qs = QuantitySet(arrays)
>>> qs.qa1.data
[1, 2, 3, 4, 5] km / s
>>> qs.qa2
xarray.QuantityArray 'qa2' (dim_0: 5)
<Quantity [11., 12., 13., 14., 15.] km / s>
Coordinates: (0)
Attributes: (0)

This library is using Semantic Versioning.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xarray-quantity-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xarray_quantity-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file xarray-quantity-0.1.1.tar.gz.

File metadata

  • Download URL: xarray-quantity-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/5.8.0-1036-azure

File hashes

Hashes for xarray-quantity-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c462382baff1f35eb48ebf22bd9e42cf3f1b783ab52031c4c6c08a55104e5162
MD5 648c36be32371863bf8aecf0c914a98d
BLAKE2b-256 1fe701a2e2abb531fd36cd9b96d3ecfc3678872b0e3cef7c1d80af196b007c26

See more details on using hashes here.

File details

Details for the file xarray_quantity-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xarray_quantity-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/5.8.0-1036-azure

File hashes

Hashes for xarray_quantity-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f69a79df8c300abaea27395a4a77d1885d0f94b9c75d605a4ef8aadc5a777147
MD5 a48d53ce2f94313946f64f0abcdd1d2d
BLAKE2b-256 220da1ff50088e8cd3b0b7afb8ba6783626efbece7614d38e51df8cb2e117446

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page