I would like to compute a power spectrum using Python3. From another thread about this topic I got the basic ingredients. I think it should be something like:
ps = np.abs(np.fft.fft(x))**2
timeres = t[1]-t[0]
freqs = np.fft.fftfreq(x.size, timeres)
idx = np.argsort(freqs)
plt.plot(freqs[idx], ps[idx])
plt.show()
Here t
are the times and x
is the photon count. I have also tried:
W = fftfreq(x.size, timeres=t[1]-t[0])
f_x = rfft(x)
plt.plot(W,f_x)
plt.show()
But both mostly just give me a peak around zero (though they are not the same). I am trying to compute the power spectrum from this:
Which should give me a signal around 580Hz. What am I doing wrong here?