The algorithm follows that described by Koch et al. (1983), with the
addition of the ability to blank out the grid in spots where data are
sparse, using the
trim argument, and the ability to pre-grid, with
interpBarnes( x, y, z, w, xg, yg, xgl, ygl, xr, yr, gamma = 0.5, iterations = 2, trim = 0, pregrid = FALSE, debug = getOption("oceDebug") )
a vector of x and ylocations.
a vector of z values, one at each (x,y) location.
a optional vector of weights at the (x,y) location. If not
supplied, then a weight of 1 is used for each point, which means equal
weighting. Higher weights give data points more influence. If
optional vectors defining the x and y grids. If not supplied,
these values are inferred from the data, using e.g.
optional lengths of the x and y grids, to be constructed with
optional values defining the width of the radius ellipse in the x and y directions. If not supplied, these are calculated as the span of x and y over the square root of the number of data.
grid-focussing parameter. At each iteration,
number of iterations.
a number between 0 and 1, indicating the quantile of data weight
to be used as a criterion for blanking out the gridded value (using
an indication of whether to pre-grid the data. If
a flag that turns on debugging. Set to 0 for no debugging information, to 1 for more, etc; the value is reduced by 1 for each descendent function call.
A list containing:
xg, a vector holding the x-grid);
yg, a vector holding the y-grid;
zg, a matrix holding the
wg, a matrix holding the weights used in the
interpolation at its final iteration; and
zd, a vector of the same
x, which holds the interpolated values at the data points.
S. E. Koch and M. DesJardins and P. J. Kocin, 1983. ``An interactive Barnes objective map analysis scheme for use with satellite and conventional data,'' J. Climate Appl. Met., vol 22, p. 1487-1503.
library(oce) # 1. contouring example, with wind-speed data from Koch et al. (1983) data(wind) u <- interpBarnes(wind$x, wind$y, wind$z) contour(u$xg, u$yg, u$zg, labcex=1)text(wind$x, wind$y, wind$z, cex=0.7, col="blue")title("Numbers are the data")# 2. As 1, but blank out spots where data are sparse u <- interpBarnes(wind$x, wind$y, wind$z, trim=0.1) contour(u$xg, u$yg, u$zg, level=seq(0, 30, 1))points(wind$x, wind$y, cex=1.5, pch=20, col="blue")# 3. As 1, but interpolate back to points, and display the percent mismatch u <- interpBarnes(wind$x, wind$y, wind$z) contour(u$xg, u$yg, u$zg, labcex=1)title("Numbers are percent mismatch between grid and data")# 4. As 3, but contour the mismatch mismatchGrid <- interpBarnes(wind$x, wind$y, mismatch) contour(mismatchGrid$xg, mismatchGrid$yg, mismatchGrid$zg, labcex=1)# 5. One-dimensional example, smoothing a salinity profile data(ctd) p <- ctd[["pressure"]] y <- rep(1, length(p)) # fake y data, with arbitrary value S <- ctd[["salinity"]] pg <- pretty(p, n=100) g <- interpBarnes(p, y, S, xg=pg, xr=1) plot(S, p, cex=0.5, col="blue", ylim=rev(range(p)))lines(g$zg, g$xg, col="red")