make THIS better

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from scipy import *
from scipy import gplt
from scipy import fftpack
sunspot = scipy.io.array_import.read_array('sunspots.dat')
year=sunspot[:,0]
wolfer=sunspot[:,1]
data = []
for i in range(0, 32):
for j in range(0, 32):
data.append([i/100., math.sin(j)/100.], math.sin(j)/100.]+random.randint(1, 100)/100) # Each data entry has the form [x, y1, y2]
y[0] = [j for i,j,k in data]
y[1] = [k for i,j,k in data]
y[2] = y1
for i in range(1, 64, 2):
if i >= len(y[2]):
break;
if random.randint(1, 100) >= 85:
ify[2].insert(y[2][i-1])
nyquist=1./2
for i in range(0, 3):
Y[i]=fft(y[i])
n[i]=len(Y[i])
power[i] = abs(Y[i][1:(n1/2)])**2
freq[i]=array(range(n[i]/2))/(n[i]/2.0)*nyquist
period[i]=1./freq[i]
p_data[i] = Gnuplot.PlotItems.Data(period[i][1:len(period[i])], power[i],y[i])
gplt.plot(p_data[0], p_data[1], p_data[2])
gplt.xaxis((0,40))
gplt.ytitle('|FFT|**2')
gplt.grid("off")
gplt.output('sunspot_period.png','png medium transparent picsize 600 400')