ir_smooth {ir} | R Documentation |
Smooths infrared spectra in an ir
object
Description
ir_smooth
applies smoothing functions to infrared spectra.
ir_smooth
either performs Savitzky-Golay smoothing, using on
signal::sgolayfilt()
, or Fourier smoothing using
fda::smooth.basis()
. Savitzky-Golay smoothing can
also be used to compute derivatives of spectra.
Usage
ir_smooth(
x,
method = "sg",
p = 3,
n = p + 3 - p%%2,
ts = 1,
m = 0,
k = 111,
...
)
Arguments
x |
An object of class |
method |
A character value specifying which smoothing method to apply.
If |
p |
An integer value representing the filter order (i.e. the degree of
the polynom) of the Savitzky-Golay filter if |
n |
An odd integer value representing the length (i.e. the number of
wavenumber values used to construct the polynom) of the Savitzky-Golay filter
if |
ts |
time scaling factor. See |
m |
An integer value representing the mth derivative to compute. This
option can be used to compute derivatives of spectra. See
|
k |
A positive odd integer representing the number of Fourier basis
functions to use as smoothed representation of the spectra if
|
... |
additional arguments (ignored). |
Details
When x
contains spectra with different wavenumber values, the
filters are applied for each spectra only on existing wavenumber values. This
means that the filter window (if method == "sg"
) will be different for
these different spectra.
Value
x
with smoothed spectra.
Examples
#' # Savitzky-Golay smoothing
x1 <-
ir::ir_sample_data[1:5, ] %>%
ir::ir_smooth(method = "sg", p = 3, n = 51, ts = 1, m = 0)
# Fourier smoothing
x2 <-
ir::ir_sample_data[1:5, ] %>%
ir::ir_smooth(method = "fourier", k = 21)
# computing derivative spectra with Savitzky-Golay smoothing (here: first
# derivative)
x3 <-
ir::ir_sample_data[1:5, ] %>%
ir::ir_smooth(method = "sg", p = 3, n = 51, ts = 1, m = 1)