Commit 4ec7cb75 by agebhard

### add last changes from Martin Maechler

ready for release as 0.5-1
 ... ... @@ -56,7 +56,7 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40), \item{linear}{logical -- indicating wether linear or spline interpolation should be used. supersedes old \code{ncp} parameter} \item{ncp}{ deprecated, use parameter \code{linear}. Now only used by deprecated, use parameter \code{linear}. Now only used by \code{interp.old()}. meaning was: ... ... @@ -101,14 +101,15 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40), interpolation the old version is choosen, but spline interpolation is done by the new version. Earlier versions (pre 0.5-1) of \code{interp} used the parameter Earlier versions (pre 0.5-1) of \code{interp} used the parameter \code{ncp} to choose between linear and cubic interpolation, this is now done by setting the logical parameter \code{linear}. Use of \code{ncp} is still by setting the logical parameter \code{linear}. Use of \code{ncp} is still possible, but is deprecated. The resulting structure is suitable for input to the functions \code{contour} and \code{image}. Check the requirements of these functions when choosing values for \code{xo} and \code{yo}. functions \code{\link{contour}} and \code{\link{image}}. Check the requirements of these functions when choosing values for \code{xo} and \code{yo}. } \details{ If \code{linear} is \code{TRUE} (default), linear ... ... @@ -125,26 +126,23 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40), user defined function). The triangulation scheme used by \code{interp} works well if \code{x} and \code{y} have similar scales but will appear stretched if they have very different scales. The spreads of \code{x} and \code{y} must be within four orders of magnitude of each other for \code{interp} to work. and \code{y} have similar scales but will appear stretched if they have very different scales. The spreads of \code{x} and \code{y} must be within four orders of magnitude of each other for \code{interp} to work. } \references{ Akima, H. (1978). A Method of Bivariate Interpolation and Smooth Surface Fitting for Irregularly Distributed Data Points. ACM Transactions on Mathematical Software, \bold{4}, 148-164. ACM Transactions on Mathematical Software \bold{4}, 148-164. Akima, H. (1996). Algorithm 761: scattered-data surface fitting that has the accuracy of a cubic polynomial. ACM Transactions on Mathematical Software, \bold{22}, 362--371 ACM Transactions on Mathematical Software \bold{22}, 362--371. } \seealso{ \code{\link{contour}}, \code{\link{image}}, \code{\link{approx}}, \code{\link{spline}}, \code{\link{aspline}}, \code{\link{outer}}, \code{\link{expand.grid}}. } \examples{ ... ... @@ -162,8 +160,8 @@ points (akima, pch = 3) akima.smooth <- with(akima, interp(x, y, z, xo=seq(0,25, length=100), yo=seq(0,20, length=100))) image (akima.smooth) contour(akima.smooth, add=TRUE) image (akima.smooth, main = "interp(, *) on finer grid") contour(akima.smooth, add = TRUE, col = "thistle") points(akima, pch = 3, cex = 2, col = "blue") # use triangulation package to show underlying triangulation: if(library(tripack, logical.return=TRUE)) ... ... @@ -171,9 +169,9 @@ if(library(tripack, logical.return=TRUE)) # use only 15 points (interpolation only within convex hull!) akima.part <- with(akima, interp(x[1:15], y[1:15], z[1:15])) image (akima.part) image (akima.part, "interp() on subset of only 15 points") contour(akima.part, add=TRUE) points(akima$x[1:15],akima$y[1:15]) points(akima$x[1:15],akima$y[1:15], col = "blue") ## spline interpolation, two variants (AMS 526 "Old", AMS 761 "New") ## ----------------------------------------------------------------- ... ... @@ -184,7 +182,7 @@ table(is.na(akima.sO$z)) ## 3990 NA's; = 40 \% akima.sO <- with(akima, interp.old(x,y,z, xo=seq(0,25, length=100), yo=seq(0,20, len=100), ncp = 4)) sum(is.na(akima.sO$z)) ## still 3429 image (akima.sO) # almost useless image (akima.sO, main = "interp.old(*, ncp = 4) [almost useless]") contour(akima.sO, add = TRUE) ## "New:" ... ... @@ -195,7 +193,8 @@ akima.spl <- with(akima, interp(x,y,z, xo=seq(0,25, length=100), yo=seq(0,20, length=100), linear=FALSE)) contour(akima.spl) ; points(akima) contour(akima.spl, main = "smooth interp(*, linear = FALSE)") points(akima) full.pal <- function(n) hcl(h = seq(340, 20, length = n)) cool.pal <- function(n) hcl(h = seq(120, 0, length = n) + 150) ... ... @@ -203,6 +202,7 @@ warm.pal <- function(n) hcl(h = seq(120, 0, length = n) - 30) filled.contour(akima.spl, color.palette = full.pal, plot.axes = { axis(1); axis(2); title("smooth interp(*, linear = FALSE"); points(akima, pch = 3, col= hcl(c=100, l = 20))}) # no extrapolation! ... ...