wxee.time_series.TimeSeries.rolling_time

TimeSeries.rolling_time(window: int, unit: str, align: str = 'left', min_observations: int = 1, reducer: Any | None = None, keep_bandnames: bool = True) TimeSeries[source]

Apply a rolling reducer over the time dimension. Rolling windows are calculated around each image, so if images are irregularly spaced in time, the windows will be as well. As long as the minimum observations are met in each window, the output time series will contain the same number of images as the input, with each image reduced over its surrounding window.

Parameters:
  • window (int) – The number of time units to include in each rolling period.

  • unit (str) – The time frequency of the window. One of “hour”, “day”, “week”, “month”, “year”.

  • align (str, default "left") – The start location of the rolling window, relative to the primary image time. One of “left”, “center”, “right”. For example, a 3-day left-aligned window will include all images up to (but not including) 3 days prior to the primary image. Date ranges are exclusive in the alignment direction and inclusive in the opposite direction, so each primary image will be included in its own window.

  • min_observations (int, default 1) – The minimum number of images to include in the rolling window (counting the primary image). If the minimum observations are not met, the primary image will be dropped. For example, a monthly time series reduced with a 10 day window and min_observations==3 would be empty because none of the windows would include enough observations.

  • reducer (Optional[ee.Reducer]) – The reducer to apply to each rolling window. If none is given, ee.Reducer.mean will be used.

  • keep_bandnames (bool, default True) – If true, the band names of the input images will be kept in the reduced images. If false, the name of the reducer will be appended to the band names, e.g. SR_B4 will become SR_B4_mean.

Returns:

The time series with the rolling reducer applied to each image.

Return type:

wxee.time_series.TimeSeries

Example

>>> ts = wxee.TimeSeries("MODIS/006/MOD13A2)
>>> ts_smooth = ts.rolling_time(90, "day", "center", reducer=ee.Reducer.median())