xarray.DataTree.map_over_datasets

xarray.DataTree.map_over_datasets#

DataTree.map_over_datasets(func, *args)[source]#

Apply a function to every dataset in this subtree, returning a new tree which stores the results.

The function will be applied to any dataset stored in this node, as well as any dataset stored in any of the descendant nodes. The returned tree will have the same structure as the original subtree.

func needs to return a Dataset in order to rebuild the subtree.

Parameters
  • func (callable()) – Function to apply to datasets with signature: func(node.dataset, *args, **kwargs) -> Dataset.

    Function will not be applied to any nodes without datasets.

  • *args (tuple, optional) – Positional arguments passed on to func.

Returns

subtrees (DataTree, tuple of DataTrees) – One or more subtrees containing results from applying func to the data at each node.