[Numpy-discussion] can't take FFT of ndarray

charles reid charlesreid1@gmail....
Fri Mar 6 16:36:10 CST 2009


Hi there -

I've imported some data from a file, and it's in a list called mixfrac.  I'd
like to take the Fourier transform of the data, but when I try to take the
FFT of the list, I get this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/charles/apriori/read.py in <module>()
----> 1
      2
      3
      4
      5

/Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc
in fft(a, n, axis)
    105     """
    106
--> 107     return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf,
_fft_cache)
    108
    109

/Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc
in _raw_fft(a, n, axis, init_function, work_function, fft_cache)
     64     if axis != -1:
     65         a = swapaxes(a, axis, -1)
---> 66     r = work_function(a, wsave)
     67     if axis != -1:
     68         r = swapaxes(r, axis, -1)

TypeError: array cannot be safely cast to required type


so I convert to an array and run fft(mixfracarray).

mixfracarray = array(mixfrac)
fft(mixfracarray)

whereupon I recieve the error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/charles/apriori/read.py in <module>()
----> 1
      2
      3
      4
      5

/Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc
in fft(a, n, axis)
    105     """
    106
--> 107     return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf,
_fft_cache)
    108
    109

/Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc
in _raw_fft(a, n, axis, init_function, work_function, fft_cache)
     64     if axis != -1:
     65         a = swapaxes(a, axis, -1)
---> 66     r = work_function(a, wsave)
     67     if axis != -1:
     68         r = swapaxes(r, axis, -1)

TypeError: array cannot be safely cast to required type

This is strange, because I can run fft(array([0,0,0,1,1,1])), or
fft([0,0,0,1,1,1]), perfectly fine.  This is passing an array and a list,
respectively.

type(mixfrac) is list and size(mixfrac) is 100; type(mixfracarray) is
ndarray, and mixfracarray.shape is (100,).  I've also tried taking the FFT
of the transpose of mixfracarray, but that doesn't work either.

I'm stumped - why can't I run an FFT on either mixfrac or mixfracarray?


Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090306/235fd051/attachment.html 


More information about the Numpy-discussion mailing list