View source: R/smooth_intens.R
smooth_intens | R Documentation |
This smoother can enhance the signal to noise ratio of the data useing a Savitzky-Golay or Whittaker-Henderson filter.
smooth_intens(x, ...)
## Default S3 method:
smooth_intens(x, ...)
## S3 method for class '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, ...)
## Default S3 method:
calc_window_points(x, wavenum_width = 70, ...)
## S3 method for class 'OpenSpecy'
calc_window_points(x, wavenum_width = 70, ...)
x |
an object of class |
polynomial |
polynomial order for the filter |
window |
number of data points in the window, filter length (must be odd). |
derivative |
the derivative order if you want to calculate the derivative. Zero (default) is no derivative. |
abs |
logical; whether you want to calculate the absolute value of the resulting output. |
lambda |
smoothing parameter for Whittaker-Henderson smoothing, 50 results in rough smoothing and 10^4 results in a high level of smoothing. |
d |
order of differences to use for Whittaker-Henderson smoothing, typically set to 2. |
type |
the type of smoothing to use "wh" for Whittaker-Henerson or "sg" for Savitzky-Golay. |
lag |
the lag to use for the numeric derivative calculation if using Whittaker-Henderson. Greater values lead to smoother derivatives, 1 or 2 is common. |
make_rel |
logical; if |
wavenum_width |
the width of the window you want in wavenumbers. |
... |
further arguments passed to |
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.
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.
Win Cowger, Zacharias Steinmetz
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.