This smoother can enhance the signal to noise ratio of the data useing a Savitzky-Golay or Whittaker-Henderson filter.
smooth_intens(x, ...)# S3 method for default
smooth_intens(x, ...)
# S3 method for OpenSpecy
smooth_intens(
x,
polynomial = 3,
window = 11,
derivative = 1,
abs = TRUE,
lambda = 1600,
d = 2,
type = "sg",
lag = 2,
make_rel = TRUE,
...
)
calc_window_points(x, ...)
# S3 method for default
calc_window_points(x, wavenum_width = 70, ...)
# S3 method for OpenSpecy
calc_window_points(x, wavenum_width = 70, ...)
smooth_intens()
returns an OpenSpecy
object.
calc_window_points()
returns a single numberic vector object of the
number of points needed to fill the window and can be passed to smooth_intens()
.
For many applications, this is more reusable than specifying a static number of points.
an object of class OpenSpecy
or vector for calc_window_points()
.
polynomial order for the filter
number of data points in the window, filter length (must be odd).
the derivative order if you want to calculate the derivative. Zero (default) is no derivative.
logical; whether you want to calculate the absolute value of the resulting output.
smoothing parameter for Whittaker-Henderson smoothing, 50 results in rough smoothing and 10^4 results in a high level of smoothing.
order of differences to use for Whittaker-Henderson smoothing, typically set to 2.
the type of smoothing to use "wh" for Whittaker-Henerson or "sg" for Savitzky-Golay.
the lag to use for the numeric derivative calculation if using Whittaker-Henderson. Greater values lead to smoother derivatives, 1 or 2 is common.
logical; if TRUE
spectra are automatically normalized
with make_rel()
.
the width of the window you want in wavenumbers.
further arguments passed to sgolay()
.
Win Cowger, Zacharias Steinmetz
For Savitzky-Golay this is a wrapper around the filter function in the signal package to improve integration with other Open Specy functions. A typical good smooth can be achieved with 11 data point window and a 3rd or 4th order polynomial. For Whittaker-Henderson, the code is largely based off of the whittaker() function in the pracma package. In general Whittaker-Henderson is expected to be slower but more robust than Savitzky-Golay.
Savitzky A, Golay MJ (1964). “Smoothing and Differentiation of Data by Simplified Least Squares Procedures.” Analytical Chemistry, 36(8), 1627--1639.
sgolay()
data("raman_hdpe")
smooth_intens(raman_hdpe)
smooth_intens(raman_hdpe, window = calc_window_points(x = raman_hdpe, wavenum_width = 70))
smooth_intens(raman_hdpe, lambda = 1600, d = 2, lag = 2, type = "wh")
Run the code above in your browser using DataLab