Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs = 1652 Hz
- fc = 208 Hz
- def fir_lowpass(data, fc, fs, nfft):
- # Convert to normalized frequency
- fc_nor = fc / (fs / 2)
- N = nfft
- n = np.arange(N)
- # Compute sinc filter.
- h = np.sinc(2 * fc * (n - (N - 1) / 2))
- # Compute hanning window.
- w = signal.hann(N)
- # Multiply sinc filter with window.
- h = h * w
- # Normalize to get unity gain.
- h = h / np.sum(h)
- # Apply filter to data
- data = np.convolve(data, h, 'same')
- return data
- def IIR_lowpass(data, fc, fs):
- fc_nor = fc / (fs / 2) # Normalize cutoff frequency
- b, a = signal.butter(5, fc_nor, btype='low', analog=False, output='ba')
- filt_data = signal.filtfilt(b, a, data)
- return filt_data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement