from scipy import * import scipy.io.array_import from scipy import gplt from scipy import fftpack tempdata = scipy.io.array_import.read_array('sunspots.dat') year=tempdata[:,0] wolfer=tempdata[:,1] gplt.plot(year,wolfer,'title "Meas" with linespoints') gplt.xtitle('Year') gplt.ytitle('Wolfer number') gplt.grid("off") gplt.output('sunspot_time.png','png medium transparent picsize 600 400') Y=fft(wolfer) gplt.plot(Y.real,Y.imag,'title "Meas" with points') gplt.xtitle('real(FFT)') gplt.ytitle('img(FFT)') gplt.xaxis((-4000,2000)) gplt.grid("off") gplt.output('sunspot_FFT.png','png medium transparent picsize 600 400') n=len(Y) power = abs(Y[1:(n/2)])**2 nyquist=1./2 freq=array(range(n/2))/(n/2.0)*nyquist gplt.plot(freq[1:len(freq)], power,'title "Meas" with linespoints') gplt.xtitle('Frequency [1/year]') gplt.ytitle('|FFT|**2') gplt.xaxis((0,0.20)) gplt.grid("off") gplt.output('sunspot_freq.png','png medium transparent picsize 600 400') period=1./freq gplt.plot(period[1:len(period)], power,'title "Meas" with linespoints') gplt.xaxis((0,40)) gplt.xtitle('Period [year]') gplt.ytitle('|FFT|**2') gplt.grid("off") gplt.output('sunspot_period.png','png medium transparent picsize 600 400')