Resamples (interpolates) different spectra types with
corresponding x-axis values that are both stored in list-columns of a spectra
tibble. A spectra tibble hosts spectra, x-axis vectors, metadata, and
further linked data with standardized naming conventions. Data input for
resampling can for example be generated with simplerspec::gather_spc()
.
Resampling is a key harmonizing step to process and later model spectra
measured at different resolutions and spectral ranges (i.e., different
spectrometer devices and/or measurement settings).
Spectra data embedded in a tibble object (classes
"tbl_df", "tbl", "data.frame"
). The spectra tibble needs to contain at
least of one of the the spectra columns spc
, spc_rs
, spc_mean
,
spc_nocomp
, sc_sm
, sc_rf
, or spc_pre
(list-columns with spectral
data.table
s), and wavenumbers
or wavelengths
(list-column with vectors
of x-axis values corresponding to each spectrum). The help section "Matching
spectrum type and corresponding x-axis type" describes the spectra types
and corresponding x-axis types.
Character vector of length 1L or symbol/name specifying the name of list-column that contains the spectra to be resampled.
Character vector of length 1L specifying the measurement unit
of the x-axis values (list-column) of the input spectra in spc_tbl
.
Possible values are "wavenumber"
(default) or "wavelength"
. Wavenumber
is a convenient unit of frequency in the mid-infrared spectral range,
where wavelength is often used as spatial period for the visible and
near-infrared range.
Numeric value of lowest wavenumber. This argument will only
be used if x_unit = "wavenumber"
. The value serves as starting value for
the new wavenumber sequence that the spectra will be resampled upon. Default
value is 500 (i.e., in reciprocal centimeters).
Numeric value of highest wavenumber. This argument will only
be used if x_unit = "wavenumber
. The value will be used as last value of
the new wavenumber sequence that the spectra will be resampled upon. Default
value is 4000 (i.e., in reciprocal centimeters).
Numeric value of the wavenumber increment for the new wavenumber sequence that the spectra will be resampled upon. Default value is 2 (i.e., in reciprocal centimeters).
Numeric value of lowest wavelength. This argument will only
be used if x_unit = "wavelength"
. The value serves as starting value of
the new wavenumber sequence that the spectra will be resampled upon.
Default value is 350 (i.e. in nanometers).
Numeric value of highest wavelength. This argument will only
be used if x_unit = "wavelength"
. The value will be used as last value of
the new wavenumber sequence that the spectra will be resampled upon. Default
value is 2500 (i.e., in nanometers).
Numeric value of the wavelength increment for the new
wavenumber sequence that the spectra will be resampled upon. This argument
will only be used if x_unit = "wavelength"
. Default value is 1 (i.e., in
nanometers).
Character of "linear"
(default) or "spline"
with
the interpolation method. "spline"
uses a cubic spline to interpolate the
input spectra at given x-axis values to new equispaced x-axis intervals.
A spectra tibble (spc_tbl
) containing two added list-columns:
spc_rs:
Resampled spectra as list of data.table
s
wavenumbers_rs
or wavelengths_rs
: Resampled x-axis values as list of
numeric vectors
The combinations of input spectrum types (column_in
) and
corresponding x-axis types are generated from a simple lookup list. The
following key-value(s) pairs can be matched at given key, which is the column
name from column_in
containing the spectra.
"spc"
: "wavenumbers"
or "wavelengths"
(raw spectra)
"spc_rs"
: "wavenumbers_rs"
or "wavelengths_rs"
) (resampled spectra)
"spc_mean"
: "wavenumbers_rs"
or "wavelengths_rs"
(mean spectra)
"spc_nocomp"
"wavenumbers"
or "wavelengths"
(spectra prior
atmospheric compensation)
"sc_sm" : c("wavenumbers_sc_sm", "wavelengths_sc_sm")
(single channel
sample spectra)
"sc_rf" : c("wavenumbers_sc_rf", "wavelengths_sc_rf")
(single channel
reference spectra)
"spc_pre" : "xvalues_pre"
(preprocessed spectra)