Numerical & FFT

Fernando Pérez fperez528 at yahoo.com
Sun Nov 3 17:57:45 EST 2002


David Siroky wrote:

> Hi!
> 
> Functions "fft" and "real_fft" returns some array. What those numbers
> exactly mean? Especially the first one (DC or what)?
> 
> Thank you!
> 
> David
In [3]: fft?
Type:           function
Base Class:     <type 'function'>
String Form:    <function fft at 0x81f87fc>
Namespace:      Interactive
File:           /usr/lib/python2.2/site-packages/Numeric/FFT/FFT.py
Definition:     fft(a, n=None, axis=-1)
Docstring:
    fft(a, n=None, axis=-1)

    Will return the n point discrete Fourier transform of a. n defaults to the
    length of a. If n is larger than a, then a will be zero-padded to make up
    the difference. If n is smaller than a, the first n items in a will be
    used.

    The packing of the result is "standard": If A = fft(a, n), then A[0]
    contains the zero-frequency term, A[1:n/2+1] contains the
    positive-frequency terms, and A[n/2+1:] contains the negative-frequency
    terms, in order of decreasingly negative frequency. So for an 8-point
    transform, the frequencies of the result are [ 0, 1, 2, 3, 4, -3, -2, -1].

    This is most efficient for n a power of two. This also stores a cache of
    working memory for different sizes of fft's, so you could theoretically
    run into memory problems if you call this too many times with too many
    different n's.


In [4]: real_fft?
Type:           function
Base Class:     <type 'function'>
String Form:    <function real_fft at 0x827101c>
Namespace:      Interactive
File:           /usr/lib/python2.2/site-packages/Numeric/FFT/FFT.py
Definition:     real_fft(a, n=None, axis=-1)
Docstring:
    real_fft(a, n=None, axis=-1)

    Will return the n point discrete Fourier transform of the real valued
    array a. n defaults to the length of a. n is the length of the input, not
    the output.

    The returned array will be the nonnegative frequency terms of the
    Hermite-symmetric, complex transform of the real array. So for an 8-point
    transform, the frequencies in the result are [ 0, 1, 2, 3, 4]. The first
    term will be real, as will the last if n is even. The negative frequency
    terms are not needed because they are the complex conjugates of the
    positive frequency terms. (This is what I mean when I say
    Hermite-symmetric.)

    This is most efficient for n a power of two.

cheers,

f



More information about the Python-list mailing list