line_intensities: Intensities of Emission Lines

View source: R/line_intensities.R

line_intensitiesR Documentation

Intensities of Emission Lines

Description

Measures the intensity of emission lines in spectra: for each line, the peak is searched near its tabulated wavelength, and its area or height is measured. The result feeds boltzmann(), saha_boltzmann(), cf_libs() and calibration_curve().

Usage

line_intensities(
  spectra,
  lines,
  half_width = 0.15,
  search = 0.2,
  method = "area",
  baseline = FALSE,
  fit_width = 3 * half_width,
  limit = NULL,
  min_snr = 3
)

Arguments

spectra

The spectra: a numeric vector named by wavelength (one spectrum), or a matrix or data frame with one spectrum per row and the wavelengths as column names. Other columns of a data frame (such as sample names) are kept in the result.

lines

The lines: a numeric vector of wavelengths (nm), whose names are used as labels, or a data frame with a wavelength column, such as returned by nist_lines(), whose columns are kept in the result.

half_width

The half-width of the integration window around the peak, in nm. Default is 0.15.

search

The half-width of the window in which the peak is searched around the tabulated wavelength, in nm. Default is 0.2.

method

"area" (default), "height" or "voigt".

baseline

A logical: subtract a linear baseline under each line (FALSE, default).

fit_width

The half-width of the window of the Voigt fit, in nm. Default is 3 times half_width.

limit

The saturation limit of the detector, in counts, or NULL (default) not to check saturation.

min_snr

The signal-to-noise ratio above which a line is detected. Default is 3.

Details

For each spectrum and line, the peak is the channel of highest intensity within search nm of the tabulated wavelength, which absorbs small errors of the wavelength calibration. The intensity is then measured on the channels within half_width nm of the peak:

  • method = "area" (default): the integrated intensity (trapezoidal rule), in intensity units times nm;

  • method = "height": the peak intensity;

  • method = "voigt": the area of a Voigt profile fitted with peak_fit() to the channels within fit_width nm of the peak. It separates the line from a flat background and is less sensitive to the window, but it is slower and needs a line well sampled by the detector.

With baseline = TRUE, a straight line through the intensities at both ends of the window is subtracted before the area or height is measured (the Voigt fit always includes a constant background).

Each line is also checked:

  • snr: the height above the baseline divided by the noise of the spectrum, estimated robustly from its channel-to-channel differences; detected is snr >= min_snr.

  • saturated: with limit, whether a channel of the window reaches the saturation limit of the detector (see saturation_summary()).

intensity_se is the standard error of the intensity due to the noise of the spectrum: the noise (as for snr) propagated through the integration and the baseline subtraction, or, for the Voigt method, the standard error of the fitted area. The noise is taken as white and the same in every channel, so this is a lower bound: it leaves out the shot-to-shot fluctuations of the plasma, which usually dominate in LIBS. These are better estimated from replicate spectra, as the standard deviation of the intensities of the replicates divided by the square root of their number. plasma_uncertainty() propagates intensity_se to the temperature and the composition.

Value

A tibble with one row per spectrum and line: the other columns of spectra (or spectrum, the row number), the columns of lines (or line and wavelength), and peak_wavelength, shift (nm), height, intensity, intensity_se, snr, detected and saturated (which replace the columns of lines of the same name, such as the relative intensity listed by nist_lines()). For a single spectrum, it has one row per line, like lines, with the measured intensity.

Author(s)

Christian L. Goueguel

See Also

step_line_intensities(), nist_lines(), cf_libs(), calibration_curve(), peak_fit()

Examples

data(forageLIBS)
spectra <- forageLIBS[1:8, -(1:14)]
k <- c(`K I 404.41` = 404.414, `K I 404.72` = 404.721, `Mg I 518.36` = 518.360)
line_intensities(spectra, k, baseline = TRUE)

# one spectrum and a table of lines, ready for a Boltzmann plot
lines <- data.frame(wavelength = c(428.30, 430.25, 443.50, 445.48),
                    Aki = c(4.34e7, 1.36e8, 6.70e7, 8.70e7), gk = c(5, 5, 5, 7),
                    Ek = c(4.78, 4.78, 4.68, 4.68))
mean_spectrum <- colMeans(forageLIBS[-(1:14)])
line_intensities(mean_spectrum, lines, baseline = TRUE)

specProc documentation built on Nov. 20, 2026, 5:11 p.m.