ktk.filters.savgol#
- savgol(ts, /, *, window_length, poly_order, deriv=0)[source]#
Apply a Savitzky-Golay 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.
poly_order (int) – The order of the polynomial used to fit the samples. polyorder must be less than window_length.
deriv (int) – Optional. The order of the derivative to compute. The default is 0, which means to filter the data without differentiating.
- Returns:
A copy of the input TimeSeries, which each data being filtered.
- Return type:
- Raises:
ValueError – If sample rate is not constant, or if there is no data to filter.
See also