xarray.DataTree#
- class xarray.DataTree(dataset=None, children=None, name=None)[source]#
A tree-like hierarchical collection of xarray objects.
Attempts to present an API like that of xarray.Dataset, but methods are wrapped to also update all the tree’s child nodes.
- __init__(dataset=None, children=None, name=None)[source]#
Create a single node of a DataTree.
The node may optionally contain data in the form of data and coordinate variables, stored in the same way as data is stored in an xarray.Dataset.
- Parameters
- Returns
See also
Methods
__init__
([dataset, children, name])Create a single node of a DataTree.
all
([dim, keep_attrs])Reduce this DataTree's data by applying
all
along some dimension(s).any
([dim, keep_attrs])Reduce this DataTree's data by applying
any
along some dimension(s).argsort
([axis, kind, order])Returns the indices that would sort this array.
assign
([items])Assign new data variables or child nodes to a DataTree, returning a new object with all the original items in addition to the new ones.
chunk
([chunks, name_prefix, token, lock, ...])Coerce all arrays in all groups in this tree into dask arrays with the given chunks.
close
()Close any files associated with this tree.
compute
(**kwargs)Manually trigger loading and/or computation of this datatree's data from disk or a remote source into memory and return a new datatree.
conj
()Complex-conjugate all elements.
Return the complex conjugate, element-wise.
copy
(*[, inherit, deep])Returns a copy of this subtree.
count
([dim, keep_attrs])Reduce this DataTree's data by applying
count
along some dimension(s).cumprod
([dim, skipna, keep_attrs])Reduce this DataTree's data by applying
cumprod
along some dimension(s).cumsum
([dim, skipna, keep_attrs])Reduce this DataTree's data by applying
cumsum
along some dimension(s).drop_nodes
(names, *[, errors])Drop child nodes from this node.
equals
(other)Two DataTrees are equal if they have isomorphic node structures, with matching node names, and if they have matching variables and coordinates, all of which are equal.
filter
(filterfunc)Filter nodes according to a specified condition.
find_common_ancestor
(other)Find the first common ancestor of two nodes in the same tree.
from_dict
(d, /[, name])Create a datatree from a dictionary of data objects, organised by paths into the tree.
get
(key[, default])Access child nodes, variables, or coordinates stored in this node.
identical
(other)Like equals, but also checks attributes on all datasets, variables and coordinates, and requires that any inherited coordinates at the tree root are also inherited on the other tree.
isel
([indexers, drop, missing_dims])Returns a new data tree with each array indexed along the specified dimension(s).
isomorphic
(other)Two DataTrees are considered isomorphic if the set of paths to their descendent nodes are the same.
items
()Iterate up the tree, starting from the current node.
keys
()load
(**kwargs)Manually trigger loading and/or computation of this datatree's data from disk or a remote source into memory and return this datatree.
map_over_datasets
(func, *args)Apply a function to every dataset in this subtree, returning a new tree which stores the results.
match
(pattern)Return nodes with paths matching pattern.
max
([dim, skipna, keep_attrs])Reduce this DataTree's data by applying
max
along some dimension(s).mean
([dim, skipna, keep_attrs])Reduce this DataTree's data by applying
mean
along some dimension(s).median
([dim, skipna, keep_attrs])Reduce this DataTree's data by applying
median
along some dimension(s).min
([dim, skipna, keep_attrs])Reduce this DataTree's data by applying
min
along some dimension(s).orphan
()Detach this node from its parent.
persist
(**kwargs)Trigger computation, keeping data as chunked arrays.
pipe
(func, *args, **kwargs)Apply
func(self, *args, **kwargs)
prod
([dim, skipna, min_count, keep_attrs])Reduce this DataTree's data by applying
prod
along some dimension(s).reduce
(func[, dim, keep_attrs, keepdims, ...])Reduce this tree by applying func along some dimension(s).
relative_to
(other)Compute the relative path from this node to node other.
round
(*args, **kwargs)same_tree
(other)True if other node is in the same tree as this node.
sel
([indexers, method, tolerance, drop])Returns a new data tree with each array indexed by tick labels along the specified dimension(s).
set_close
(close)Set the closer for this node.
std
([dim, skipna, ddof, keep_attrs])Reduce this DataTree's data by applying
std
along some dimension(s).sum
([dim, skipna, min_count, keep_attrs])Reduce this DataTree's data by applying
sum
along some dimension(s).to_dataset
([inherit])Return the data in this node as a new xarray.Dataset object.
to_dict
([relative])Create a dictionary mapping of paths to the data contained in those nodes.
to_netcdf
(filepath[, mode, encoding, ...])Write datatree contents to a netCDF file.
to_zarr
(store[, mode, encoding, ...])Write datatree contents to a Zarr store.
update
(other)Update this node's children and / or variables.
values
()var
([dim, skipna, ddof, keep_attrs])Reduce this DataTree's data by applying
var
along some dimension(s).Attributes
All parent nodes and their parent nodes, starting with the most distant.
Dictionary of global attributes on this node object.
Child nodes of this node, stored under a mapping via their names.
Mapping from group paths to a mapping of chunksizes.
Dictionary of xarray.DataArray objects corresponding to coordinate variables
Dictionary of DataArray objects corresponding to data variables
An immutable Dataset-like view onto the data in this node.
Maximum level of this tree.
Child nodes and all their child nodes.
Mapping from dimension names to lengths.
ds
An immutable Dataset-like view onto the data in this node.
Dictionary of global encoding attributes on this node object.
Return all groups in the tree, given as a tuple of path-like strings.
Whether or not there are any metadata attributes in this node.
Whether or not there are any variables in this node.
Mapping of pandas.Index objects used for label based indexing.
False if node contains any data or attrs.
True if only leaf nodes contain data.
Whether this node is a leaf node.
Whether this node is the tree root.
All leaf nodes.
Level of this node.
All parent nodes and their parent nodes, starting with the closest.
The name of this node.
Parent of this node.
All parent nodes and their parent nodes, starting with the closest.
Return the file-like path from the root to this node.
Root node of the tree
Nodes with the same parent as this node.
Mapping from dimension names to lengths.
Iterate over all nodes in this tree, including both self and all descendants.
subtree_with_keys
Iterate over relative paths and node pairs for all nodes in this tree.
Low level interface to node contents as dict of Variable objects.
Number of nodes at this level in the tree.
xindexes
Mapping of xarray Index objects used for label based indexing.