python - 使用 Python 的 FFT - 意想不到的低频

标签 python matplotlib scipy fft

我仍在尝试对此 data 进行频率分析在 Python 中使用 FFT。 采样率为每分钟 1 个数据点。

我的代码是:

from scipy.fftpack import fft
df3 = pd.read_csv('Pressure - Dates by Minute.csv', sep=",", skiprows=0)
df3['Pressure FFT'] = df3['ATMOSPHERIC PRESSURE (hPa) mean'] - df3['ATMOSPHERIC PRESSURE (hPa) mean'].mean()
Pressure = df3['Pressure FFT']
Fs = 1/60
Ts = 1.0/Fs
n = len(Pressure)
k = np.arange(n)
T = n/Fs
t = np.arange(0,1,1/n) # time vector
frq = k/T # two sides frequency range
frq = frq[range(int(n/2))] # one side frequency range

Y = np.fft.fft(Pressure)/n # fft computing and normalization
Y = Y[range(int(n/2))]

fig, ax = plt.subplots(2, 1)
ax[0].plot(t,Pressure)
ax[0].set_xlabel('Time')
ax[0].set_ylabel('Amplitude')
ax[1].plot(frq,abs(Y),'r') # plotting the spectrum
ax[1].set_xlabel('Freq (Hz)')
ax[1].set_ylabel('|Y(freq)|')

但结果给出:

enter image description here

所以我的问题是:

1) 为什么根本没有频率?数据明显是周期性的。

2) 为什么频谱这么低? (0 - 0.009)

3) 也许我应该尝试不同的过滤技术?

有什么见解吗?

谢谢!!!

最佳答案

1) Why there are no frequencies at all ? The data is clearly periodic.

嗯,有频率内容,只是因为它的结构不完全可见。尝试更改绘制频谱的线,从 ax[1].plot(frq,abs(Y),'r')ax[1].semilogy(frq,abs (Y),'r')

这将导致:

semilog Spectrum

我们现在应用了一个简单的转换来提升低值并限制高值。有关详细信息,请参阅 this link .当然,删除 DC(就像您在代码的第 3 行所做的那样)也有帮助。

这看起来仍然有点模糊,但如果我们放大到频谱的较低部分,我们会看到:

semilog Transform

它显示大约 2.3e-05 Hz 处的尖峰,对应于大约 12 小时。

2) Why the frequency spectrum is so low ? (0 - 0.009)

因为您每 60 秒采样一次,所以您的采样频率(大约)为 0.016 Hz。您的频谱包含 DC (0Hz) 和 0.0083Hz 之间的所有频率。更多信息,请参阅this link

3) Maybe I should try different filtering technique?

如果您无法解决谐波问题,您可以尝试加窗,但看起来这里不需要加窗。

希望这对您有所帮助。

关于python - 使用 Python 的 FFT - 意想不到的低频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37225249/

相关文章:

python - matplotlib pdf savefig 提前退出

scipy 缺少 libifport.so.5

python - 使用 scipy.optimize 最小化多元可微函数

python - ttest_1samp 给出的 P_value 错误

python - 在 Python 中将单词/数字与符号分开

python - 特征匹配的图像相似性度量?

pandas - 如何修复属性错误: 'Series' object has no attribute 'find' ?

python - use_for_related_fields 如何在 Django 中工作?

python - 如何应用内核峰值为 1 的 3D 高斯滤波器?

python - 如何从 n x n 矩阵生成等高线图?