Metadata-Version: 2.1
Name: xarray-dataclasses
Version: 0.2.0
Summary: xarray extension for dataarray classes
Home-page: https://github.com/astropenguin/xarray-dataclasses/
License: MIT
Author: Akio Taniguchi
Author-email: taniguchi@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: numpy (>=1.19,<2.0)
Requires-Dist: typing-extensions (>=3.7,<4.0)
Requires-Dist: xarray (>=0.15,<0.16)
Project-URL: Documentation, https://astropenguin.github.io/xarray-dataclasses/
Description-Content-Type: text/markdown

# xarray-dataclasses

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

xarray extension for dataarray classes

## TL;DR

xarray-dataclasses is a third-party Python package which helps to create DataArray classes in the same manner as [the Python's native dataclass].
Here is an introduction code of what the package provides:

```python
from xarray_dataclasses import DataArray, dataarrayclass


@dataarrayclass
class Image:
    """DataArray class to represent images."""

    data: DataArray[('x', 'y'), float]
    x: DataArray['x', int] = 0
    y: DataArray['y', int] = 0
```

The key features are:

```python
# create a DataArray instance
image = Image.new([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])

# create a DataArray instance filled with ones
ones = Image.ones((2, 2), x=[0, 1], y=[0, 1])
```

- Custom DataArray instances with fixed dimensions, datatype, and coordinates can easily be created.
- NumPy-like special functions like ``ones()`` are provided as class methods.

## Requirements

- **Python:** 3.7, 3.8, or 3.9 (tested by the author)
- **Dependencies:** See [pyproject.toml](pyproject.toml)

## Installation

```shell
$ pip install xarray-dataclasses
```

<!-- References -->
[the Python's native dataclass]: https://docs.python.org/3/library/dataclasses.html

