xarray.group_subtrees#
- xarray.group_subtrees(*trees)[source]#
Iterate over subtrees grouped by relative paths in breadth-first order.
group_subtrees allows for applying operations over all nodes of a collection of DataTree objects with nodes matched by their relative paths.
Example usage:
outputs = {} for path, (node_a, node_b) in group_subtrees(tree_a, tree_b): outputs[path] = f(node_a, node_b) tree_out = DataTree.from_dict(outputs)
- Parameters
*trees (
Tree
) – Trees to iterate over.- Yields
A tuple
ofthe relative path
andcorresponding nodes for each subtree in the
inputs.
- Raises
TreeIsomorphismError – If trees are not isomorphic, i.e., they have different structures.
See also
DataTree.subtree
,DataTree.subtree_with_keys