Skip to content

kaymal/auto-smooth

Repository files navigation

Auto Smooth

License Code style: black

Apply data smoothing/filtering to a time series by automatically selecting parameters.

Currently available smoothing/filtering techniques in the package:

  • Savitzky–Golay filter

Quickstart

from auto_smooth import auto_savgol

# apply savgol filter
data_filtered = auto_savgol(data)

>>> wl_best=7, po_best=2

original_vs_smooth

Savitzky-Golay Filtering

Savitzky–Golay (Abraham Savitzky and Marcel J. E. Golay) filter is a type of low-pass filter used for smoothing noisy data.1 It is based on local least-squares fitting.2

auto_savgol method applies a Savitzky–Golay filter using the scipy savgol_filter() method.

from auto_smooth import auto_savgol

# apply savgol filter
data_filtered = auto_savgol(data)

# pass window-length and polynomial-order arguments
data_filtered = auto_savgol(data, wl_min=10, wl_max=30, po_min=2, po_max=10)

References

Footnotes

  1. https://scipy-cookbook.readthedocs.io/items/SavitzkyGolay.html

  2. https://pubs.acs.org/doi/10.1021/acsmeasuresciau.1c00054