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)interpolate_mspct(
mspct,
w.length.out = NULL,
fill = NA,
length.out = NULL,
.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 value to be assigned to out of range wavelengths
numeric value
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 the extent of the data natural spline interpolation or
linear interpolation are used. In the first case a call to
spline
with method = "natural"
is
used when 25 or fewer distinct wavelengths are available as input, or if
the wavelengths in the output are more than three times those in the input.
In the second case, a call to approx
is
used.
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