繁体   English   中英

从数据的FFT分析中提取含义

[英]Extracting meaning from an FFT analysis of data

我的问题是关于快速傅立叶变换的,因为这是我第一次使用它们。 因此,我有一组按年(从1700年至2009年)的数据,并且每年对应于某个值(读数)。 当我根据年份绘制读数时,它给出了下面的第一张图。 现在,我的目标是使用带python的FFT来找到读数最高的主要时段(从图中看来,该时期大约是1940年-1950年)。 因此,我执行了FFT并获得了其幅度和功率谱(有关功率谱,请参见第二图)。 功率谱显示主频率在0.08和0.1(周期/年)之间。 我的问题是,我该如何将其与“读书与年代”联系起来? 即我如何从这个主导频率中知道哪个年(或几年)是主导年(或者我怎么用它来找到它)?

可以在以下位置找到数据列表: http : //www.physics.utoronto.ca/%7Ephy225h/web-pages/sunspot_yearly.txt

我写的代码是:

from pylab import *
from numpy import *
from scipy import *
from scipy.optimize import leastsq
import numpy.fft

#-------------------------------------------------------------------------------
# Defining the time array
tmin = 0
tmax = 100 * pi
delta = 0.1
t = arange(tmin, tmax, delta)

# Loading the data from the text file
year, N_sunspots = loadtxt('/Users/.../Desktop/sunspot_yearly.txt', unpack = True) # years and number of sunspots

# Ploting the data
figure(1)
plot(year, N_sunspots)
title('Number of Sunspots vs. Year')
xlabel('time(year)')
ylabel('N')

# Computing the FFT
N_w = fft(N_sunspots)

# Obtaining the frequencies 
n = len(N_sunspots)
freq = fftfreq(n) # dt is default to 1

# keeping only positive terms
N = N_w[1:len(N_w)/2.0]/float(len(N_w[1:len(N_w)/2.0]))
w = freq[1:len(freq)/2.0]

figure(2)
plot(w, real(N))
plot(w, imag(N))
title('The data function f(w) vs. frequency')
xlabel('frequency(cycles/year)')
ylabel('f(w)')
grid(True)

# Amplitude spectrum
Amp_spec = abs(N)

figure(3)
plot(w, Amp_spec)
title('Amplitude spectrum')
xlabel('frequency(cycles/year)')
ylabel('Amplitude')
grid(True)

# Power spectrum
Pwr_spec = abs(N)**2

figure(4)
plot(w, Pwr_spec 'o')
title('Power spectrum')
xlabel('frequency(cycles/year)')
ylabel('Power')
grid(True)

show()

下图显示了输入到FFT的数据。 原始数据文件总共包含309个样本。 FFT会自动在右端添加零值,以将输入样本的数量填充到下一个较高的2的幂(2 ^ 9 = 512)。

时域图-年度太阳斑数据-sooeet.com FFT计算器

下图显示了输入到FFT的数据,并应用了Kaiser-Bessel a = 3.5窗口函数。 在这种情况下,当FFT的输入是整个采样间隔内的非周期性信号时,窗口函数可减少FFT中的频谱泄漏误差。

使用Kaiser-Bessel窗口的年度太阳斑数据-sooeet.com FFT计算器

下图显示了满量程的FFT输出。 没有窗口功能。 峰值为0.0917968(47/512)频率单位,对应于10.89年(1 / 0.0917968)的时间值。

年度太阳斑数据的FFT,无窗口-sooeet.com FFT计算器

下图显示了满量程的FFT输出。 使用Kaiser-Bessel时,将应用a = 3.5窗口。 峰值以0.0917968(47/512)频率单位保持在相同的频率位置,这对应于10.89年(1 / 0.0917968)的时间值。 由于窗口功能提供的光谱泄漏减少,峰在背景上方更清晰可见。

年度太阳斑点数据的FFT,应用Kaiser-Bessel窗口-sooeet.com FFT计算器

总而言之,我们可以肯定地说原始帖子中提供的Sun斑点数据是周期性的,基本周期为10.89年。

FFT和图形使用Sooeet FFT计算器完成

暂无
暂无

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

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