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.
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()
,energy_calibrate()
,dose_predict()
.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(dose_fit)
). These built-in curves are in use in
several labs and can be used to reproduce published results. Check out
the dedicated vignette for an overview of the fitting process:
vignette("doserate")
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
cnf_test <- system.file("extdata/LaBr.CNF", package = "gamma")
(spc_cnf <- read(cnf_test))
#> 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
tka_test <- system.file("extdata/LaBr.TKA", package = "gamma")
(spc_tka <- read(tka_test))
#> Gamma spectrum:
#> * name: LaBr
#> * date: 2024-09-23 21:26:10.596201
#> * live_time: 3385.54
#> * real_time: 3403.67
#> * channels: 1024
#> * energy_min: NA
#> * energy_max: NA
# Import all files in a given directory
files_test <- system.file("extdata", package = "gamma")
(spc <- read(files_test))
#> A collection of 4 gamma spectra: BEGe, Kromek_CZT, LaBr, LaBr
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.
The stabilization step aims at improving the identification of peaks with a low signal-to-noise ratio. This particularly targets higher energy peaks.
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
baseline <- signal_baseline(smoothed, method = "SNIP", decreasing = TRUE)
# Plot spectrum + baseline
plot(smoothed, baseline) +
ggplot2::labs(title = "Spectrum + baseline") +
ggplot2::theme_bw()
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.
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
scaled <- energy_calibrate(spc_tka, peaks)
# Plot the spectrum
plot(scaled, xaxis = "energy") +
ggplot2::labs(title = "Calibrated spectrum") +
ggplot2::theme_bw()
Alternatively, you can do it by hand:
# Spectrum pre-processing and peak detection
pks <- spc_tka |>
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
cal <- energy_calibrate(spc_tka, pks)
# Plot spectrum
plot(cal, pks) +
ggplot2::theme_bw()
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.
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.