xarray.DataTree.filter

xarray.DataTree.filter#

DataTree.filter(filterfunc)[source]#

Filter nodes according to a specified condition.

Returns a new tree containing only the nodes in the original tree for which fitlerfunc(node) is True. Will also contain empty nodes at intermediate positions if required to support leaves.

Parameters:

filterfunc (function) – A function which accepts only one DataTree - the node on which filterfunc will be called.

Returns:

DataTree