;+ ; Do an FFT or an inverse FFT on the data container(s) indicated by ; the arguments. This always overwrites the data array in those data ; containers with the result. ; ;
In the case of the forward FFT (the ; default), if an index for the imaginary part is omitted, it is ; assumed that the input array is a pure real array (the imaginary ; part is all 0) and any data at the imag_index location is ignored on ; input (and overwritten on output). ; ;
The units of the x-axis and the ; data are not changed here. The user needs to keep track of the ; state of their data containers. If a non-zero bdrop or edrop are ; used, the resulting data containers will be shortened by that many ; elements using dcextract. ; Consequently, it may ; not be appropriate to use the same bdrop and edrop on an inverse FFT ; as it was when the FFT was first done. ; ;
See the discussion in dcfft on ; how inverse is used for spectral-line data vs continuum data. For ; spectral-line data, an FFT is a transformation from frequency to ; time and an inverse FFT is a transformation in the other direction. ; For continuum data, an FFT is a transformation from time to ; frequency and an inverse FFT is a transformation in the other direction. ; ; @param real_index {in}{out}{optional}{type=integer}{default=0} The index ; from which the real values going in to the FFT are obtained. The ; real values from the result are overwritten to this location. ; ; @param imag_index {in}{out}{optional}{type=integer}{default=1} The index ; from which the imaginary values going in to the FFT are obtained. The ; imaginary values from the result are overwritten to this location. ; If this parameter is omitted on the forward transformation (inverse ; is not set) then the input values are assumed to be all real (the ; imaginary part is all 0) and any data at this location is ignored ; and overwritten on output. ; ; @keyword inverse {in}{optional}{type=boolean} When set, the inverse ; FFT is performed as described above. ; ; @keyword bdrop {in}{optional}{type=integer}{default=0} The number of ; channels to exclude from the FFT at the beginning. ; ; @keyword edrop {in}{optional}{type=integer}{default=0} The number of ; channels to exclude from the FFT at the end. ; ; @uses dcfft ; @uses dcextract ; ; @version $Id: gfft.pro,v 1.1 2005/04/20 21:18:41 bgarwood Exp $ ;- pro gfft,real_index,imag_index,inverse=inverse,bdrop=bdrop,edrop=edrop compile_opt idl2 pureReal = 1 if (n_elements(real_index) eq 0) then real_index = 0 if (n_elements(imag_index) eq 0) then begin imag_index = 1 if (keyword_set(inverse)) then pureReal = 0 endif else begin pureReal = 0 endelse if (!g.line) then begin if (real_index gt n_elements(!g.s) or real_index lt 0) then begin message, string((n_elements(!g.s)-1),format='("real_index must be >= 0 and <= ",i2)'),/info return endif if (imag_index gt n_elements(!g.s) or imag_index lt 0) then begin message, string((n_elements(!g.s)-1),format='("imag_index must be >= 0 and <= ",i2)'),/info return endif ; real_index must have valid data nin = data_valid(!g.s[real_index]) if nin le 0 then begin message,string(real_index,format='("No valid data seen at index ",i2)'),/info return endif if pureReal then begin data = dcfft(!g.s[real_index],inverse=inverse,bdrop=bdrop,edrop=edrop) endif else begin nout = data_valid(!g.s[imag_index]) if nout le 0 then begin message,string(imag_index,format='("No valid data seen at index ",i2)'),/info return endif if nout ne nin then begin message,'Size of data in real_index and imag_index are not the same',/info return endif data = dcfft(!g.s[real_index],!g.s[imag_index],inverse=inverse,bdrop=bdrop,edrop=edrop) endelse ; if data is not complex, a problem occured, dcfft will have emitted the ; error, just return here if size(data,/type) ne 6 then return ; dcfft will set bdrop and edrop if not set by here if bdrop ne 0 or edrop ne 0 then begin newdc = dcextract(!g.s[real_index],bdrop,(nin-edrop-1)) set_data_container,newdc,index=real_index,/noshow data_free,newdc endif copy,real_index,imag_index setdata,real_part(data),index=real_index setdata,imaginary(data),index=imag_index endif else begin if (real_index gt n_elements(!g.c) or real_index lt 0) then begin message, string((n_elements(!g.c)-1),format='("real_index must be >= 0 and <= ",i2)'),/info return endif if (imag_index gt n_elements(!g.c) or imag_index lt 0) then begin message, string((n_elements(!g.c)-1),format='("imag_index must be >= 0 and <= ",i2)'),/info return endif ; real_index must have valid data nin = data_valid(!g.c[real_index]) if nin le 0 then begin message,string(real_index,format='("No valid data seen at index ",i2)'),/info return endif if pureReal then begin data = dcfft(!g.c[real_index],inverse=inverse,bdrop=bdrop,edrop=edrop) endif else begin nout = data_valid(!g.c[imag_index]) if nout le 0 then begin message,string(imag_index,format='("No valid data seen at index ",i2)'),/info return endif if nout ne nin then begin message,'Size of data in real_index and imag_index are not the same',/info return endif data = dcfft(!g.c[real_index],!g.c[imag_index],inverse=inverse,bdrop=bdrop,edrop=edrop) endelse ; if data is not complex, a problem occured, dcfft will have emitted the ; error, just return here if size(data,/type) ne 6 then return ; dcfft will set bdrop and edrop if not set by here if bdrop ne 0 or edrop ne 0 then begin newdc = dcextract(!g.c[real_index],bdrop,(nin-edrop-1)) set_data_container,newdc,index=real_index,/noshow data_free,newdc endif copy,real_index,imag_index setdata,real_part(data),index=real_index setdata,imaginary(data),index=imag_index endelse end