# test of biquad filter import numpy as np from BiquadFilter import BiquadFilter import matplotlib.pyplot as plt omega = 10 q = 2 dt = 0.01 tflow = BiquadFilter(omega, q, dt, "lowpass") tfhigh = BiquadFilter(omega, q, dt, "highpass") tfband = BiquadFilter(omega, q, dt, "bandpass") tfnotch = BiquadFilter(omega, q, dt, "notch") tflow.PrintContinuousTF(); print('') tfhigh.PrintContinuousTF(); print('') tfband.PrintContinuousTF(); print('') tfnotch.PrintContinuousTF(); print('') # simulate filter response tend = 10 Npts = int(np.ceil(tend/dt)) Yl = np.zeros(Npts) Yh = np.zeros(Npts) Yband = np.zeros(Npts) Ynotch = np.zeros(Npts) T = np.zeros(Npts) for i in range(Npts): t = i*dt if t >= 1: x = 1 else: x = 0 T[i] = t Yl[i] = tflow.Filter(x) Yh[i] = tfhigh.Filter(x) Yband[i] = tfband.Filter(x) Ynotch[i] = tfnotch.Filter(x) plt.plot(T, Yl, T, Yh, T, Yband, T, Ynotch) plt.grid(True) plt.show()