smooth_intens {OpenSpecy} | R Documentation |
Smooth spectral intensities
Description
This smoother can enhance the signal to noise ratio of the data useing a Savitzky-Golay or Whittaker-Henderson filter.
Usage
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, ...)
Arguments
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 |
Details
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.
Value
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.
Author(s)
Win Cowger, Zacharias Steinmetz
References
Savitzky A, Golay MJ (1964). “Smoothing and Differentiation of Data by Simplified Least Squares Procedures.” Analytical Chemistry, 36(8), 1627–1639.
See Also
sgolay()
Examples
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")