def butterLP(self):
#===== parameter =====
coefficients = self.trendLine()
axis = str(self.axis_combobox.currentText())
N=10
time_interval = 0.007
sample_rate = int(1/time_interval)
Nquist_freq = 0.5 * sample_rate
Wn = float(self.filtbutter_lp_slider.value()) / 1430.0
#===== input =====
if axis[0] =='a':
input_signal = self.acc_normalize(self.raw_data[axis])
elif axis[0]=='g':
input_signal = self.gyro_normalize(self.raw_data[axis])
elif axis[0]=='m':
input_signal = self.raw_data[axis]
#===== caculation area =====
b, a = signal.butter(N, Wn, 'low')
#d, c = signal.bessel(N, Wn, 'low')
butter_lp_signal = signal.filtfilt(b, a, input_signal)
#===== output =====
raw_a, raw_v, raw_s = self.another_integral(input_signal)
butter_lp_a, butter_lp_v, butter_lp_s = self.another_integral(butter_lp_signal) #butter_lp_signal
#bessel_lp_a, bessel_lp_v, bessel_lp_s = self.basic_basic_integral(bessel_lp_signal)
print "Max: " + str(max(butter_lp_s)) + "; Min: " + str(min(butter_lp_s))
#===== raw vs filt =====
plt.title(axis)
plt.subplot(311)
plt.grid(True)
plt.plot(raw_a, "blue", label="raw_a")
plt.plot(butter_lp_a, "red", label="butter_lp_a")
plt.legend(loc=2, fontsize = 'medium')
plt.subplot(312)
plt.grid(True)
plt.plot(raw_v, "blue", label="raw_a")
plt.plot(butter_lp_v, "red", label="butter_lp_v")
plt.legend(loc=2, fontsize = 'medium')
plt.subplot(313)
plt.grid(True)
plt.plot(raw_s, "blue", label="raw_a")
plt.plot(butter_lp_s, "red", label="butter_lp_s")
plt.legend(loc=2, fontsize = 'medium')
plt.show()
self.filtbutter_lp_slider.setFocus()
ShowTrace.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录