comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: possible bug with center keyword option for FFT

Re: possible bug with center keyword option for FFT
type: item
description: Mark writes: > I sent the following to ittvis support, but I was wondering if anyone > has an insights into this. Basically, setting the center keyword for > FFT() gives an output that is shifted incorrectly. I'm doing some > really perverse stuff where it's really important to be sure what > frequency(angle) an output element from FFT() corresponds to.... I recall an earlier discussion here that this keyword might not be working correctly. I know I made a note in my book about this, and I normally save the reference, but I can't put my hands on it at the moment. 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.")
creator: David Fanning
date: 2011-02-11T18:05:50-00:00

Re: possible bug with center keyword option for FFT
type: item
description: On Feb 11, 1:05 pm, David Fanning <n...@dfanning.com> wrote: > Mark writes: >> I sent the following to ittvis support, but I was wondering if anyone >> has an insights into this. Basically, setting the center keyword for >> FFT() gives an output that is shifted incorrectly. I'm doing some >> really perverse stuff where it's really important to be sure what >> frequency(angle) an output element from FFT() corresponds to.... > > I recall an earlier discussion here that this keyword > might not be working correctly. I know I made a note in > my book about this, and I normally save the reference, > but I can't put my hands on it at the moment. > > 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.") Thanks David. I had a look on this group but apparently I missed that.... I hope the work on the book is going well.
creator: astroboy2k
date: 2011-02-11T18:17:24-00:00

Re: possible bug with center keyword option for FFT
type: item
description: > > > "Mark" wrote in message > news:babf90b7-e4a3-48bc-aecf-ae81e4a055d4@o18g2000prh.google groups.com... > > > 2: According to the documentation, with the center keyword off in > FFT(), element(0) is the FFT coefficient for the zero frequency. With > the keyword center set, this coefficient is shifted to the 'center' of > the array. This is a little ambiguous, especially when an array might > have an even or odd number of points in a dimension. You are absolutely correct. This is an error in IDL. The normal packing is 0 DC value 1/(NT) 2/(NT) ... (N/2-1)/(NT) (N/2)/NT = 1/(wT) = special point, IF n is even, aliased nyquist value -(N/2-1)/(NT) -(N/2-2)/(NT) ... -2/NT -1/NT So, if you want to "center" it, then you obviously want the most neg freq which I would say is -(N/2-1)/(NT), but you could arguably say it is the nyquist (for the even case). There is an ambiguity there. But, you always want the DC at the "center" followed by all the positive frequencies. For the case of 8 points you have i, freq 0 DC 1 1/N 2 2/N 3 3/N 4 nyquist 5 -3/N 6 -2/N 7 -1/N So to 'center' it, it must become i, old i, freq 0 5 -3/N 1 6 -2/N 2 7 -1/N 3 0 DC 4, 1 1/N 5, 2 2/N 6, 3 3/N 7, 4 nyquist However, it could also be (cause the nyquist is both most neg and most positive) I, old I, freq 0 4 nyquist 1, 5 -3/N 2, 6 -2/N 3, 7 -1/N 4, 0 DC 5, 1 1/N 6, 2 2/N 7, 3 3/N Now, either way, IDL is wrong since it has a postive frequency as it's first point, then the nyquist, then the neg freqs. Here, the DC can go to index 3, or to 4, but NOT to 5. cheers, bob -- ---------------------------- R.G. Stockwell, Ph.D. Northwest Research Associates, Colorado Research Associates Div. 3380 Mitchell Lane Boulder CO USA 80301 ----------------------------
creator: R.G.Stockwell
date: 2011-02-11T20:34:53-00:00

Re: possible bug with center keyword option for FFT
type: item
description: "R.G. Stockwell" wrote in message news:ij46h9$cg9$1@speranza.aioe.org... > > > "Mark" wrote in message > news:babf90b7-e4a3-48bc-aecf-ae81e4a055d4@o18g2000prh.google groups.com... > > > 2: According to the documentation, with the center keyword off in > FFT(), element(0) is the FFT coefficient for the zero frequency. With > the keyword center set, this coefficient is shifted to the 'center' of > the array. This is a little ambiguous, especially when an array might > have an even or odd number of points in a dimension. You are absolutely correct. This is an error in IDL. ********************************************** also, for the odd case, IDL is also wrong. When there is an odd number of points, the actual nyquist value is not sampled. (great trick question for anyone who thinks the nyquist is 1/(2T)) so you have, N = 7, and take T = 1 as the sampling interval: I, freq 0, DC 1, 1/N 2, 2/N 3, 3/N 4, -3/N 5, -2/N 6, -1/N so the 'centered' fft is: i, old i, freq 0, 4, -3/N 1, 5, -2/N 2, 6, -1/N 3, 0, DC 4, 1, 1/N 5, 2, 2/N 6, 3, 3/N From the example shown, the dc went to the 4th index when centered, it MUST go to the 3rd index. cheers, bob PS, I hope it's obvious how I am writing that. the first number is the current index of the spectrum array. Then the next column is the "old" index based on the result of a straight FFT (i.e with out the center keyword), then the final column is what the frequency value is, of a N point time series with sampling T = 1, and here N = 7 but I thought that it would be confusing to write out the 7 each time. ---------------------------- R.G. Stockwell, Ph.D. Northwest Research Associates, Colorado Research Associates Div. 3380 Mitchell Lane Boulder CO USA 80301 ----------------------------
creator: R.G.Stockwell
date: 2011-02-11T20:41:33-00:00

Re: possible bug with center keyword option for FFT
type: item
description: Hi all, This is indeed a bug, and has now been fixed for IDL 8.1. For an even number of points I decided to make the Nyquist frequency component be the first element - the documentation now states this explicitly. Thanks for tracking it down. Cheers, Chris ITTVIS
creator: chris_torrence@NOSPAM
date: 2011-02-15T20:25:31-00:00