Description Usage Arguments Value Author(s) References See Also Examples
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 pregrid, with
the pregrid
argument.
1 2 3  interpBarnes(x, y, z, w, xg, yg, xgl, ygl, xr, yr, gamma = 0.5,
iterations = 2, trim = 0, pregrid = FALSE,
debug = getOption("oceDebug"))

x, y 
a vector of x and ylocations. 
z 
a vector of z values, one at each (x,y) location. 
w 
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. 
xg, yg 
optional vectors defining the x and y grids. If not supplied,
these values are inferred from the data, using e.g. 
xgl, ygl 
optional lengths of the x and y grids, to be constructed with

xr, yr 
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. 
gamma 
gridfocussing parameter. At each iteration, 
iterations 
number of iterations. 
trim 
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

pregrid 
an indication of whether to pregrid the data. If

debug 
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 xgrid);
yg
, a vector holding the ygrid; zg
, a matrix holding the
gridded values; wg
, a matrix holding the weights used in the
interpolation at its final iteration; and zd
, a vector of the same
length as x
, which holds the interpolated values at the data points.
Dan Kelley
S. E. Koch and M. DesJardins and P. J. Kocin, 1983. “An interactive Barnes objective map anlaysis scheme for use with satellite and conventional data,” J. Climate Appl. Met., vol 22, p. 14871503.
See wind
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  library(oce)
# 1. contouring example, with windspeed 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)
mismatch < 100 * (wind$z  u$zd) / wind$z
text(wind$x, wind$y, round(mismatch), col="blue")
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. Onedimensional 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")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.