[SciPy-user] Difference between ffts?

Robert Kern robert.kern@gmail....
Mon Oct 13 22:48:41 CDT 2008

On Mon, Oct 13, 2008 at 22:36, Collin Day <dcday137@gmail.com> wrote:
> Hi all,
> I have looked around, but can't seem to find an answer.  I have been
> trying the following (according to the Getting started page -
> http://www.scipy.org/Getting_Started)
> from scipy import *
> a=zeros(1000)
> a[:100]=1
> b=fft(a)
> plot(abs(b))
> and I get what you would expect - the abs. value of a sinc function
> rect(x) ->F-> sinc(Frequency)
> now, if I try the Scipy.fftpack
> import scipy.fftapck as S
> c=S.fft(a)
> figure()
> plot(abs(c))
> I get something I would expect if I did a FFT on a sine function (kind
> of like dual spikes equally spaced)

Can you show us the plots? I don't see a difference.

> I do see there is a difference in the packing or how the fft output is
> represented.  How do you plot the data from fftpack so that it looks
> correct?  Should I even bother?

Typically, I will use fftfreq() to get the "X" values in packed form
and then use fftshift() on both X and Y to "unpack" the arrays.

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 SciPy-user mailing list