⚡ Data classes for custom xarray creation
xarray-custom is a third-party Python package which helps to create custom DataArray classes in the same manner as the Python's native dataclass. Here is an introduction code of what the package provides:
fromxarray_customimportcoord, dataarrayclass@dataarrayclassclassImage:
"""DataArray class to represent images."""dims='x', 'y'dtype=floataccessor='img'x: coord('x', int) =0y: coord('y', int) =0defnormalize(self):
returnself/self.max()The key features are:
# create a custom DataArrayimage=Image([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])
# use a custom method via an accessornormalized=image.img.normalize()
# create a custom DataArray filled with onesones=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. - Custom DataArray methods can be available via a custom accessor.
- Python: 3.6, 3.7, or 3.8 (tested by the author)
- Dependencies: See pyproject.toml
$ pip install xarray-customCopyright (c) 2020 Akio Taniguchi
- xarray-custom is distributed under the MIT License
- xarray-custom uses an icon of xarray distributed under the Apache 2.0 license