简体   繁体   English

如何平滑时间序列的频谱?

[英]How to smooth frequency spectrum of time series?

I tried to reproduce Watson's spectrum plot from these set of slides (PDF p. 30, p.29 of the slides), that came from this data of housing building permits .我试图从这些来自房屋建筑许可证数据的幻灯片(PDF 第 30 页,幻灯片的第 29 页)中重现 Watson 的光谱 plot。

Watson achieves a very smooth spectrum curve in which it is very easy to tell the peak frequencies. Watson 实现了非常平滑的频谱曲线,其中很容易分辨出峰值频率。 When I tried to run a FFT on the data, I get a really noisy spectrum curve and I wonder if there is an intermediate step that I am missing.当我尝试对数据运行 FFT 时,我得到了一个非常嘈杂的频谱曲线,我想知道是否缺少我缺少的中间步骤。

I ran the fourier analysis on python, using scipy package fftpack as follows:我使用 scipy package fftpack 对 python 进行了傅立叶分析,如下所示:

from scipy import fftpack

fs = 1 / 12 # monthly
N = data.shape[0]
spectrum = fftpack.fft(data.PERMITNSA.values)
freqs = fftpack.fftfreq(len(spectrum)) #* fs

plt.plot(freqs[:N//2], 20 * np.log10(np.abs(spectrum[:N//2])))

Could anyone help me with the missing link?有人可以帮我解决缺少的链接吗?

The original data is:原始数据为:

原始数据

Below is the Watson's spectrum curve, the one I tried to reproduce:下面是 Watson 的光谱曲线,我试图重现的曲线:

目标谱

And these are my results:这些是我的结果:

我的结果

The posted curve doesn't look realistic.张贴的曲线看起来不真实。 But there are many methods to get a smooth result with a similar amount of "curviness", using various kinds of resampling and/or plot interpolation.但是有许多方法可以使用各种重采样和/或 plot 插值来获得具有相似“曲线”量的平滑结果。

One method I like is to chop the data into segments (windows, possibly overlapped) roughly 4X longer than the maximum number of "bumps" you want to see, maybe a bit longer.我喜欢的一种方法是将数据分割成段(窗口,可能重叠),大约比您想看到的“凹凸”的最大数量长 4 倍,也许更长一点。 Then window each segment before using a much longer (size of about the resolution of the final plot you want) zero-padded FFT.然后在 window 之前使用更长的每个段(大小大约为您想要的最终 plot 的分辨率)零填充 FFT。 Then average the results of the multiple FFTs of the multiple windowed segments.然后对多个窗口段的多个 FFT 的结果进行平均。 This works because a zero-padded FFT is (almost) equivalent to a highest-quality Sinc interpolating low-pass filter.这是有效的,因为零填充 FFT(几乎)等同于最高质量的 Sinc 插值低通滤波器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM