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.5.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: xarray-quantity-0.1.5.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-1014-azure

File hashes

Hashes for xarray-quantity-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2bcba2b20b8a284fb7fa8bb13e3383d9d76bd889c2aa9d91854da340ad9253af
MD5 8de0284392beeb101bf5fe9598f49107
BLAKE2b-256 1fcbe641afb705cd2ff18c6ccb6a6ebdb6033b2f857cb8c6d7a1110426c74c42

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xarray_quantity-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-1014-azure

File hashes

Hashes for xarray_quantity-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bb527a10c0135eb7599d9085fe335fdb954f5dfae48d3a569de85ccd68dc3def
MD5 9872e302bc4dfdce67d549a4ae942604
BLAKE2b-256 101b3ee842ed1593b2a5a5621a9b0395d54fb49842d179a7be0c89585ad0c930

See more details on using hashes here.

Supported by

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