ktk.filters.smooth

Contents

ktk.filters.smooth#

smooth(ts, /, window_length)[source]#

Apply a smoothing (moving average) filter on a TimeSeries.

Filtering occurs on the first axis (time). If the TimeSeries contains missing samples, a warning is issued, missing samples are interpolated using a first-order interpolation before filtering, and then replaced by np.nan in the filtered signal.

Parameters:
  • ts (TimeSeries) – Input TimeSeries.

  • window_length (int) – The length of the filter window. window_length must be a positive odd integer less or equal than the length of the TimeSeries.

Returns:

A copy of the input TimeSeries, which each data being filtered.

Return type:

TimeSeries

Raises:

ValueError – If sample rate is not constant, or if there is no data to filter.