Hierarchical tree-like data structures for xarray
Project Links
Meta
Author: Thomas Nicholas
Requires Python: >=3.8
Classifiers
Development Status
- 3 - Alpha
Intended Audience
- Science/Research
Topic
- Scientific/Engineering
License
- OSI Approved :: Apache Software License
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
datatree
WIP implementation of a tree-like hierarchical data structure for xarray.
This aims to create the data structure discussed in xarray issue #4118, and therefore extend xarray's data model to be able to handle arbitrarily nested netCDF4 groups.
The approach used here is based on benbovy's DatasetNode
example - the basic idea is that each tree node wraps a up to a single xarray.Dataset
. The differences are that this effort:
- Uses a node structure inspired by anytree for the tree,
- Implements path-like getting and setting,
- Has functions for mapping user-supplied functions over every node in the tree,
- Automatically dispatches some of
xarray.Dataset
's API over every node in the tree (such as.isel
), - Has a bunch of tests,
- Has a printable representation that currently looks like this:

You can create a DataTree
object in 3 ways:
- Load from a netCDF file (or Zarr store) that has groups via
open_datatree()
. - Using the init method of
DataTree
, which creates an individual node. You can then specify the nodes' relationships to one other, either by setting.parent
and.chlldren
attributes, or through__get/setitem__
access, e.g.dt['path/to/node'] = DataTree()
. - Create a tree from a dictionary of paths to datasets using
DataTree.from_dict()
.
Oct 24, 2024
0.0.15
Feb 07, 2024
0.0.14
Oct 27, 2023
0.0.13
Mar 07, 2023
0.0.12
Jan 09, 2023
0.0.11
Dec 07, 2022
0.0.10
Jul 14, 2022
0.0.9
Jun 03, 2022
0.0.6
May 05, 2022
0.0.5
Mar 31, 2022
0.0.4
Mar 30, 2022
0.0.3
Mar 30, 2022
0.0.2.post1
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
(>=2022.05.0.dev0)
xarray