简体   繁体   English

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

[英]Extracting meaning from an FFT analysis of data

My question is about Fast Fourier Transforms, since this is the first time i'm using them. 我的问题是关于快速傅立叶变换的,因为这是我第一次使用它们。 So, I have a set of data by years (from 1700 - 2009) and each year corresponding to a certain value (a reading). 因此,我有一组按年(从1700年至2009年)的数据,并且每年对应于某个值(读数)。 when i plot the readings against the years it gives me the first plot below. 当我根据年份绘制读数时,它给出了下面的第一张图。 Now, my aim is to find the dominant period with the highest readings using FFT with python (From the graph it seems that it is around 1940 - 1950). 现在,我的目标是使用带python的FFT来找到读数最高的主要时段(从图中看来,该时期大约是1940年-1950年)。 So i performed an FFT and got its amplitude and power spectra (see second plot for power spectrum). 因此,我执行了FFT并获得了其幅度和功率谱(有关功率谱,请参见第二图)。 The power spectrum shows that the dominant frequencies are between 0.08 and 0.1 (cycles/year). 功率谱显示主频率在0.08和0.1(周期/年)之间。 My question is, how do i link this to the Readings vs. years ? 我的问题是,我该如何将其与“读书与年代”联系起来? ie how do i know from this dominant frequency what year (or period of years) is the dominant one (or how can i use it to find it) ? 即我如何从这个主导频率中知道哪个年(或几年)是主导年(或者我怎么用它来找到它)?

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

the code i wrote is: 我写的代码是:

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()

The graph below shows the data input to the FFT. 下图显示了输入到FFT的数据。 The original data file contains a total of 309 samples. 原始数据文件总共包含309个样本。 The zero values at the right end are added automatically by the FFT, to pad the number of input samples to the next higher power of two (2^9 = 512). FFT会自动在右端添加零值,以将输入样本的数量填充到下一个较高的2的幂(2 ^ 9 = 512)。

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

The graph below shows the data input to the FFT, with the Kaiser-Bessel a=3.5 window function applied. 下图显示了输入到FFT的数据,并应用了Kaiser-Bessel a = 3.5窗口函数。 The window function reduces the spectral leakage errors in the FFT, when the input to the FFT is a non-periodic signal over the sampling interval, as in this case. 在这种情况下,当FFT的输入是整个采样间隔内的非周期性信号时,窗口函数可减少FFT中的频谱泄漏误差。

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

The graph below shows the FFT output at full scale. 下图显示了满量程的FFT输出。 Without the window function. 没有窗口功能。 The peak is at 0.0917968 (47/512) frequency units, which corresponds to a time value of 10.89 years (1/0.0917968). 峰值为0.0917968(47/512)频率单位,对应于10.89年(1 / 0.0917968)的时间值。

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

The graph below shows the FFT output at full scale. 下图显示了满量程的FFT输出。 With the Kaiser-Bessel a=3.5 window applied. 使用Kaiser-Bessel时,将应用a = 3.5窗口。 The peak remains in the same frequency location at 0.0917968 (47/512) frequency units, which corresponds to a time value of 10.89 years (1/0.0917968). 峰值以0.0917968(47/512)频率单位保持在相同的频率位置,这对应于10.89年(1 / 0.0917968)的时间值。 The peak is more clearly visible above the background, due to the reduction in spectral leakage provided by the window function. 由于窗口功能提供的光谱泄漏减少,峰在背景上方更清晰可见。

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

In conclusion, we can say with high certainty that the Sun spot data, provided in the original post, is periodic with a fundamental period of 10.89 years. 总而言之,我们可以肯定地说原始帖子中提供的Sun斑点数据是周期性的,基本周期为10.89年。

FFT and graphs were done with the Sooeet FFT calculator FFT和图形使用Sooeet FFT计算器完成

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

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