;+ ; This procedure decimates a spectrum (i.e. thins the spectrum by ; selecting out every nth channel). The procedure still needs to be generalized ; by offering the option to choose a start channel. At present, it ; always starts at channel 0. Operates on the PDC (!g.s[0]) ; ; @param nchan {in}{optional}{type=integer} Thin the spectrum by one channel in every ; nchan channels. Default nchan=2. ; ; @examples ;
;    getrec,1
;    show
;    decimate,2
;    show
; 
; ; @version $Id: decimate.pro,v 1.8 2005/05/30 04:03:42 bgarwood Exp $ ;- pro decimate, nchan compile_opt idl2 len = data_valid(!g.s[0]) if (len le 0) then begin message,'Primary data container is empty, nothing to decimate',/info return endif if n_elements(nchan) eq 0 then nchan = 2 oldarr = *!g.s[0].data_ptr len = n_elements(oldarr) ; set the ref channel to channel 0 !g.s[0].reference_frequency = !g.s[0].reference_frequency - !g.s[0].frequency_interval*!g.s[0].reference_channel !g.s[0].reference_channel = 0 ; select every nth channel, starting at channel 0 decim = fltarr(len/nchan) inchans = seq(0,(len-1),nchan) outchans = lindgen(n_elements(inchans)) decim[outchans] = oldarr[inchans] *!g.s[0].data_ptr = decim !g.s[0].frequency_interval = !g.s[0].frequency_interval * float(nchan) if !g.frozen eq 0 then show end