Scipy/Numpy FFT Frequency Analysis

后端 未结 4 877
再見小時候
再見小時候 2020-12-04 08:15

I\'m looking for how to turn the frequency axis in a fft (taken via scipy.fftpack.fftfreq) into a frequency in Hertz, rather than bins or fractional bins.

I tried to

4条回答
  •  没有蜡笔的小新
    2020-12-04 08:58

    Your equation is messed up.

    fs = 33.33
    df1 = 2*pi * (2.0/fs)
    df2 = 2*pi * (5.0/fs)
    x = [10*sin(n*df1) + 5*sin(n*df2) + 2*random.random() for n in range(4000)]
    

    This gives you 4000 samples of your function, sampled at 33.33 Hz, representing 120 seconds of data.

    Now take your FFT. Bin 0 will hold the DC result. Bin 1 will be 33.33, bin 2 will be 66.66, etc..

    Edit: I forget to mention that, since your sampling rate is 33.33 Hz, the maximum frequency that can be represented will be fs/2, or 16.665 Hz.

提交回复
热议问题