| 771 | |
| 772 | |
| 773 | class DatasetRolling(Rolling["Dataset"]): |
| 774 | __slots__ = ("rollings",) |
| 775 | |
| 776 | def __init__( |
| 777 | self, |
| 778 | obj: Dataset, |
| 779 | windows: Mapping[Any, int], |
| 780 | min_periods: int | None = None, |
| 781 | center: bool | Mapping[Any, bool] = False, |
| 782 | ) -> None: |
| 783 | """ |
| 784 | Moving window object for Dataset. |
| 785 | You should use Dataset.rolling() method to construct this object |
| 786 | instead of the class constructor. |
| 787 | |
| 788 | Parameters |
| 789 | ---------- |
| 790 | obj : Dataset |
| 791 | Object to window. |
| 792 | windows : mapping of hashable to int |
| 793 | A mapping from the name of the dimension to create the rolling |
| 794 | window along (e.g. `time`) to the size of the moving window. |
| 795 | min_periods : int, default: None |
| 796 | Minimum number of observations in window required to have a value |
| 797 | (otherwise result is NA). The default, None, is equivalent to |
| 798 | setting min_periods equal to the size of the window. |
| 799 | center : bool or mapping of hashable to bool, default: False |
| 800 | Set the labels at the center of the window. The default, False, |
| 801 | sets the labels at the right edge of the window. |
| 802 | |
| 803 | Returns |
| 804 | ------- |
| 805 | rolling : type of input argument |
| 806 | |
| 807 | See Also |
| 808 | -------- |
| 809 | xarray.Dataset.rolling |
| 810 | xarray.DataArray.rolling |
| 811 | xarray.Dataset.groupby |
| 812 | xarray.DataArray.groupby |
| 813 | """ |
| 814 | super().__init__(obj, windows, min_periods, center) |
| 815 | |
| 816 | # Keep each Rolling object as a dictionary |
| 817 | self.rollings = {} |
| 818 | for key, da in self.obj.data_vars.items(): |
| 819 | # keeps rollings only for the dataset depending on self.dim |
| 820 | dims, center = [], {} |
| 821 | for i, d in enumerate(self.dim): |
| 822 | if d in da.dims: |
| 823 | dims.append(d) |
| 824 | center[d] = self.center[i] |
| 825 | |
| 826 | if dims: |
| 827 | w = {d: windows[d] for d in dims} |
| 828 | self.rollings[key] = DataArrayRolling(da, w, min_periods, center) |
| 829 | |
| 830 | def _dataset_implementation(self, func, keep_attrs, **kwargs): |
no outgoing calls
no test coverage detected
searching dependent graphs…