IDL 5.5, 2D FFT indexing confusion. [message #44831] |
Tue, 19 July 2005 04:23  |
Pitufa
Messages: 8 Registered: July 2005
|
Junior Member |
|
|
Hi,
I have been trying to generate an real even function in fourier space
that I can INVERSE FFT in order to get a function which has no
imaginary part. I have no problems when the function is a vector, but I
get an imaginary part when it is a two dimensional array.
Below is the test program that shows my problem. Am I defining wrong
the variables 'centre' or 'nshift'?
I would be really grateful if someone could let me know what I am doing
wrong.
Thanks!
Pitufa.
pro test_index
npix = 100
centre = npix/2.d - 1.d
nshift = npix/2 + 1
;1d example:
f = abs(findgen(npix) - centre)
ifft = fft(shift(f,nshift),1,/double)
print,'1D: Imaginary maximum:', Max(Abs(Imaginary(ifft)))
print,'1D: Real maximum :', Max(Abs(Double(ifft)))
;2d example:
;angle of position vector w.r.t x axis:
phi = dblarr(NPIX,NPIX)
FOR X = 0, NPIX-1 DO FOR Y = 0, NPIX-1 DO $
PHI[X,Y] = ATAN(Y*1.D - centre,X*1.D - centre)
TEST = sin(2.d*phi)
IFFTTEST = FFT(SHIFT(TEST,nshift,nshift),1,/DOUBLE)
print,'2D: Imaginary maximum: ', $
MAX(ABS(imaginary(IFFTTEST))),mean(ABS(imaginary(IFFTTEST)))
print,'2D: Real maximum : ',MAX(ABS(double(IFFTTEST)))
end
|
|
|