Frequency spectrum with fft of a real valued array...?

Robert Kern robert.kern at
Thu Jan 11 19:08:00 CET 2007

Holger wrote:

> What does it mean to me? How do I get to the wanted frequenca spectrum???

It's packed in the conventional FFT format. Here is a function in numpy (the
successor to Numeric, which I assume that you are using) that generates the
corresponding frequencies in the same packed format:

In [324]: import numpy

In [325]: numpy.fft.fftfreq?
Type:           function
Base Class:     <type 'function'>
Namespace:      Interactive
Definition:     numpy.fft.fftfreq(n, d=1.0)
    fftfreq(n, d=1.0) -> f

    DFT sample frequencies

    The returned float array contains the frequency bins in
    cycles/unit (with zero at the start) given a window length n and a
    sample spacing d:

      f = [0,1,...,n/2-1,-n/2,...,-1]/(d*n)         if n is even
      f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n)   if n is odd

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Python-list mailing list