xarray.core.rolling.DatasetRolling.construct

xarray.core.rolling.DatasetRolling.construct#

DatasetRolling.construct(window_dim=None, *, stride=1, fill_value=<NA>, keep_attrs=None, sliding_window_view_kwargs=None, **window_dim_kwargs)[source]#

Convert this rolling object to xr.Dataset, where the window dimension is stacked as a new dimension

Parameters:
  • window_dim (str or mapping, optional) – A mapping from dimension name to the new window dimension names. Just a string can be used for 1d-rolling.

  • stride (int, optional) – size of stride for the rolling window.

  • fill_value (Any, default: dtypes.NA) – Filling value to match the dimension size.

  • sliding_window_view_kwargs – Keyword arguments that should be passed to the underlying array type’s sliding_window_view function.

  • **window_dim_kwargs ({dim: new_name, ...}, optional) – The keyword arguments form of window_dim.

Returns:

Dataset – Dataset with views of the original arrays. By default, the returned arrays are not writeable. For numpy arrays, one can pass writeable=True in sliding_window_view_kwargs.

Notes

With dask arrays, it’s possible to pass the automatic_rechunk kwarg as sliding_window_view_kwargs={"automatic_rechunk": True}. This controls whether dask should automatically rechunk the output to avoid exploding chunk sizes. Automatically rechunking is the default behaviour. Importantly, each chunk will be a view of the data so large chunk sizes are only safe if no copies are made later.