;PURPOSE: ; The purpose of this script is to show the effect of sampling a function ; on its fft pro fft_sample_region !p.multi=[0,2,2] ;Set up Quantitities necessary for FFT and real signal DeltaX=1. ;Spacing in the Time Domain (sec) or Spatial Domain (m) Period1=10. ;Period of First Signal Period2=22. ;Period of Second Signal Strength1=20. ;Strength of First Signal Strength2=80. ;Strength of Second Signal SignalN=1000. ;Number of Sample Points SignalLength=SignalN*DeltaX ;Total Length in Time (or Space) FreqSpacing=1/(SignalLength) ;In Frequency Domain, Spacing is 1/Length KMax1=SignalN/2 ;The index of the Frequency Split (Positive/Negative) ;Here is the Signal x=DeltaX*findgen(SignalN) y1=Strength1*sin((2*!pi/Period1)*x)+Strength2*cos((2*!pi/Period2)*x) plot,x,y1 FreqSpacing1=1/(SignalLength) Kvals1=FreqSpacing1*(-KMax1+findgen(SignalN)) FftY1=fft(y1) plot,KVals1,abs(shift(ffty1,KMax1))^2 ;Now Sample the function and see what we get Sample=y2 SampleSignalN=N_elements(y1)/2 SampleSignalLength=SampleSignalN*DeltaX FreqSpacing2=1/(SampleSignalLength) KMax2=SampleSignalN/2 Kvals2=FreqSpacing2*(-KMax2+findgen(SampleSignalN)) ;Here is the sampled signal x=DeltaX*findgen(SampleSignalN) y2=y1(0:SampleSignalN) plot,x,y2 FftY2=fft(Y2) plot,KVals2,abs(shift(ffty2,KMax2))^2 end