rolling_reduce

earthkit.transforms.temporal.rolling_reduce(dataarray: Dataset | DataArray, window_length: int | None = None, time_dim: str | None = None, **kwargs)[source]

Return reduced data using a moving window over the time dimension.

Parameters:
  • dataarray (xarray.DataArray or xarray.Dataset) – Data over which the moving window is applied according to the reduction method.

  • window_length – Length of window for the rolling groups along the time dimension. see documentation for xarray.dataarray.rolling.

  • time_dim (str) – Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to “time”.

  • min_periods (integer) – The minimum number of observations in the window required to have a value (otherwise result is NaN). Default is to set min_periods equal to the size of the window. see documentation for xarray.dataarray.rolling

  • center (bool) – Set the labels at the centre of the window, see documentation for xarray.dataarray.rolling.

  • how_reduce (str,) – Function to be applied for reduction. Default is ‘mean’.

  • how_dropna (str) – Determine if dimension is removed from the output when we have at least one NaN or all NaN. how_dropna can be ‘None’, ‘any’ or ‘all’. Default is ‘any’.

  • windows (dict[str, int]) – Any other windows to apply to other dimensions in the dataset/dataarray

  • **kwargs – Any kwargs that are compatible with the select how_reduce method.

Returns:

A dataarray reduced values with a rolling window applied along the time dimension.

Return type:

xarray.DataArray | xarray.Dataset