This method returns the result of interpolating spectral data from the original set of wavelengths to a new one.
interpolate_wl(x, w.length.out, fill, length.out, method, ...)# S3 method for default
interpolate_wl(x, w.length.out, fill, length.out, method, ...)
# S3 method for generic_spct
interpolate_wl(
x,
w.length.out = NULL,
fill = NA,
length.out = NULL,
method = "approx",
...
)
# S3 method for generic_mspct
interpolate_wl(
x,
w.length.out = NULL,
fill = NA,
length.out = NULL,
method = "approx",
...,
.parallel = FALSE,
.paropts = NULL
)
A new spectral object or collection of spectral objects, of the same
class as argument x
. Each spectrum returned with more or fewer rows
than in x
, the requested new w.length
values and new numeric
values for spectral quantities, obtained by interpolation.
an R object
numeric vector of wavelengths (nm).
a numeric value to be assigned to out of range wavelengths.
integer Length of the wavelength vector in the returned
value. Overrides w.length.out
is not NULL
, respects its
range but overrides the actual values.
character string One of "auto"
, "approx"
,
"spline"
, "skip"
.
additional arguments passed to spline()
.
if TRUE, apply function in parallel, using parallel backend provided by foreach
a list of additional options passed into the foreach function when parallel computation is enabled. This is important if (for example) your code relies on external data or packages: use the .export and .packages arguments to supply them so that all cluster nodes have the correct environment set up for computing.
interpolate_wl(default)
: Default for generic function
interpolate_wl(generic_spct)
: Interpolate wavelength in an object of class
"generic_spct" or derived.
interpolate_wl(generic_mspct)
: Interpolate wavelength in an object of class
"generic_mspct" or derived.
Depending on method
natural spline interpolation or linear
interpolation are used. With method = spline
a call to
spline
with method = "natural"
is
used and with method = "approx"
a call to
approx
is used. If method = "auto"
or
method = NULL
when 100 or fewer distinct wavelengths are available
as input and/or the maximum wavelength step size in w.length.in
is
more than three times the minimum wavelength step size in
w.length.out
"spline"
is used and "approx"
otherwise.
Finally, with method = "skip"
the input is returned unchanged.
If w.length.out
is a numeric vector and length.out = NULL
, it
directly gives the target wavelengths for interpolation. If it is
NULL
, and length.out
is an integer value evenly spaced
wavelength values covering the same wavelength range as in the input are
generated. If w.length.out
is a numeric vector and length.out
is an integer value, length.out
evenly spaced wavelengths covering
the wavelength range of w.length.out
are generated.
Extrapolation is not supported.
With default fill = NA
if the output exceeds the wavelength range of
the input, extrapolated values are filled with NA
values. With
fill = NULL
wavelengths outside the wavelength range of input data
are discarded. A numerical value can be also be provided as fill. While
interpolate_spectrum
supports interpolation of a single numeric
vector, interpolate_wl
applies, one at a time, interpolation to all
numeric columns found in x
.
interpolate_wl(sun.spct, 400:500, NA)
interpolate_wl(sun.spct, 400:500, NULL)
interpolate_wl(sun.spct, seq(200, 1000, by=0.1), 0)
interpolate_wl(sun.spct, c(400,500), length.out=201)
Run the code above in your browser using DataLab