The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Baseline Estimation

N. Frerebeau

2024-07-26

library(alkahest)
## Load data
data("XRD") # X-ray diffraction

## Subset from 20 to 70 degrees
XRD <- signal_select(XRD, from = 20, to = 70)

## Y plot limits
ylim <- c(0, max(XRD$y))

1. Linear baseline

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = expression(2*theta), ylab = "Count")
abline(h = 0, lty = "dashed")

## Estimate the baseline between 25 and 34 degrees
baseline <- baseline_linear(XRD, points = c(25, 34))

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

Linear baseline.

2. Polynomial baseline

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = expression(2*theta), ylab = "Count")
abline(h = 0, lty = "dashed")

## Estimate the baseline
baseline <- baseline_polynomial(XRD, d = 4, tolerance = 0.02, stop = 1000)

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

Polynomial baseline.

3. Asymmetric Least Squares Smoothing

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = "Energy (keV)", ylab = "Count")
abline(h = 0, lty = "dashed")

## AsLS baseline
baseline <- baseline_asls(XRD, p = 0.005, lambda = 10^7)

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

Asymmetric Least Squares Smoothing.

4. Rolling Ball baseline

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = expression(2*theta), ylab = "Count")
abline(h = 0, lty = "dashed")

## Estimate the baseline
baseline <- baseline_rollingball(XRD, m = 201, s = 151)

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

Rolling Ball baseline.

5. Rubberband baseline

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = expression(2*theta), ylab = "Count")
abline(h = 0, lty = "dashed")

## Estimate the baseline
baseline <- baseline_rubberband(XRD)

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

Rubberband baseline.

6. SNIP baseline

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = expression(2*theta), ylab = "Count")
abline(h = 0, lty = "dashed")

## Estimate the baseline
baseline <- baseline_snip(XRD, LLS = FALSE, decreasing = FALSE, n = 100)

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

SNIP baseline.

7. 4S Peak Filling

## Plot spectrum
plot(XRD, type = "l", ylim = ylim, xlab = "Energy (keV)", ylab = "Count")
abline(h = 0, lty = "dashed")

## 4S Peak Filling baseline
baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, 
                                 lambda = 1000, d = 3, sparse = TRUE)

## Plot the baseline
lines(baseline, col = "red")

## Correct spectrum
corrected <- signal_drift(XRD, lag = baseline, subtract = TRUE)

lines(corrected, col = "blue")

4S Peak Filling.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.