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 ofwindow_dim
.
- Returns:
Dataset
– Dataset with views of the original arrays. By default, the returned arrays are not writeable. For numpy arrays, one can passwriteable=True
insliding_window_view_kwargs
.
See also
numpy.lib.stride_tricks.sliding_window_view
,dask.array.lib.stride_tricks.sliding_window_view
Notes
With dask arrays, it’s possible to pass the
automatic_rechunk
kwarg assliding_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.