This function gives the result of interpolating spectral data from the original set of wavelengths to a new one.
interpolate_spct(
spct,
w.length.out = NULL,
fill = NA,
length.out = NULL,
method = "approx",
...
)interpolate_mspct(
mspct,
w.length.out = NULL,
fill = NA,
length.out = NULL,
method = "approx",
...,
.parallel = FALSE,
.paropts = NULL
)
A new spectral object of the same class as argument spct
with
a different number of rows than x
, different w.length
values
and new numeric values for spectral data obtained by interpolation.
generic_spct
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()
.
an object of class "generic_mspct"
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.
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_spct(sun.spct, 400:500, NA)
interpolate_spct(sun.spct, 400:500, NULL)
interpolate_spct(sun.spct, seq(200, 1000, by=0.1), 0)
interpolate_spct(sun.spct, c(400,500), length.out=201)
Run the code above in your browser using DataLab