Skip to main content

xarray extension for dataarray classes

Project description

xarray-dataclasses

PyPI Python Test 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:

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:

# 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

Installation

$ pip install xarray-dataclasses

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-dataclasses-0.2.0.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

xarray_dataclasses-0.2.0-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

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