decode.utils module#

mad(da: DataArray, dim: str | Collection[Hashable] | ellipsis | None = None, skipna: bool | None = None, keep_attrs: bool | None = None, **kwargs: Any) DataArray[source]#

Calculate the median absolute deviation (MAD) of a DataArray.

Parameters:
  • da (DataArray) – Input DataArray.

  • dim (str | Collection[Hashable] | ellipsis | None) – Name of dimension(s) along which the MAD is calculated.

  • skipna (bool | None) – Same-name option to be passed to DataArray.median.

  • keep_attrs (bool | None) – Same-name option to be passed to DataArray.median.

  • kwargs (Any) – Same-name option(s) to be passed to DataArray.median.

Returns:

The MAD of the input DataArray.

Return type:

DataArray

phaseof(da: DataArray, /, *, keep_attrs: bool = False, keep_coords: bool = False) DataArray[source]#

Assign a phase to each value in a 1D DataArray.

The function assigns a unique phase (int64) to consecutive identical values in the DataArray. The phase increases sequentially whenever the value in the DataArray changes.

Parameters:
  • da (DataArray) – Input 1D DataArray.

  • keep_attrs (bool) – Whether to keep attributes of the input.

  • keep_coords (bool) – Whether to keep coordinates of the input.

Returns:

1D int64 DataArray of phases.

Return type:

DataArray