3

I'm using a slightly modified version of this python code to do frequency analysis: FFT wrong value?

Lets say I have a pack of sine waves in the time domain that are very close together in frequency, while sharing the same amplitude. This is how they look like in the frequency domain, using FFT on 1024 samples from which I strip out the second half, giving 512 bins of resolution:

Blue: rectangular window. Pink: Nuttall window

This is when I apply a FFT over the same group of waves but this time with 128 samples (64 bins):

Blue: rectangular window. Pink: Nuttall window

I expected a plateau-ish frequency response but it looks like the waves in the center are being cancelled. What are those "horns" I see? Is this normal?

Community
  • 1
  • 1
user2464424
  • 1,536
  • 1
  • 14
  • 28

2 Answers2

5

I believe your result is correct. The peaks are at ±f1 and ±f2), corresponding to the respective frequency components of the two signals shown in your first plot.

I assume that you are shifting the DC component back to the center? What "waves in the center" are you referring to?

There are a couple of other potential issues that you should be aware of:

  • Aliasing: by inspection it appears that you have enough samples across your signal but keep in mind that artificial (or aliased) frequencies can be created by the FFT, if there are not enough sample points to capture the underlying frequency. Specifically, if your frequency is f, then you need your data sample spacing to be at least, Δx = 1/(2*f), or smaller.
  • Windowing: your signal is windowed (has a finite extent) so there will also be some broadening, ringing, or redistribution of power about each spatial frequency due to edge affects.
  • Since I don't know the details of your data, I went ahead and created a sinusoid and then sampled the data close to what appears to be your sampling rate. For example, below is a sinusoid with 64 points and with a signal frequency at 10 cycles (count the peaks):

    enter image description here

    The FFT result is then:

    enter image description here

    which shows the same quantitative features as yours, but without having your data, its difficult for me to match your exact situation (spacing and taper).

    Next I applied a super-Gauss window function (shown below) to simulate the finite extent of your data:

    enter image description here

    After applying the window to the input signal we have:

    enter image description here

    The corresponding FFT result shows some additional power redistribution, due to the finite extent of the data:

    enter image description here

    Although I can't match your exact situation, I believe your results appear as expected and some qualitative features of your data have been identified. Hope this helps.

    Bruce Dean
    • 2,798
    • 2
    • 18
    • 30
    • Jupiter! I'm sorry to say that but your answer has two major misunderstandings. First off, the first image I posted in the question effectively shows the _frequency_ domain of 10 sine waves stacked together with very similar frequencies! In an additive synthesizer if you will. That's not the time domain btw. Second, the horns I showed in the second image are NOT caused by the proverbial FFT mirroring of the result. In fact, I explicitely said that i stripped out the second half of the FFT to show just the first half. Please do re-read my question. – user2464424 Dec 27 '13 at 11:36
    • You show 2 figures and the 1st is sinusoidal. So you are saying that the 1st figure is the result of an FFT, of some other signal that is not shown? If so thats fine, just want to understand what you have. If thats the case then that means the other "unknown" signal is synthesized from the frequency spectrum shown in the top figure. What then are you taking away when you say "strip out the 2nd half"? Could you show that? Then right below the 1st figure you say that you then perform the FFT again after changing the sampling of the signal (that is not shown), from 1024 samples to 128? – Bruce Dean Dec 27 '13 at 14:02
    1

    Sine waves closely spaced in the frequency domain will occasionally nearly cancel out in the time domain. Since your second FFT is 8 times shorter than your first FFT, you may have windowed just such an short area of cancellation. Try a different time location of shorter time window to see something different (or different phases of sinusoids).

    hotpaw2
    • 70,107
    • 14
    • 90
    • 153
    • Yes! I tried randomizing the phase of the sines and now the 128-FFT shows a single, nice, smooth peak as expected. Thanks. – user2464424 Dec 27 '13 at 21:53