mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-02-07 16:50:54 -07:00
sos_filter: define filtfilt call
To implement host-side analysis of tap data, we need a way to apply the same filtering as on the mcu. As bonus, it cancels the induced signal delay. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
dfe6d3f066
commit
5fb9902dda
1 changed files with 7 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ class DigitalFilter:
|
|||
return
|
||||
try:
|
||||
import scipy.signal as signal
|
||||
import numpy
|
||||
except:
|
||||
raise cfg_error("DigitalFilter require the SciPy module")
|
||||
if highpass:
|
||||
|
|
@ -69,6 +70,12 @@ class DigitalFilter:
|
|||
def get_initial_state(self):
|
||||
return self.initial_state
|
||||
|
||||
def filtfilt(self, data):
|
||||
import scipy.signal as signal
|
||||
import numpy
|
||||
data = numpy.array(data)
|
||||
return signal.sosfiltfilt(self.filter_sections, data)
|
||||
|
||||
# Produce sample to sample difference (derivative) of a DigitalFilter
|
||||
class DerivativeFilter:
|
||||
def __init__(self, main_filter):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue