Commit bd80a8b1 authored by agebhard's avatar agebhard
Browse files

adopt man pages for ncp->linear change

parent 5019f80c
Package: akima Package: akima
Version: 0.4-5 Version: 0.5-1
Date: 2005-07-21 Date: 2006-02-01
Title: Interpolation of irregularly spaced data Title: Interpolation of irregularly spaced data
Author: Fortran code by H. Akima Author: Fortran code by H. Akima
R port by Albrecht Gebhardt <albrecht.gebhardt@uni-klu.ac.at> R port by Albrecht Gebhardt <albrecht.gebhardt@uni-klu.ac.at>
......
...@@ -50,7 +50,7 @@ rgl.points(akima.p$x,akima.p$z , akima.p$y,size=4,color="yellow") ...@@ -50,7 +50,7 @@ rgl.points(akima.p$x,akima.p$z , akima.p$y,size=4,color="yellow")
# data # data
rgl.spheres(akima$x,akima$z , akima$y,0.5,color="red") rgl.spheres(akima$x,akima$z , akima$y,0.5,color="red")
rgl.bbox() rgl.bbox()
# bivariate linear interpolation # bivariate cubic spline interpolation
# interp: # interp:
akima.si <- interp(akima$x, akima$y, akima$z, akima.si <- interp(akima$x, akima$y, akima$z,
xo=seq(min(akima$x), max(akima$x), length = 100), xo=seq(min(akima$x), max(akima$x), length = 100),
......
...@@ -56,14 +56,15 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40), ...@@ -56,14 +56,15 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40),
\item{linear}{logical -- indicating wether linear or spline \item{linear}{logical -- indicating wether linear or spline
interpolation should be used. supersedes old \code{ncp} parameter} interpolation should be used. supersedes old \code{ncp} parameter}
\item{ncp}{ \item{ncp}{
deprecated, use parameter \code{linear}. deprecated, use parameter \code{linear}. Now only used by
\code{interp.old()}.
meaning was: meaning was:
number of additional points to be used in computing partial number of additional points to be used in computing partial
derivatives at each data point. derivatives at each data point.
\code{ncp} must be either \code{0} (partial derivatives are not used), or at \code{ncp} must be either \code{0} (partial derivatives are not used), or at
least 2 but smaller than the number of data points (and smaller than least 2 but smaller than the number of data points (and smaller than
25). This option is only supported by \code{interp.old}. 25).
} }
\item{extrap}{ \item{extrap}{
logical flag: should extrapolation be used outside of the logical flag: should extrapolation be used outside of the
...@@ -100,20 +101,22 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40), ...@@ -100,20 +101,22 @@ interp.new(x, y, z, xo = seq(min(x), max(x), length = 40),
interpolation the old version is choosen, but spline interpolation is interpolation the old version is choosen, but spline interpolation is
done by the new version. done by the new version.
At the moment \code{interp.new} ignores \code{ncp} and does only Earlier versions (pre 0.5-1) of \code{interp} used the parameter
bicubic spline interpolation. \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
possible, but is deprecated.
The resulting structure is suitable for input to the The resulting structure is suitable for input to the
functions \code{contour} and \code{image}. Check the requirements of functions \code{contour} and \code{image}. Check the requirements of
these functions when choosing values for \code{xo} and \code{yo}. these functions when choosing values for \code{xo} and \code{yo}.
} }
\details{ \details{
If \code{ncp} is zero, linear If \code{linear} is \code{TRUE} (default), linear
interpolation is used in the triangles bounded by data points. interpolation is used in the triangles bounded by data points.
Cubic interpolation is done if partial derivatives are used. Cubic interpolation is done if \code{linear} is set to \code{FALSE}.
If \code{extrap} is \code{FALSE}, z-values for points outside the If \code{extrap} is \code{FALSE}, z-values for points outside the
convex hull are returned as \code{NA}. convex hull are returned as \code{NA}.
No extrapolation can be performed if \code{ncp} is zero. No extrapolation can be performed for the linear case.
The \code{interp} function handles duplicate \code{(x,y)} points The \code{interp} function handles duplicate \code{(x,y)} points
in different ways. As default it will stop with an error message. But in different ways. As default it will stop with an error message. But
...@@ -172,8 +175,8 @@ image (akima.part) ...@@ -172,8 +175,8 @@ image (akima.part)
contour(akima.part, add=TRUE) contour(akima.part, add=TRUE)
points(akima$x[1:15],akima$y[1:15]) points(akima$x[1:15],akima$y[1:15])
## spline interpolation ## spline interpolation, two variants (AMS 526 "Old", AMS 761 "New")
## -------------------- ## -----------------------------------------------------------------
## "Old": use 5 points to calculate derivatives -> many NAs ## "Old": use 5 points to calculate derivatives -> many NAs
akima.sO <- interp.old(akima$x, akima$y, akima$z, akima.sO <- interp.old(akima$x, akima$y, akima$z,
xo=seq(0,25, length=100), yo=seq(0,20, length=100), ncp=5) xo=seq(0,25, length=100), yo=seq(0,20, length=100), ncp=5)
...@@ -187,6 +190,11 @@ contour(akima.sO, add = TRUE) ...@@ -187,6 +190,11 @@ contour(akima.sO, add = TRUE)
## "New:" ## "New:"
akima.spl <- with(akima, interp.new(x,y,z, xo=seq(0,25, length=100), akima.spl <- with(akima, interp.new(x,y,z, xo=seq(0,25, length=100),
yo=seq(0,20, length=100))) yo=seq(0,20, length=100)))
## equivalent call via setting linear=FALSE in interp():
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) ; points(akima)
full.pal <- function(n) hcl(h = seq(340, 20, length = n)) full.pal <- function(n) hcl(h = seq(340, 20, length = n))
...@@ -204,9 +212,10 @@ data(airquality) ...@@ -204,9 +212,10 @@ data(airquality)
air <- subset(airquality, air <- subset(airquality,
!is.na(Temp) & !is.na(Ozone) & !is.na(Solar.R)) !is.na(Temp) & !is.na(Ozone) & !is.na(Solar.R))
# gives an error {duplicate ..}: # gives an error {duplicate ..}:
try( air.ip <- interp.new(air$Temp,air$Solar.R,air$Ozone) ) try( air.ip <- interp(air$Temp,air$Solar.R,air$Ozone, linear=FALSE) )
# use mean of duplicate points: # use mean of duplicate points:
air.ip <- with(air, interp.new(Temp, Solar.R, log(Ozone), duplicate = "mean")) air.ip <- with(air, interp(Temp, Solar.R, log(Ozone), duplicate = "mean",
linear = FALSE))
image(air.ip, main = "Airquality: Ozone vs. Temp and Solar.R") image(air.ip, main = "Airquality: Ozone vs. Temp and Solar.R")
with(air, points(Temp, Solar.R)) with(air, points(Temp, Solar.R))
} }
......
...@@ -37,7 +37,8 @@ dupfun = NULL, ncp) ...@@ -37,7 +37,8 @@ dupfun = NULL, ncp)
\item{linear}{logical -- indicating wether linear or spline \item{linear}{logical -- indicating wether linear or spline
interpolation should be used. supersedes old \code{ncp} parameter} interpolation should be used. supersedes old \code{ncp} parameter}
\item{ncp}{ \item{ncp}{
deprecated, use parameter \code{linear}. deprecated, use parameter \code{linear}. Now only used by
\code{interpp.old()}.
meaning was: meaning was:
number of additional points to be used in computing partial number of additional points to be used in computing partial
...@@ -79,10 +80,15 @@ dupfun = NULL, ncp) ...@@ -79,10 +80,15 @@ dupfun = NULL, ncp)
Use \code{interp} if interpolation on a regular grid is wanted. Use \code{interp} if interpolation on a regular grid is wanted.
The two versions \code{interpp.old} and \code{interpp.new} refer to The two versions \code{interpp.old} and \code{interpp.new} refer to
Akimas Fortran code from 1978 and 1996 resp. At the moment Akimas Fortran code from 1978 and 1996 resp. The call wrapper \code{interpp}
\code{interpp.new} chooses \code{interpp.old} for linear and \code{interpp.new} for cubic
does not work porperly (it results in a segmentation fault), so it is spline interpolation.
not used from the call wrapper \code{interp}.
Earlier versions (pre 0.5-1) of \code{interpp} 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
possible, but is deprecated.
} }
\description{ \description{
If \code{ncp} is zero, linear If \code{ncp} is zero, linear
...@@ -122,8 +128,8 @@ data(akima) ...@@ -122,8 +128,8 @@ data(akima)
akima.lip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12)) akima.lip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12))
akima.lip$z akima.lip$z
# spline interpolation # spline interpolation
akima.lip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12), akima.sip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12),
linear=FALSE) linear=FALSE)
akima.lip$z akima.sip$z
} }
\keyword{dplot} \keyword{dplot}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment