;+ ; Compute the power spectrum for the indicated data container, which ; is overwritten with the result. Uses ; dcfft to do the fft. This is simply ; the sum of squares of the real and imaginary parts of the fft on the ; data. ; ;

Use to get the power ; spectrum for a non-global data container. ; ; @param index {in}{out}{optional}{type=integer}{default=0} The data ; container to use for both input and output. ; ; @uses dcfft ; ; @version $Id: powspec.pro,v 1.1 2005/04/22 18:44:25 bgarwood Exp $ ;- pro powspec,index compile_opt idl2 if n_elements(index) eq 0 then index=0 if !g.line then begin if index lt 0 or index ge n_elements(!g.s) then begin message, string(n_elements(!g.s),format='("index must be between 0 and ",i2)'),/info return endif if data_valid(!g.s[index]) le 0 then begin message, 'No valid data found at index',/info return endif f = dcfft(!g.s[index]) setdata,real_part(f)^2 + imaginary(f)^2,index=index endif else begin if index lt 0 or index ge n_elements(!g.c) then begin message, string(n_elements(!g.c),format='("index must be between 0 and ",i2)'),/info return endif if data_valid(!g.c[index]) le 0 then begin message, 'No valid data found at index',/info return endif f = dcfft(!g.c[index]) setdata,real_part(f)^2 + imaginary(f)^2,index=index endelse if index eq 0 and not !g.frozen then chan & show end