【问题标题】:Fourier Transformation with wrong result in amplitude spectrum, why?傅里叶变换导致幅度谱错误,为什么?
【发布时间】:2019-11-23 22:13:01
【问题描述】:

我尝试使用如下所示的信号制作幅度谱:

为什么我在幅度谱中看不到任何火花?或者我的数据有什么问题?或者为什么峰值只在0?

我使用了一个相当长的数据集,但这里是一个信号样本:

s = [45772.47797743, 45792.20303892, 45772.47797743, 46374.99865567, ... 45671.71873548, 45651.16006596, 45630.4722909 ]

还有代码:

from scipy.fftpack import fft, fftfreq, fftshift

s = np.array(id1.u_motion)
Fs= 4

fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(7, 7))

# plot time signal:
axes[0, 0].set_title("Signal")
axes[0, 0].plot(t, s, color='C0')
axes[0, 0].set_xlabel("Time")
axes[0, 0].set_ylabel("Amplitude")

# plot different spectrum types:
axes[1, 0].set_title("Magnitude Spectrum")
axes[1, 0].magnitude_spectrum(s, Fs=Fs, color='C1')

axes[1, 1].set_title("Log. Magnitude Spectrum")
axes[1, 1].magnitude_spectrum(s, Fs=Fs, scale='dB', color='C1')

axes[2, 0].set_title("Phase Spectrum ")
axes[2, 0].phase_spectrum(s, Fs=Fs, color='C2')

axes[2, 1].set_title("Angle Spectrum")
axes[2, 1].angle_spectrum(s, Fs=Fs, color='C2')

axes[0, 1].remove()  # don't display empty ax

fig.tight_layout()
plt.show()

任何人都可以帮助找出为什么我在幅度规格中没有出现任何尖峰的原因吗? 非常感谢!

【问题讨论】:

  • 如果信号中没有比其他所有信号更强的周期性分量,您的频谱中不会出现任何峰值。
  • 但是蓝色图中不是有周期信号吗?
  • 我不知道,可能是随机的。
  • 删除数据的 DC 部分,只需从每个点减去数据向量的平均值。

标签: python time-series signal-processing fft spectrogram


【解决方案1】:

您的信号是非常好的低噪声直流信号。对数图揭示了这一点。

一般来说,在像您这样的情况下,非常高的直流分量会隐藏微弱的高频贡献。我的示例中的等价物是红色的。

可能的解决方案是删除 DC(蓝色曲线)或绘制光谱的对数(底行),就像您已经完成的那样。

import numpy as np
import matplotlib.pyplot as p
%matplotlib inline

T=3 # secs
d=0.04 # secs
n=int(T/d)
print(n)
t=np.arange(0,T,d)  
fr=1 # Hz
y1= np.sin(2*np.pi*fr*t) +100
y2= y1- np.mean(y1)

f1=np.fft.fftshift(np.fft.fft(y1))
f2=np.fft.fftshift(np.fft.fft(y2))
freq=np.fft.fftshift(np.fft.fftfreq(n,d))

p.figure(figsize=(12,10))
p.subplot(231)
p.plot(t,y1,'.-',color='red', lw=0.5, ms=1)  
p.plot(t,y2,'.-',color='blue', lw=0.5,ms=1) 

p.xlabel('time (sec)')
p.ylabel('amplitude (Volt)')
p.subplot(232)
p.plot(freq,np.abs(f1)/n,color='red')
p.title('very high DC dominates other components')
p.xlabel(' freq (Hz)')

p.subplot(233)
p.plot(freq,np.abs(f2)/n)
p.xlabel(' freq (Hz)')

p.subplot(235)
p.plot(freq,np.log(np.abs(f1)/n),color='red')
p.title('very high DC dominates other components')
p.xlabel(' freq (Hz)')

p.subplot(236)
p.plot(freq,np.log(np.abs(f2)/n))
p.xlabel(' freq (Hz)')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多