runave

Calculate an unweighted running average. Missing values are allowed.

Note: This function is only available in version 4.1.1 of NCL. If your site is licensed for version 4.1, then you can get version 4.1.1 for free. To get version 4.1.1 of NCAR Graphics software, please contact your site representative. If you don't know who your site representative is, then send email to ncarginf@ucar.edu or call (303) 497-1201.


Synopsis

    function runave(
        x    : float,
        nave : float,
        kopt : integer
    )

Arguments

x
An array with one or more dimensions. The rightmost dimension will be the dimension on which the unweighted running average is performed. Missing values should be indicated by x@_FillValue. If x@_FillValue is not set, then the NCL default (-999) will be assumed.
nave
Number of points to be included in the running average.
kopt
End-point option (kopt = 0 is the most frequently used)

In the following, N=last point in the series:

kopt < 0 : utilize cyclic conditions             
           e.g.,  nave=3 
           x(0) = (x(N)  +x(0)+x(1))/nave
           x(N) = (x(N-1)+x(N)+x(0))/nave
           e.g.,  nave=4 at n=1 and n=N     
           x(0) = (x(N-1)+x(N)  +x(0)+x(1))/nave
           x(N) = (x(N-2)+x(N-1)+x(N)+x(0))/nave

kopt = 0 : set unsmoothed beginning and end pts to x@_FillValue [most common]
           e.g.,  nave=3 , x(0) = (x@_FillValue and x(N) = (x@_FillValue    
                         , x(1) = (x(0)+x(1)+x(2))/nave
           e.g.,  nave=4 , x(0),x(1),x(N-1) and x(N) = (x@_FillValue 
                         , x(2) = (x(0)+x(1)+x(2)+x(3))/nave

kopt > 0 : utilize reflective (symmetric) conditions
           e.g.,  nave=3 
           x(0) = (x(1)  +x(0)+x(1))/nave
           x(N) = (x(N-1)+x(N)+x(N-1))/nave
           e.g.,  nave=4 
           x(0) = (x(2)  +x(1)  +x(0)+x(1))/nave
           x(N) = (x(N-2)+x(N-1)+x(N)+x(N-1))/nave

Description

runave returns a float array of the same dimensionality as x with the last dimension smoothed. The running average is a special case of a filter where all weights are the same. The filter is applied to the i-th time of the requested series as follows:
F(i) = SUM{UF(i-(nave/2)+j-1)}/nave from j=0,nave-1
where F is the filtered field, UF is the unfiltered field, and nave is the number of elements in the running average.

If the number of weights is even, the filter's center falls between series elements; in this case, the center is shifted one-half of a time increment towards the latter element.


Example 1

Let x be dimensioned nlat x mlon x ktimes (nlat=64, mlon=128, ktimes=1000). Perform a 3 point running average and use kopt=0. Return the smoothed value to the original x array:

  x = runave (x,3,0)

Example 2

Let x be dimensioned ntimes x nlat x mlon with named dimensions "time" , "lat" , "lon". Then:
    nave = 31
    kopt = 0
    y    = runave (x(lat|:,lon|:,time|:), nave, kopt)
y will be a 3-dimensional array of length nlat x mlon x time.

Example 3

Let x be dimensioned ntimes x klev x nlat x mlon with named dimensions. Perform a 5 point running average use the cyclic option in the longitude direction:

    nave = 5
    kopt = -1
    x = runave (x,nave, kopt)  ; return the series in the original array

Reference Manual Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?


$Revision: 1.4 $ $Date: 1999/03/22 20:49:10 $