library(gamma)
gamma is intended to process in-situ gamma-ray spectrometry measurements for luminescence dating. This package allows to import, inspect and (automatically) correct the energy scale of the spectrum. It provides methods for estimating the gamma dose rate by the use of a calibration curve. This package only supports Canberra CNF and TKA files.
Typical workflow:
read()
,plot()
,calibrate_energy()
,predict_dose()
.The estimation of the gamma dose rate requires a calibration curve.
This package contains several built-in curves, but as these are
instrument-specific you may need to build your own (see
help(fit)
). These built-in curves are in use in several
labs and can be used to reproduce published results. Check out the
following vignettes for an overview of the fitting process.
# IRAMAT-CRP2A LaBr (BDX1)
::vignette("CRP2A#1", package = "gamma")
utils
# CEREGE NaI (AIX1)
::vignette("CEREGE#1", package = "gamma") utils
Note that gamma uses the International System of Units: energy values are assumed to be in keV and dose rates in µGy/y.
Both Canberra CNF and TKA files can be imported.
# Automatically skip the first channels
# Import a CNF file
<- system.file("extdata/LaBr.CNF", package = "gamma")
cnf_test <- read(cnf_test))
(spc_cnf #> Gamma spectrum:
#> * name: LaBr
#> * date: 2019-02-07 11:48:18
#> * live_time: 3385.54
#> * real_time: 3403.67
#> * channels: 1024
#> * energy_min: -7
#> * energy_max: 3124.91
# Import a TKA file
<- system.file("extdata/LaBr.TKA", package = "gamma")
tka_test <- read(tka_test))
(spc_tka #> Gamma spectrum:
#> * name: LaBr
#> * date: 2022-08-23 15:07:52
#> * live_time: 3385.54
#> * real_time: 3403.67
#> * channels: 1024
#> * energy_min: NA
#> * energy_max: NA
# Import all files in a given directory
<- system.file("extdata", package = "gamma")
files_test <- read(files_test))
(spc #> A collection of 3 gamma spectra: BEGe, LaBr, LaBr
# Plot CNF spectrum
plot(spc_cnf) +
::theme_bw() ggplot2
The energy calibration of a spectrum is the most tricky part. To do this, you must specify the position of at least three observed peaks and the corresponding energy value (in keV).
The package allows you to provide the channel-energy pairs you want to use. However, the spectrum can be noisy so it is difficult to properly determine the peak channel. In this case, a better approach may be to pre-process the spectrum (variance-stabilization, smoothing and baseline correction) and perform a peak detection. Once the identified peaks are satisfactory, you can set the corresponding energy values (in keV) and use these lines to calibrate the energy scale of the spectrum.
Regardless of the approach you choose, it is strongly recommended to check the result before proceeding.
The following steps illustrate how to properly fine-tune the parameters for spectrum processing before peak detection.
Several channels can be dropped to retain only part of the spectrum. If no specific value is provided, an attempt is made to define the number of channels to skip at the beginning of the spectrum. This drops all channels before the highest count maximum. This is intended to deal with the artefact produced by the rapid growth of random background noise towards low energies.
# Use a square root transformation
<- signal_slice(spc_tka) sliced
The stabilization step aims at improving the identification of peaks with a low signal-to-noise ratio. This particularly targets higher energy peaks.
# Use a square root transformation
<- signal_stabilize(sliced, f = sqrt) transformed
# Use a 21 point Savitzky-Golay-Filter to smooth the spectrum
<- signal_smooth(transformed, method = "savitzky", m = 21) smoothed
The baseline estimation is performed using the SNIP algorithm (Ryan et al. 1988; Morháč et al. 1997; Morháč and Matoušek 2008). You can apply the LLS operator to your data, use a decreasing clipping window or change the number of iterations (see references).
# Estimate the baseline of a single file
<- signal_baseline(smoothed, method = "SNIP", decreasing = TRUE)
baseline
# Plot spectrum + baseline
plot(smoothed, baseline) +
::labs(title = "Spectrum + baseline") +
ggplot2::theme_bw() ggplot2
# Substract the estimated baseline
<- smoothed - baseline
corrected # Or, remove the baseline in one go
# corrected <- removeBaseline(smoothed)
# Plot the corrected spectrum
plot(corrected) +
::labs(title = "Baseline-corrected spectrum") +
ggplot2::theme_bw() ggplot2
# You can remove the baseline of multiple spectra in one go
# Note that the same parameters will be used for all spectra
<- signal_correct(spc) clean
Once you have a baseline-corrected spectrum, you can try to automatically find peaks in the spectrum. A local maximum has to be the highest one in the given window and has to be higher than \(k\) times the noise to be recognized as peak.
# Detect peaks in a single file
<- peaks_find(corrected)
peaks
# Plot spectrum + peaks
plot(corrected, peaks) +
::labs(title = "Peaks") +
ggplot2::theme_bw() ggplot2
If you know the correspondence between several channels and the energy scale, you can use these pairs of values to calibrate the spectrum. A second order polynomial model is fitted on these energy vs channel values, then used to predict the new energy scale of the spectrum.
You can use the results of the peak detection and set the expected energy values.
# Set the energy values (in keV)
set_energy(peaks) <- c(238, NA, NA, NA, 1461, NA, NA, 2615)
peaks#> 3 peaks were detected.
# Calibrate the spectrum using the peak positions
<- energy_calibrate(spc_tka, peaks)
scaled
# Plot the spectrum
plot(scaled, xaxis = "energy") +
::labs(title = "Calibrated spectrum") +
ggplot2::theme_bw() ggplot2
Alternatively, you can do it by hand.
# Create a list of channel-enegy pairs
<- list(
calib_lines channel = c(84, 492, 865),
energy = c(238, 1461, 2615)
)
# Calibrate the spectrum using these fixed lines
<- energy_calibrate(spc_tka, lines = calib_lines) scaled2
library(magrittr)
# Spectrum pre-processing and peak detection
<- spc_tka %>%
pks signal_slice() %>%
signal_stabilize(f = sqrt) %>%
signal_smooth(method = "savitzky", m = 21) %>%
signal_correct(method = "SNIP", decreasing = TRUE, n = 100) %>%
peaks_find()
# Set the energy values (in keV)
set_energy(pks) <- c(238, NA, NA, NA, 1461, NA, NA, 2615)
# Calibrate the energy scale
<- energy_calibrate(spc_tka, pks)
cal
# Plot spectrum
plot(cal, pks) +
::theme_bw() ggplot2
To estimate the gamma dose rate, you can either use one of the calibration curves distributed with this package or build your own.
# Load one of the built-in curves
data(BDX_LaBr_1) # IRAMAT-CRP2A (Bordeaux)
data(AIX_NaI_1) # CEREGE (Aix-en-Provence)
The construction of a calibration curve requires a set of reference spectra for which the gamma dose rate is known and a background noise measurement. First, each reference spectrum is integrated over a given interval, then normalized to active time and corrected for background noise. The dose rate is finally modelled by the integrated signal value used as a linear predictor.
See vignette(doserate)
for a reproducible example.