https://github.com/wpbonelli/xattree
attrs + xarray data tree = xattree
https://github.com/wpbonelli/xattree
Last synced: 5 months ago
JSON representation
attrs + xarray data tree = xattree
- Host: GitHub
- URL: https://github.com/wpbonelli/xattree
- Owner: wpbonelli
- License: apache-2.0
- Created: 2025-02-16T04:44:50.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-10-23T17:43:32.000Z (8 months ago)
- Last Synced: 2025-10-23T18:34:11.484Z (8 months ago)
- Language: Python
- Homepage: https://xattree.readthedocs.io
- Size: 269 KB
- Stars: 0
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xattree

[](https://github.com/modflowpy/xattree/actions/workflows/ci.yml)
[](https://xattree.readthedocs.io/en/latest/?badge=latest)
[](https://img.shields.io/github/contributors/modflowpy/xattree)
`attrs` + `xarray.DataTree` = `xattree`
"exa-tree", or "cat tree" if you like.
**Warning**: This project is experimental. It is *not* meant for production. Use at your own risk.
```python
import numpy as np
from numpy.typing import NDArray
from xattree import xattree, dim, array, field, ROOT
@xattree
class Grid:
x: int = dim(scope=ROOT, default=3)
y: int = dim(scope=ROOT, default=3)
@xattree
class Arrs:
a: NDArray[np.float64] = array(default=0.0, dims=("x", "y"))
@xattree
class Root:
grid: Grid = field()
arrs: Arrs = field()
grid = Grid()
root = Root(grid=grid)
arrs = Arrs(parent=root)
root.data
Group: /
│ Dimensions: (x: 3, y: 3)
│ Coordinates:
│ * x (x) int64 24B 0 1 2
│ * y (y) int64 24B 0 1 2
├── Group: /grid
│ Attributes:
│ x: 3
│ y: 3
└── Group: /arrs
Dimensions: (x: 3, y: 3)
Data variables:
a (x, y) float64 72B 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
```