Nov-08-2022, 12:07 PM
I have data from a IMU Sensor. I have file an Excelfile samplesdata where the data of the IMU Sensor is export. In samplesdata There is a column Euclidian Norm and i want to filter the noisy signal. I research and found the Low pass filter to filter the noisy signal from my data. I write this code in Jupyter Notebook:
https://ibb.co/PCNsrs1
In this Link you can see that it only shows the unfiltered data two times.
Does anyone has a idea what in this code could be wrong?
import numpy as np from scipy.signal import butter, lfilter, freqz import matplotlib.pyplot as plt def butter_lowpass(cutoff, fs, order=5): nyq = fs/2 normal_cutoff = cutoff / nyq b, a = butter(order, normal_cutoff, btype='low', analog=False) return b, a def butter_lowpass_filter(data, cutoff, fs, order=5): b, a = butter_lowpass(cutoff, fs, order=order) y = lfilter(b, a, data) return y data=pd.read_csv('samplesdata.csv',sep=";", decimal=",",encoding='latin-1') sensor_data=data[['Euclidian Norm']] sensor_data=np.array(sensor_data) # Filter requirements. order = 10 fs = 100 # sample rate, Hz cutoff = 30 y = butter_lowpass_filter(sensor_data, cutoff, fs, order) b, a = butter_lowpass(cutoff, fs, order) plt.figure() plt.subplot(211) plt.plot(sensor_data, color='green') plt.grid(color='green', linestyle='--', linewidth=0.5) plt.title('original signal') plt.subplot(212) plt.plot(y, color='red') plt.title('Filtered') plt.grid(color='green', linestyle='--', linewidth=0.5) plt.show(block=True)The problem is that it only plot the unfiltered data twice.
https://ibb.co/PCNsrs1
In this Link you can see that it only shows the unfiltered data two times.
Does anyone has a idea what in this code could be wrong?