boxAverage

Calcuates the box average. Commonly used for creating seasonal averages. Note: function should only be used with continuous data domain (see example below).

var grid interval minfrac boxAverage

Arguments
labeltypedescription
var variable variable to be averaged
grid grid grid(s) over which the box average is to be calculated
interval number width of interval (in units of grid).
minfrac number Minimum fraction of data that must be present (i.e., fraction not indicated as missing) within the selected domain in order for the box average to be calculated. If minfrac is not present, then a missing value is returned. If minfrac is not given, then the box average is calculated regardless of the amount of data present in domain. (optional)
Returns
avgvar variable box average of var, where the non-overlapping intervals are of length interval

Description

For the latest variable on the stack, boxAverage calculates non-overlapping, unweighted averages over windows of length interval over the specified grid, starting with the first point in the grid. No average is calculated for any incomplete interval at the end of the grid. interval is in the units of the grid being averaged over. The optional argument minfrac has a default value of 0. Note that the units of the grid itself in the result are not changed, only the spacing and number of calculated values assigned to the grid.

Example

SOURCES .IRI .EPPF .environment .thermocline_depth
T (Jan 1950) (Nov 1998) RANGE
T 3 1. boxAverage


In this example boxAverage calculates 3-month, non-overlapping averages over the time (T) grid of the thermocline_depth variable, starting with January 1950. With a minfrac of 1.0, 3-month averages will be returned for only for those intervals with three months of non-missing data. Three-month averages are returned for January-March 1950, April-June 1950, ..., July-September 1998. Because the final interval in the time grid is incomplete (October-November 1998), no average is returned for it.

Live Example Link

Note: This function should NOT be used with a discontinuous domain like the T grid shown below:

SOURCES .IRI .EPPF .environment .thermocline_depth
T (Jan-Mar 1950-1998) VALUES
T 3 boxAverage


See also

Average: average dekadalAverage monthlyAverage pentadAverage runningAverage seasonalAverage weighted-average yearlyAverage
Smoothing Data: runningAverage SM121