LIBS spectra typically contain a continuum background, electronic
noise, and shot-to-shot intensity variation. libscanR
provides chainable preprocessing primitives: baseline correction,
normalization, smoothing, cropping, and shot averaging.
Four methods are supported: snip, als,
rolling_ball, linear, polynomial.
SNIP and ALS are the workhorses for LIBS continuum removal.
spec <- ls_simulate_spectrum(line_data = ls_demo_peaks(),
elements = c(Ca = 5000, Na = 1000, K = 800, Fe = 200),
n_channels = 1024, seed = 1
)
snip <- ls_baseline(spec, method = "snip", iterations = 60)
als <- ls_baseline(spec, method = "als", iterations = 10, lambda = 1e5)
df <- rbind(
data.frame(w = spec$wavelength,
y = libscanR:::.mean_intensity(spec),
method = "raw"),
data.frame(w = spec$wavelength,
y = libscanR:::.mean_intensity(snip),
method = "SNIP"),
data.frame(w = spec$wavelength,
y = libscanR:::.mean_intensity(als),
method = "ALS")
)
ggplot2::ggplot(df, ggplot2::aes(w, y, colour = method)) +
ggplot2::geom_line() + theme_libs() +
ggplot2::labs(x = "Wavelength (nm)", y = "Intensity (a.u.)")Five options: