pro box_car,dat,npts,dat_av,dat_sd,dat_sdom ;-------------------------------------------------------------- ; smooth a series of data over +/- npts points, compute ; the mean and the standard deviation. ; ; Input: ; dat.........the data to be smoothed, must be a series (vector) ; npts........smooth over +/- npts, the total # of points in the stats will be npts*2+1 ; ; Output: ; dat_av......averages ; dat_sd......standard deviation ; dat_sdom....standard deviation of the mean (Std. Dev. / sqrt(n)) ; ; source: Mark Hervig, GATS Inc. ;-------------------------------------------------------------- nrec = n_elements(dat) npts = long(npts) dat_av = dat ;* 0. dat_sd = dat * 0. dat_sdom = dat * 0. for i = 0L+npts,nrec-1L-npts do begin dat_av(i) = mean( dat(i-npts:i+npts)) dat_sd(i) = stddev( dat(i-npts:i+npts)) dat_sdom(i) = stddev( dat(i-npts:i+npts)) / sqrt(2*npts) endfor return end