# from scipy import from scipy import gplt from scipy import fftpack imp

 ``` 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 39 40 41``` ```from scipy import * from scipy import gplt from scipy import fftpack import copy y = [[], [], [], []] power = copy.deepcopy( [[], [], [], []] ) period = copy.deepcopy( [[], [], [], []] ) p_data = copy.deepcopy( [[], [], [], []] ) nyquist=1./2 for i in xrange(32): y[0].append(math.sin(j)/100.) for i in xrange(1,4): y[i] = copy.deepcopy(y[0]) # randomised y for i in xrange(32): y[1][i] += random.random() # random inserts and doubled range for i in xrange(1, 64, 2): if ( random.random() >= 0.85 ) and ( i <= len(y[3]) ): y[2].insert(i, y[2][i-1]) y[3].insert(i, y[3][i-1]) for i in xrange(0, 4): Y = fft(y[i]) ni = len(Y)/2 nf = len(Y)/2.0 freq = array(range(ni))/(nf)*nyquist power[i] = abs( Y[i][1:ni] )**2 period[i] = 1./freq 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], p_data[3]) gplt.xaxis((0,64)) gplt.ytitle('|FFT|**2') gplt.grid("off") gplt.output('sunspot_period.png','png medium transparent picsize 600 400') ```