Metadata-Version: 2.1
Name: xarray-quantity
Version: 0.1.1
Summary: xarray extension which supports astropy quantities.
Home-page: https://github.com/KaoruNishikawa/xarray-quantity
License: MIT
Author: KaoruNishikawa
Author-email: k.nishikawa@a.phys.nagoya-u.ac.jp
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: astropy (>=4.2.1,<5.0.0)
Requires-Dist: xarray (>=0.18.2,<0.19.0)
Project-URL: Repository, https://github.com/KaoruNishikawa/xarray-quantity
Description-Content-Type: text/markdown

# xarray-quantity

[![PyPI](https://img.shields.io/pypi/v/PACKAGENAME.svg?label=PyPI&style=flat-square)](https://pypi.org/pypi/xarray-quantity/)
[![Python](https://img.shields.io/pypi/pyversions/PACKAGENAME.svg?label=Python&color=yellow&style=flat-square)](https://pypi.org/pypi/xarray-quantity/)
[![Test](https://img.shields.io/github/workflow/status/USERNAME/PACKAGENAME/Test?logo=github&label=Test&style=flat-square)](https://github.com/KaoruNishikawa/xarray-quantity/actions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?label=License&style=flat-square)](LICENSE)

xarray extension which supports astropy quantities.

## Features

This library provides:

- xarray DataArray and Dataset with units.

## Installation

```shell
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`.

```python
>>> 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.

```python
>>> 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](https://semver.org).

