From 353cac3b569dafc7b80fb41a0bad515f220bfa1b Mon Sep 17 00:00:00 2001 From: shrutik pradip balwan Date: Wed, 7 Oct 2026 23:37:56 +0530 Subject: [PATCH] Fixes #9: Add Butterworth and Chebyshev filter APIs --- filters.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 filters.py diff --git a/filters.py b/filters.py new file mode 100644 index 0000000..0a350bd --- /dev/null +++ b/filters.py @@ -0,0 +1,15 @@ +import scipy.signal as signal + +def design_butterworth(order, cutoff, fs, btype='low'): + """Designs a digital Butterworth filter.""" + nyq = 0.5 * fs + normal_cutoff = cutoff / nyq + b, a = signal.butter(order, normal_cutoff, btype=btype, analog=False) + return b, a + +def design_chebyshev(order, rp, cutoff, fs, btype='low'): + """Designs a digital Chebyshev Type I filter.""" + nyq = 0.5 * fs + normal_cutoff = cutoff / nyq + b, a = signal.cheby1(order, rp, normal_cutoff, btype=btype, analog=False) + return b, a