- Aug 15, 2006
- 375
- 1
- 81
I'm working with Intel's FFTW libraries and I have a few questions about phases.
First off, as a test example I'm taking the fft of a gaussian pulse. I've set it up so that the pulse is centered at x=5, with x ranging from 0 to 10.
I plot the initial pulse, so far so good, its the gaussian I expected.
Next, I take the fftw. Now I get the phase shifted version (since the dft presumes that the first array value is the origin).
Finally, I fft back and happily get my initial gaussian back (after dividing by n to normalize).
Now there are a couple of complications...
I wrote a function to shift the data back to the center after a fft, this means that when I do the forward transform and plot the results, I get a gaussian again instead of the phase shifted one. (In practice this means I take the second half of the array and set it to the beginning of the array, there are complications if the array is odd or even). Anyone have suggestions for how to write a good shifting routine that is symmetric for odd data?
So far so good, now I get a nice gaussian for all three plots and when I actually go to put this in my code I can work on the transformed data.
Now here is the problem, if the pulse is not centered, say its at x=3. When I forward transform I get the usual, then I backwards transform the pulse is now centered at x = 8! (Same thing happens if I shift in between the forward and backward transforms)
Anyone have any advice on how to take the fft so that I can take the forward transform, do some work, then take the backwards transform and not have to deal with phases messing things up?
First off, as a test example I'm taking the fft of a gaussian pulse. I've set it up so that the pulse is centered at x=5, with x ranging from 0 to 10.
I plot the initial pulse, so far so good, its the gaussian I expected.
Next, I take the fftw. Now I get the phase shifted version (since the dft presumes that the first array value is the origin).
Finally, I fft back and happily get my initial gaussian back (after dividing by n to normalize).
Now there are a couple of complications...
I wrote a function to shift the data back to the center after a fft, this means that when I do the forward transform and plot the results, I get a gaussian again instead of the phase shifted one. (In practice this means I take the second half of the array and set it to the beginning of the array, there are complications if the array is odd or even). Anyone have suggestions for how to write a good shifting routine that is symmetric for odd data?
So far so good, now I get a nice gaussian for all three plots and when I actually go to put this in my code I can work on the transformed data.
Now here is the problem, if the pulse is not centered, say its at x=3. When I forward transform I get the usual, then I backwards transform the pulse is now centered at x = 8! (Same thing happens if I shift in between the forward and backward transforms)
Anyone have any advice on how to take the fft so that I can take the forward transform, do some work, then take the backwards transform and not have to deal with phases messing things up?