I'm a beginner in signal processing and have a hard time to filter out environmental noise from the floor vibration data collected using accelerometers.
I have tried using butterworth filter (IIR) and sinc function (FIR) along with some window functions. Yet, I do not see obvious change in the time domain plot nor in the frequency domain plot by just using above-mentioned low pass filter.
The frequency domain plot does show some changes when I use the filter along with the window function. But, when I use inverse fft of the filtered data, the magnitude of the original data is reduced. I am not sure if the filter/ window function is applied correctly.
fs = 1652 Hz fc = 208 Hz
I'm not sure the right way to determine the cutoff frequency since I am not sure what is acceptable range for passband/stopband ripples.
Here is my sinc filter:
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
Here is my butterworth filter:
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