;+ ; NAME faverage.pro ; ; PURPOSE Averaging routine for an array of floating point numbers. ; ; SYNTAX faverage, nave, buf, nval ; nave = # elements to average. ; buf = floating point array. ; nval = number of elements in array buf. ; ; HISTORY Andrew L. Stanger HAO/NCAR ; C-language code faverage.c 4 Mar 1983 ; 30 Sep 2004 Converted from C to IDL. ;- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ PRO faverage, nave, buf, nval IF (nave .LE. 1) THEN RETURN navehalf = nave / 2 avebuf = buf ; --- Average over 'nave' points. FOR i = navehalf, nval - navehalf - 1 DO $ BEGIN sum = 0.0 FOR is = 0, nave-1 DO sum = sum + buf [i-navehalf+is] avebuf [i] = sum / nave; END buf = avebuf RETURN END