Interpolate/re-express spectral irradiance (or other spectral quantity) values at new wavelengths values. This is a low-level function operating on numeric vectors and called by higher level functions in the package, such as mathematical operators for classes for spectral data.
interpolate_spectrum(
w.length.in,
s.irrad,
w.length.out,
fill = NA,
method = "approx",
...
)
a numeric vector of interpolated spectral values.
numeric vector of wavelengths (nm).
a numeric vector of spectral values.
numeric vector of wavelengths (nm).
a numeric value to be assigned to out of range wavelengths.
character string One of "auto"
, "approx"
,
"spline"
, "skip"
.
additional arguments passed to spline()
.
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
.
Other low-level functions operating on numeric vectors.:
as_energy()
,
as_quantum_mol()
,
calc_multipliers()
,
div_spectra()
,
energy_irradiance()
,
energy_ratio()
,
insert_hinges()
,
integrate_xy()
,
irradiance()
,
l_insert_hinges()
,
oper_spectra()
,
photon_irradiance()
,
photon_ratio()
,
photons_energy_ratio()
,
prod_spectra()
,
s_e_irrad2rgb()
,
split_energy_irradiance()
,
split_photon_irradiance()
,
subt_spectra()
,
sum_spectra()
,
trim_tails()
,
v_insert_hinges()
,
v_replace_hinges()
my.w.length <- 300:700
with(sun.data, interpolate_spectrum(w.length, s.e.irrad, my.w.length))
Run the code above in your browser using DataLab