1
$\begingroup$

I'm using numpy FFT functions to find the amplitude, frequency and phase of low frequency signals. focusing between 0-10 hz.Part of my project is to vary the time over which the sample is taken and the sample frequency. To test the function im currently using unit amplitudes and set frequencies. At any sample size other then 10,20 sec .. ect the fft becomes rather inaccurate.

Since i am using unit amplitudes of 1, the outputs should all be 1, or at least the same number if my scaling is off. but i am getting aptitude outputs from 1 to 0.66 when not using a sample of a multiple of 10.

i have tried changing both the sample time and frequency to match the total sample size but this doesn't seem to have any effect.

Why does this happen? i can't find anything about why the FFT only works for these discrete time periods.

functions use:

z = Series(ampl_OR[i] * np.cos(2np.pifreq_OR[i]*t_OR + phase_OR[i]))

Ramp = np.fft.fft(z) #real amplitudes used to find phase

Rfeq = np.fft.fftfreq(z.shape[-1]) #real frequency domain to find phase

For example I expect this output for any time series. measured over 20 seconds

but instead get plots like this. measured over 23 seconds

$\endgroup$
4
  • 3
    $\begingroup$ en.wikipedia.org/wiki/Spectral_leakage $\endgroup$ – Ben Mar 14 at 19:41
  • $\begingroup$ In your case, your frequencies have a whole number of periods in a 10-second, 20-second or 30-second window. So you have no leakage. With a period of 11 seconds, you have spectral leakge. $\endgroup$ – Ben Mar 14 at 19:42
  • $\begingroup$ Related $\endgroup$ – OverLordGoldDragon Mar 15 at 1:23
  • $\begingroup$ Im focusing on measuring these low frequencies looking at real world applications, how would i reduce the leakage effect?? $\endgroup$ – Jacob wood Mar 16 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.