? on scipy.fftpack

Robert Kern robert.kern at gmail.com
Wed Jun 28 14:12:45 EDT 2006


Mike Duffy wrote:
> I've been debugging a simulation I wrote a while ago, and it seems that
> the problem is in the fft module itself. I'm trying a simple test by
> just feeding the function a basic real gaussian. Obviously, I should
> get back the same real gaussian, but what I get is not even close. Can
> anyone help me? Thanks in advance.

You will probably want to ask scipy questions on scipy-user. There aren't many 
scipy people here.

   http://www.scipy.org/Mailing_Lists

I haven't run your code, yet, but one of the things you are running into is the 
FFT packing convention for FFTs on real functions. Please read the docstring:

Type:           function
Base Class:     <type 'function'>
String Form:    <function rfft at 0x204fbf0>
Namespace:      Interactive
File: 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy-0.5.0.1980-py2.4-mac
osx-10.4-ppc.egg/scipy/fftpack/basic.py
Definition:     rfft(x, n=None, axis=-1, overwrite_x=0)
Docstring:
     rfft(x, n=None, axis=-1, overwrite_x=0) -> y

     Return discrete Fourier transform of real sequence x.

     The returned real arrays contains
       [y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2))]              if n is even
       [y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2))]   if n is odd
     where
       y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k* 2*pi/n)
       j = 0..n-1
     Note that y(-j) = y(n-j).

     Optional input:
       n
         Defines the length of the Fourier transform. If n is not
         specified then n=x.shape[axis] is set. If n<x.shape[axis],
         x is truncated. If n>x.shape[axis], x is zero-padded.
       axis
         The transform is applied along the given axis of the input
         array (or the newly constructed array if n argument was used).
       overwrite_x
         If set to true, the contents of x can be destroyed.

     Notes:
       y == rfft(irfft(y)) within numerical accuracy.



-- 
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