datatree.DataTree.clip#

DataTree.clip(min: ScalarOrArray | None = None, max: ScalarOrArray | None = None, *, keep_attrs: bool | None = None) Self[source]#

Return an array whose values are limited to [min, max]. At least one of max or min must be given.

Parameters
  • min (None or Hashable, optional) – Minimum value. If None, no lower clipping is performed.

  • max (None or Hashable, optional) – Maximum value. If None, no upper clipping is performed.

  • keep_attrs (bool or None, optional) – If True, the attributes (attrs) will be copied from the original object to the new one. If False, the new object will be returned without attributes.

Returns

clipped (same type as caller) – This object, but with with values < min are replaced with min, and those > max with max.

See also

numpy.clip

equivalent function