On Wednesday, June 27, 2012 6:45:46 PM UTC+2, alx wrote:
> On 27 juin, 18:45, alx <lecacheux.al...@wanadoo.fr> wrote:
>> On 27 juin, 18:33, David Fanning <n...@idlcoyote.com> wrote:
>>
>>
>>
>>
>>
>>> alx writes:
>>>> You can use the /CENTER keyword in FFT function since IDL7.1
>>
>>> Well, it was *present* in IDL 7.1. I don't think
>>> it actually worked until later.
>>
>>> Cheers,
>>
>>> David
>>
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>>
>> ?
>> IDL> print,fft(cos(2*!pi*findgen(16)/16*3))
>> ( 5.06635e-008, 0.000000)( 8.06580e-008, 3.52675e-008)
>> (-9.04610e-009, 2.63418e-008)( 0.500000, 1.28007e-007)
>> (-9.08976e-008, 1.49012e-008)
>> (-2.65443e-008,-1.35536e-008)( 1.20273e-008, 2.63418e-008)
>> (-7.60014e-008,-9.51177e-008)( 1.25169e-007, -0.000000)
>> (-7.60014e-008, 9.51177e-008)
>> ( 1.20273e-008,-2.63418e-008)(-2.65443e-008, 1.35536e-008)
>> (-9.08976e-008,-1.49012e-008)( 0.500000,-1.28007e-007)
>> (-9.04610e-009,-2.63418e-008)
>> ( 8.06580e-008,-3.52675e-008)
>> IDL> print,fft(cos(2*!pi*findgen(16)/16*3),/CENTER)
>> ( 1.25169e-007, -0.000000)(-7.60014e-008, 9.51177e-008)
>> ( 1.20273e-008,-2.63418e-008)(-2.65443e-008, 1.35536e-008)
>> (-9.08976e-008,-1.49012e-008)
>> ( 0.500000,-1.28007e-007)(-9.04610e-009,-2.63418e-008)
>> ( 8.06580e-008,-3.52675e-008)( 5.06635e-008, 0.000000)
>> ( 8.06580e-008, 3.52675e-008)
>> (-9.04610e-009, 2.63418e-008)( 0.500000, 1.28007e-007)
>> (-9.08976e-008, 1.49012e-008)(-2.65443e-008,-1.35536e-008)
>> ( 1.20273e-008, 2.63418e-008)
>> (-7.60014e-008,-9.51177e-008)
>> Both statements give expected results: i.e. non zero values at
>> positions 3 and 13 (CENTER=0) or 5 and 11 (CENTER=1).
>> alx.
>
> I forgot to say, by using 8.2.
> alx.
Thank you all for the answers. I guess the difference between changing sign of every second element and shift the array is due to a round-off error. This becomes clear when analyzing the differences between the two results using double precision or not.
Thanks also for the explanation of how the frequencies in an FFT are displayed.
I guess I'll have to update old code and remove the shift and use instead the center option.
Regards,
Helder
|