I have a spectrum with flux on the Y-axis and wavelength on the X-axis. What I want to do is take the Fourier transform of this spectrum. Then add a random phase between 0 and 2pi to the phase only. Then take the inverse Fourier Transform of this. The piece of code I wrote in IDL for a simple example is below. I was hoping to scramble up the spectrum by doing this. But I am not sure if I have achieved that goal. I have two questions(adsbygoogle = window.adsbygoogle || []).push({});

1. The final spectrum ( for some random phases) are vertically offset from the original spectrum. Why is that so?

2. The amplitude of the final signal varies a lot from the original spectrum for some phases. I wasnt expecting that either. why is that?

3. All I want is that the components of the original spectrum be jumbled up in the X-direction (ie the wavelength direction). How can it be done?

MY CODE :

n = 257

x = FINDGEN(n)

y = COS(x*!PI/6)*EXP(-((x - n/2)/30)^2/2)+x/50.

tek_color

yfft = fft(y)

magnitude = abs(yfft)

angle = ph(yfft)

for count=0, 300 do begin

rand = randomu(seed, 1)*2*!pi

randph = replicate(rand, 256)

fft_signal = magnitude*exp(complex(0,1)*(angle+randph))

ifft_signal = (fft(fft_signal, /inverse))

wait, 0.2

plot, x, y

oplot, x, (ifft_signal), color=2

endfor

end

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# IDL help with FFT.PRO

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**