problem with fft periodogram

A

aitor69gonzalez

Hello,

I am ploting a fft periodogram of my data using a script (found in
internet: http://linuxgazette.net/115/andreasen.html ) that gave me
good results before. There should be a periodicity of >160 in the data
as can be seen by eye. However, this script now says that there is
periodicity of ~9. Can somebody explain me what's wrong? Thank you in
advance.
I present first the python script and second my data.
###### usage ############
python <script_name> <data_file>
######### PYTHON SCRIPT ###########
from scipy import *
import scipy.io.array_import
from scipy import gplt
from scipy import fftpack
# Read file
f=open(sys.argv[1], 'r')
tempdata = scipy.io.array_import.read_array(f)
minutes=tempdata[:,0]
wolfer=tempdata[:,1]
# plot data
gplt.plot(minutes,wolfer,'title "Meas" with linespoints')
gplt.xtitle('Minutes')
gplt.ytitle('Wolfer number')
gplt.grid("off")
Y=fft(wolfer)
n=len(Y)
power = abs(Y[1:(n/2)])**2
nyquist=1./2
print nyquist
freq=array(range(n/2))/(n/2.0)*nyquist
period=1./freq
# plot period
gplt.plot(period[1:len(period)], power,'title "Simul" with
linespoints')
gplt.xaxis((50,400))
gplt.xtitle('Period [minutes]')
gplt.ytitle('|FFT|**2')
##########################
######## DATA ############
0 48
20 49
40 54
60 49
80 69
100 92
120 98
140 58
160 50
180 66
200 76
220 82
240 119
260 141
280 128
300 107
320 93
340 78
360 74
380 74
400 93
420 109
440 135
460 118
480 90
500 64
520 58
540 56
560 70
580 90
600 115
620 158
640 150
660 96
680 73
700 61
720 55
740 66
760 81
780 116
800 142
820 111
840 102
860 84
880 64
#################
 
T

Travis E. Oliphant

Hello,

I am ploting a fft periodogram of my data using a script (found in
internet: http://linuxgazette.net/115/andreasen.html ) that gave me
good results before. There should be a periodicity of >160 in the data
as can be seen by eye. However, this script now says that there is
periodicity of ~9. Can somebody explain me what's wrong? Thank you in
advance.

The units are wrong on your period axis. Right now you have them in
units of "sample-spacing". So, the plot is telling you that you have a
periodicity of ~9 sample spacings. To get it in unites of minutes you
need to multiply period by the difference in minutes

period_in_minutes = period * (minutes[1] - minutes[0])

Then, plot period_in_minutes versus power. I see a peak around 180
minutes in your data.



-Travis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,260
Messages
2,571,039
Members
48,768
Latest member
first4landlord

Latest Threads

Top