问题描述
我正在尝试绘制振动信号的频谱(来自 CWRU 数据集)。信号是用一台以 1790 RPM 运行的机器测量的,这意味着我的频谱应该在 30 Hz 处有一个峰值。然而,numpy.fft 或 scipy.fft 都没有返回一个在这个位置有峰值的光谱。我在 Audacity 中检查了我的信号,Audacity 的频谱确实在 30 Hz 处显示了一个峰值。
因此我想知道这些库我做错了什么? Numpy 和 Scipy 都给了我相同的频谱,但我倾向于认为这不是正确的。最终我对频谱图有同样的问题。
instance = df_all[df_all[target]==2].sample(1) # I take an instance of 12000
# samples (~1 sec) in the database
testSample = instance.iloc[0][features]
plt.plot(testSample)
plt.title('Time domain sample')
plt.show()
n_fft = 2**14
fs = 12000 #Hz (sampling frequency)
x = testSample
x = np.fft.fft(x,n = 2**14)
x = np.abs(x) / len(x)
x = x[range(int(x.shape[0] / 2))]
x = x.reshape(-1,1)
freq = np.linspace(0,fs/2,len(x))
plt.plot(freq,x)
plt.xlabel('Frequency[Hz]')
plt.ylabel('Amplitude')
plt.title('Spectrum')
#plt.xlim(0,50) #no peak at all
plt.show()
Here is the frequency domain plot
我显然做错了什么,但我无法弄清楚是什么,这几天一直困扰着我。有人可以启发我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)