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 st
(
self,
window_dim: Hashable | Mapping[Any, Hashable] | None = None,
*,
stride: int | Mapping[Any, int] = 1,
fill_value: Any = dtypes.NA,
keep_attrs: bool | None = None,
sliding_window_view_kwargs: Mapping[Any, Any] | None = None,
**window_dim_kwargs: Hashable,
)
| 923 | |
| 924 | @_deprecate_positional_args("v2024.11.0") |
| 925 | def construct( |
| 926 | self, |
| 927 | window_dim: Hashable | Mapping[Any, Hashable] | None = None, |
| 928 | *, |
| 929 | stride: int | Mapping[Any, int] = 1, |
| 930 | fill_value: Any = dtypes.NA, |
| 931 | keep_attrs: bool | None = None, |
| 932 | sliding_window_view_kwargs: Mapping[Any, Any] | None = None, |
| 933 | **window_dim_kwargs: Hashable, |
| 934 | ) -> Dataset: |
| 935 | """ |
| 936 | Convert this rolling object to xr.Dataset, |
| 937 | where the window dimension is stacked as a new dimension |
| 938 | |
| 939 | Parameters |
| 940 | ---------- |
| 941 | window_dim : str or mapping, optional |
| 942 | A mapping from dimension name to the new window dimension names. |
| 943 | Just a string can be used for 1d-rolling. |
| 944 | stride : int, optional |
| 945 | size of stride for the rolling window. |
| 946 | fill_value : Any, default: dtypes.NA |
| 947 | Filling value to match the dimension size. |
| 948 | sliding_window_view_kwargs |
| 949 | Keyword arguments that should be passed to the underlying array type's |
| 950 | ``sliding_window_view`` function. |
| 951 | **window_dim_kwargs : {dim: new_name, ...}, optional |
| 952 | The keyword arguments form of ``window_dim``. |
| 953 | |
| 954 | Returns |
| 955 | ------- |
| 956 | Dataset |
| 957 | Dataset with views of the original arrays. By default, the returned arrays are not writeable. |
| 958 | For numpy arrays, one can pass ``writeable=True`` in ``sliding_window_view_kwargs``. |
| 959 | |
| 960 | See Also |
| 961 | -------- |
| 962 | numpy.lib.stride_tricks.sliding_window_view |
| 963 | dask.array.lib.stride_tricks.sliding_window_view |
| 964 | |
| 965 | Notes |
| 966 | ----- |
| 967 | With dask arrays, it's possible to pass the ``automatic_rechunk`` kwarg as |
| 968 | ``sliding_window_view_kwargs={"automatic_rechunk": True}``. This controls |
| 969 | whether dask should automatically rechunk the output to avoid |
| 970 | exploding chunk sizes. Automatically rechunking is the default behaviour. |
| 971 | Importantly, each chunk will be a view of the data so large chunk sizes are |
| 972 | only safe if *no* copies are made later. |
| 973 | """ |
| 974 | |
| 975 | from xarray.core.dataset import Dataset |
| 976 | |
| 977 | keep_attrs = self._get_keep_attrs(keep_attrs) |
| 978 | |
| 979 | if window_dim is None: |
| 980 | if len(window_dim_kwargs) == 0: |
| 981 | raise ValueError( |
| 982 | "Either window_dim or window_dim_kwargs need to be specified." |
nothing calls this directly
no test coverage detected