Skip to main content

a minimal and light-weight equivalent of xarray.DataArray

Project description

pyxarr

image image image image

This is a package which provides a minimal and light-weight class to work with multi-dimensional labeled arrays.

Description

The software of pyxarr is written from scratch. I have tried to mimic the classes DataArray, Dataset and Coords from xarray. My main goal is to keep the code light and fast.

Installation

Pyxarr is available as pyxarr on PyPI. To install it use pip:

$ pip install pyxarr

The module pyxarr requires Python3.10+ and Python modules: h5py, numpy.

Usage

Working with a pyxarr DataArray:

import numpy as np
from pyxarr import DataArray

xds = DataArray()
bool(xds) # will return False, thus if xda: ... will work
len(xds)  # will return 0

rng = np.random.default_rng()
xda = DataArray(
   rng.random((120, 11, 17)),
   dims=("time", "y", "x"),
   coords=(
      np.arange("2025-02-24T14:32:00", "2025-02-24T15:32:00", 30, dtype="datetime64[s]"),
      list(range(11)),
      np.arange(17),
   ),
   attrs={
      "long_name": "noisy signal",
      "units": "1",
   },
)
bool(xds)  # returns True
len(xds)   # returns 120
xda.shape  # returns (120, 11, 17)
xda.size   # returns 22440
"x" in xda.coords  # returns True
xda[4, :, :]  # slicing works
xda.coords += ("orbit", list(range(500, 620))  # will add an auxiliary coordinate
xda.swap_dims("orbit", "time")  # will make the auxiliary coordinate the dimension coordinate and visa versa
xda.mean("time")  # will return a new DataArray averaged over the time axis
xda + xda2  # will return a new DataArray with the sum of the data of both arrays, other supported operator are sub, div and mul.

Authors and acknowledgment

The code is developed by R.M. van Hees (SRON)

License

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

pyxarr-0.2.0.tar.gz (200.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyxarr-0.2.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file pyxarr-0.2.0.tar.gz.

File metadata

  • Download URL: pyxarr-0.2.0.tar.gz
  • Upload date:
  • Size: 200.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxarr-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aaecbdf435bc710dd4a4fb3a47d06b5992b57e2e5b3efd5d142fcc3efd1a8e8d
MD5 fc43a0f67770a7b5365491150aaad576
BLAKE2b-256 039d7dbf054d2514a68120abbb735cc14f61410ec9e064cca4fb52e9a9d2c679

See more details on using hashes here.

File details

Details for the file pyxarr-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyxarr-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxarr-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13ae3d624fde61f98e2304c18d2314231daa648c2d893ffd5b36efdfd638a9c2
MD5 ffa75428367bc5ac4c6134fb43d24b3b
BLAKE2b-256 bf627dc7ba533930df99b711d96fda5bab13a432e44ed1c76dcd26de726b6ba0

See more details on using hashes here.

Supported by

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