xarray.DataArray.clip#
- DataArray.clip(min=None, max=None, *, keep_attrs=None)[source]#
Return an array whose values are limited to
[min, max]
. At least one of max or min must be given.- Parameters:
min (
None
orHashable
, optional) – Minimum value. If None, no lower clipping is performed.max (
None
orHashable
, optional) – Maximum value. If None, no upper clipping is performed.keep_attrs (
bool
orNone
, 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