[SciPy-user] FFT not producing correct result

Mike Duffy mike.s.duffy at gmail.com
Thu Jul 6 14:59:15 EDT 2006


On 7/6/06, Vincent Favre-Nicolin <vincefn at users.sourceforge.net> wrote:

>
>    You should look at fftpack.fftshift if you want to shift the
> zero-frequency
> term to the center of the array.
>


Ok, thanks. That helps some. I used the fftshift and got the expected result
(I'm guessing my swapaxis function only worked because the gaussian is a
special case?). But, it seems that I dont need the ifftshift? I wish I
understood this better. Essentially, the algorithm I have been trying to
execute (unsuccessfully) is this:

<code>
f = some_wavefunction()
for i in xrange(N):
    g = fft(f)
    g = foo(g)
    f = ifft(g)
    f = bar(f)
</code>

Should it be written this way:

<code>
f = some_wavefunction()
for i in xrange(N):
    g = fftshift(fft(f))
    g = foo(g)
    f = ifftshift(ifft(g))   # is this ifftshift necessary??
    f = bar(f)
</code>

-- 
Michael S. Duffy
University of Florida
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060706/07e5d897/attachment.html>


More information about the SciPy-User mailing list