[SciPy-User] rfft
garyr
garyr at fidalgo.net
Mon Jun 20 15:30:39 EDT 2011
----- Original Message -----
From: "Charles R Harris" <charlesr.harris at gmail.com>
To: "SciPy Users List" <scipy-user at scipy.org>
Sent: Monday, June 20, 2011 10:10 AM
Subject: Re: [SciPy-User] rfft
> On Mon, Jun 20, 2011 at 10:35 AM, garyr <garyr at fidalgo.net> wrote:
>
>>
>> ----- Original Message ----- From: "Charles R Harris" <
>> charlesr.harris at gmail.com>
>> To: "SciPy Users List" <scipy-user at scipy.org>
>> Sent: Monday, June 20, 2011 8:11 AM
>> Subject: Re: [SciPy-User] rfft
>>
>>
>>
>> On Mon, Jun 20, 2011 at 9:03 AM, garyr <garyr at fidalgo.net> wrote:
>>>
>>> If I generate a sine wave of a particular frequency in an array of type
>>>> float32 or float64 and compute the transform using the function fft (in
>>>> scipy/fftpack/basic.py) I find the signal in the correct bin. If I use
>>>> the
>>>> function rfft, which is described as returning the Fourier transform of
>>>> a
>>>> real sequence, I find the signal in the bin corresponding to twice the
>>>> actual frequency. I thought rfft would be the proper function to use
>>>> for
>>>> real (non-complex) data. What is the correct usage of rfft?
>>>>
>>>>
>>>> Could you provide an example?
>>>
>>> Chuck
>>>
>>>
>>
>>
> Ah, rfft from scipy returns a *real* array with the complex numbers packed
> in there together. That's why you can do it in place, the zero imaginary
> parts for DC and Nyquist are omitted. If you want a convenient format, use
> rfft from numpy.
I posted a reply with my test code as an attachment but apparently it wasn't
accepted, which is just as well. Now I begin to understand; I should have
checked the type of arrays returned by the two functions.
Thanks for your help.
More information about the SciPy-User
mailing list