Given the sampling rate of FSample and convert blockize N , you can calculate the frequency resolution deltaF , the sampling interval deltaT and the total capture time capT using the ratios:
deltaT = 1/FSample = capT/N deltaF = 1/capT = FSample/N
Keep in mind that FFT returns a value from 0 to FSample or equivalently -FSample/2 to FSample/2 . In your plot, you are already dropping the -FSample/2 part to 0 . NumPy includes a helper function to calculate all this for you: fftfreq .
For your deltaT = 1 hour and N = 576 you get deltaF = 0.001736 cycles/hour = 0.04167 cycles/day , from -0.5 cycles/hour to 0.5 cycles/hour . Therefore, if you have a peak in amplitude, for example, in bin 48 (and in hopper 528), which corresponds to the frequency component of 48*deltaF = 0.0833 cycles/hour = 2 cycles/day.
In general, you should apply the window function to the data of your temporary domain before calculating the FFT to reduce spectral leakage . Hannah’s window is almost never a bad choice. You can also use the rfft function to skip the output part of -FSample/2, 0 . So your code will look like this:
ft = np.fft.rfft(signal*np.hanning(len(signal))) mgft = abs(ft) xVals = np.fft.fftfreq(len(signal), d=1.0)
mtrw
source share