bin_avg
Calculates gridded binned averages and counts using randomly spaced data.
Available in version 5.1.0 or later.
Prototype
function bin_avg ( zlon [*] : numeric , zlat [*] : numeric , z [*] : numeric , glon [*] : numeric , glat [*] : numeric , opt [1] : logical )
Arguments
zlonLongitudes of the observations (z).
zlatLatitudes of the observations (z).
zObservation values.
glonLongitudes of the output grid. These must be equally spaced.
glatLatitudes of the output grid. These must be equally spaced but may have different spacing than used for glon.
optOption. Currently not used. Set to False.
Return value
A grid of the size defined by glon and glat. The grid spacing must be equally spaced: eg: 1x1, 2x4, etc. The output array will be of type double if any of the input is double, and of type float otherwise.
Description
This function averages values z contained within the rectilinear array defined by the input grid glon, glat. This takes advantage of the fact the latitude and longitude grid spacing is required to be constant. As noted in the argument description, the spacing in the latitude and longitude directions need not be equal. The appropriate grid point subscripts are determined via a simple algorithm.
See Also
bin_sum,
triple2grid,
triple2grid2d,
poisson_grid_fill
Examples
Example 1
Assume zlon, zlat and zVal are one-dimensional (1D) arrays. Let lon and lat be 1D arrays of length M and N which specify grid locations. Then:
grid = bin_avg(zlon,zlat,zVal, lon,lat, False)will return a 2-dimensional array of size NxM. Sometimes there are gaps in the returned array. If none are desired, then one approach would be to use poisson_grid_fill.