? on scipy.fftpack

Mike Duffy Mike.S.Duffy at gmail.com
Wed Jun 28 12:56:12 EDT 2006


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.

<code>
from scipy import *
import pylab

fft, ifft = fftpack.rfft, fftpack.irfft

def main():
    sigma = 50.
    x = arange(-100, 100, 1, 'f')
    g = exp(-x**2 / (2 * sigma)) / sqrt(2 * pi)
    testFFT(x, g)

def testFFT(x, f):
    pylab.plot(x, f)
    pylab.title('Initial gaussian')
    pylab.show()
    pylab.clf()

    f = fft(f)
    pylab.plot(x, f)
    pylab.title('After first FFT')
    pylab.show()
    pylab.clf()

    f = fft(f)
    pylab.plot(x, f)
    pylab.title('After first iFFt')
    pylab.show()
    pylab.clf()

if __name__ == '__main__': main()
</code>




More information about the Python-list mailing list