[Numpy-discussion] can't take FFT of ndarray
charles reid
charlesreid1@gmail....
Fri Mar 6 16:51:38 CST 2009
In [3]: type(mixfrac)
Out[3]: <type 'list'>
In [4]: mixfracarray=array(mixfrac)
In [5]: type(mixfracarray)
Out[5]: <type 'numpy.ndarray'>
(Is that what you were referring to?)
On Fri, Mar 6, 2009 at 3:44 PM, Charles R Harris
<charlesr.harris@gmail.com>wrote:
>
>
> On Fri, Mar 6, 2009 at 3:36 PM, charles reid <charlesreid1@gmail.com>wrote:
>
>> 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?
>>
>
> After you convert to an array what is the array type? I suspect an object
> in there somewhere.
>
> Chuck
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090306/e3baffab/attachment.html
More information about the Numpy-discussion
mailing list