A object that implements the moving window pattern. See Also -------- xarray.Dataset.groupby xarray.DataArray.groupby xarray.Dataset.rolling xarray.DataArray.rolling
| 54 | |
| 55 | |
| 56 | class Rolling(Generic[T_Xarray]): |
| 57 | """A object that implements the moving window pattern. |
| 58 | |
| 59 | See Also |
| 60 | -------- |
| 61 | xarray.Dataset.groupby |
| 62 | xarray.DataArray.groupby |
| 63 | xarray.Dataset.rolling |
| 64 | xarray.DataArray.rolling |
| 65 | """ |
| 66 | |
| 67 | __slots__ = ("center", "dim", "min_periods", "obj", "window") |
| 68 | _attributes = ("window", "min_periods", "center", "dim") |
| 69 | dim: list[Hashable] |
| 70 | window: list[int] |
| 71 | center: list[bool] |
| 72 | obj: T_Xarray |
| 73 | min_periods: int |
| 74 | |
| 75 | def __init__( |
| 76 | self, |
| 77 | obj: T_Xarray, |
| 78 | windows: Mapping[Any, int], |
| 79 | min_periods: int | None = None, |
| 80 | center: bool | Mapping[Any, bool] = False, |
| 81 | ) -> None: |
| 82 | """ |
| 83 | Moving window object. |
| 84 | |
| 85 | Parameters |
| 86 | ---------- |
| 87 | obj : Dataset or DataArray |
| 88 | Object to window. |
| 89 | windows : mapping of hashable to int |
| 90 | A mapping from the name of the dimension to create the rolling |
| 91 | window along (e.g. `time`) to the size of the moving window. |
| 92 | min_periods : int or None, default: None |
| 93 | Minimum number of observations in window required to have a value |
| 94 | (otherwise result is NA). The default, None, is equivalent to |
| 95 | setting min_periods equal to the size of the window. |
| 96 | center : bool or dict-like Hashable to bool, default: False |
| 97 | Set the labels at the center of the window. If dict-like, set this |
| 98 | property per rolling dimension. |
| 99 | |
| 100 | Returns |
| 101 | ------- |
| 102 | rolling : type of input argument |
| 103 | """ |
| 104 | self.dim = [] |
| 105 | self.window = [] |
| 106 | for d, w in windows.items(): |
| 107 | self.dim.append(d) |
| 108 | if w <= 0: |
| 109 | raise ValueError("window must be > 0") |
| 110 | self.window.append(w) |
| 111 | |
| 112 | self.center = self._mapping_to_list(center, default=False) |
| 113 | self.obj = obj |
nothing calls this directly
no test coverage detected
searching dependent graphs…