IDL Help: FFT.PRO for Scrambling Spectral Components in X-Direction

  • Thread starter astrogirl123
  • Start date
In summary, FFT.PRO is a built-in function in IDL that calculates the discrete Fourier transform of a sequence or data set, allowing for the analysis of frequency components. To use it, you must first load the function into your IDL session and then pass in the data array you want to analyze. You can also specify the size of the FFT for optimal performance. While FFT.PRO is optimized for speed and efficiency, it may have limitations when it comes to non-stationary signals or data sets with missing values. Additionally, the accuracy of the results can be affected by noise or errors in the data.
  • #1
astrogirl123
4
0
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

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 news on Phys.org
  • #2


1. The vertical offset in the final spectrum is likely due to the random phase added to the original signal. When you add a random phase, you are essentially shifting the entire spectrum up or down in the y-axis, resulting in a vertical offset in the final spectrum.

2. The amplitude of the final signal varies because the random phase is affecting the magnitude of the original signal. Depending on the value of the random phase, the resulting amplitude can be higher or lower than the original signal.

3. If you want to only jumble up the components of the original spectrum in the x-direction, you can try taking the Fourier transform of the original spectrum, adding a random phase to the phase only, and then taking the inverse Fourier transform along the y-axis only. This will preserve the original spectrum in the x-direction while scrambling it in the y-direction. Alternatively, you can try using a different method, such as shuffling the data points in the x-direction, to achieve your desired result.
 

Related to IDL Help: FFT.PRO for Scrambling Spectral Components in X-Direction

1. What is FFT.PRO in IDL?

FFT.PRO is a built-in function in IDL that performs a Fast Fourier Transform (FFT) on a given array of data. It calculates the discrete Fourier transform of a sequence or data set, which is a mathematical technique used to analyze the frequency components of a signal or data.

2. How do I use FFT.PRO in IDL?

To use FFT.PRO in IDL, you will need to first load the function into your IDL session by typing "FFT.PRO" at the command line. Then, you can pass in the data array you want to analyze as an argument to the function. The output will be the FFT of the data, which you can then use for further analysis or plotting.

3. Can I specify the size of the FFT in FFT.PRO?

Yes, you can specify the size of the FFT in FFT.PRO by passing in a second argument that specifies the size of the output array. This size should be a power of 2 for optimal performance.

4. What is the difference between FFT and FFT.PRO in IDL?

FFT.PRO is a specific implementation of the FFT algorithm in IDL, while FFT is a more general function that allows for more flexibility in terms of data types and sizes. FFT.PRO is optimized for speed and efficiency, making it a better choice for large data sets or real-time analysis.

5. Are there any limitations to using FFT.PRO in IDL?

While FFT.PRO is a powerful tool for analyzing frequency components of data, it does have some limitations. For example, it may not be suitable for non-stationary signals or data sets with missing values. Additionally, the accuracy of the FFT results can be affected by the presence of noise or errors in the data.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Astronomy and Astrophysics
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
764
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
1
Views
850
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
26
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top