Title: | Dose Rate Estimation from in-Situ Gamma-Ray Spectrometry Measurements |
---|---|
Description: | Process in-situ Gamma-Ray Spectrometry for Luminescence Dating. This package allows to import, inspect and correct the energy shifts of gamma-ray spectra. It provides methods for estimating the gamma dose rate by the use of a calibration curve as described in Mercier and Falguères (2007). The package only supports Canberra CNF and TKA and Kromek SPE files. |
Authors: | Nicolas Frerebeau [aut] , Brice Lebrun [aut] , Guilhem Paradol [aut] , Magali Rizza [ctb] , Christelle Lahaye [ctb] , Sebastian Kreutzer [aut] , Archéosciences Bordeaux [cre], Université Bordeaux Montaigne [cph, fnd], CNRS [fnd], LabEx Sciences archéologiques de Bordeaux [fnd], Idex Aix-Marseille [fnd] |
Maintainer: | Archéosciences Bordeaux <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-12-23 05:31:58 UTC |
Source: | https://github.com/crp2a/gamma |
CEREGE Calibration Curve (NaI)
data(AIX_NaI_1)
data(AIX_NaI_1)
An object of class CalibrationCurve.
Laboratory | CEREGE |
Instrument | Canberra Inspector 1000 |
Detector | NaI |
Authors | CEREGE Luminescence Team |
Other datasets:
BDX_LaBr_1
,
clermont
,
clermont_2024
## Load the curve data(AIX_NaI_1, package = "gamma") plot(AIX_NaI_1)
## Load the curve data(AIX_NaI_1, package = "gamma") plot(AIX_NaI_1)
Baseline Estimation and Removal
signal_baseline(object, ...) signal_correct(object, ...) baseline_snip(object, ...) baseline_rubberband(object, ...) baseline_linear(object, ...) ## S4 method for signature 'GammaSpectrum' signal_baseline(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectra' signal_baseline(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectrum' signal_correct(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectra' signal_correct(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectrum' baseline_linear(object, from = NULL, to = NULL) ## S4 method for signature 'GammaSpectra' baseline_linear(object, from = NULL, to = NULL) ## S4 method for signature 'GammaSpectrum' baseline_rubberband(object, noise = 0, spline = TRUE, ...) ## S4 method for signature 'GammaSpectra' baseline_rubberband(object, noise = 0, spline = TRUE, ...) ## S4 method for signature 'GammaSpectrum' baseline_snip(object, LLS = FALSE, decreasing = FALSE, n = 100, ...) ## S4 method for signature 'GammaSpectra' baseline_snip(object, LLS = FALSE, decreasing = FALSE, n = 100, ...)
signal_baseline(object, ...) signal_correct(object, ...) baseline_snip(object, ...) baseline_rubberband(object, ...) baseline_linear(object, ...) ## S4 method for signature 'GammaSpectrum' signal_baseline(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectra' signal_baseline(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectrum' signal_correct(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectra' signal_correct(object, method = c("SNIP", "rubberband", "linear"), ...) ## S4 method for signature 'GammaSpectrum' baseline_linear(object, from = NULL, to = NULL) ## S4 method for signature 'GammaSpectra' baseline_linear(object, from = NULL, to = NULL) ## S4 method for signature 'GammaSpectrum' baseline_rubberband(object, noise = 0, spline = TRUE, ...) ## S4 method for signature 'GammaSpectra' baseline_rubberband(object, noise = 0, spline = TRUE, ...) ## S4 method for signature 'GammaSpectrum' baseline_snip(object, LLS = FALSE, decreasing = FALSE, n = 100, ...) ## S4 method for signature 'GammaSpectra' baseline_snip(object, LLS = FALSE, decreasing = FALSE, n = 100, ...)
object |
A GammaSpectrum or GammaSpectra object. |
... |
Extra parameters to be passed to further methods. |
method |
A |
from |
An |
to |
An |
noise |
A length-one |
spline |
A |
LLS |
A |
decreasing |
A |
n |
An |
The following methods are available for baseline estimation:
SNIP
Sensitive Nonlinear Iterative Peak clipping algorithm.
rubberband
A convex envelope of the spectrum is determined and the baseline is estimated as the part of the convex envelope lying below the spectrum. Note that the rubber band does not enter the concave regions (if any) of the spectrum.
linear
Linear baseline estimation.
baseline_*()
returns a BaseLine object.
signal_correct()
returns a corrected GammaSpectrum or
GammaSpectra object (same as object
).
baseline_rubberband()
is slightly modified from C. Beleites'
hyperSpec::spc.rubberband()
.
N. Frerebeau
Liland, K. H. (2015). 4S Peak Filling - baseline estimation by iterative mean suppression. MethodsX, 2, 135-140. doi:10.1016/j.mex.2015.02.009.
Morháč, M., Kliman, J., Matoušek, V., Veselský, M. & Turzo, I. (1997). Background elimination methods for multidimensional gamma-ray spectra. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 401(1), p. 113-132. doi:10.1016/S0168-9002(97)01023-1
Morháč, M. & Matoušek, V. (2008). Peak Clipping Algorithms for Background Estimation in Spectroscopic Data. Applied Spectroscopy, 62(1), p. 91-106. doi:10.1366/000370208783412762
Ryan, C. G., Clayton, E., Griffin, W. L., Sie, S. H. & Cousens, D. R. (1988). SNIP, a statistics-sensitive background treatment for the quantitative analysis of PIXE spectra in geoscience applications. Nuclear Instruments and Methods in Physics Research Section B: Beam Interactions with Materials and Atoms, 34(3), p. 396-402. doi:10.1016/0168-583X(88)90063-8
Other signal processing:
peaks_find()
,
peaks_search()
,
signal_integrate()
,
signal_slice()
,
signal_split()
,
signal_stabilize()
,
smooth()
## Import a CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Remove the first 35 channels spc <- signal_slice(spc, -c(1:35)) ## Linear baseline bsl_linear <- baseline_linear(spc, from = 250, to = 750) plot(spc, bsl_linear) ## SNIP baseline bsl_snip <- baseline_snip(spc, LLS = FALSE, decreasing = FALSE, n = 100) plot(spc, bsl_snip) ## Rubberband baseline bsl_rubber <- baseline_rubberband(spc) plot(spc, bsl_rubber) ## Remove baseline spc_clean1 <- signal_correct(spc) spc_clean2 <- spc - bsl_snip all(spc_clean1 == spc_clean2) plot(spc_clean1)
## Import a CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Remove the first 35 channels spc <- signal_slice(spc, -c(1:35)) ## Linear baseline bsl_linear <- baseline_linear(spc, from = 250, to = 750) plot(spc, bsl_linear) ## SNIP baseline bsl_snip <- baseline_snip(spc, LLS = FALSE, decreasing = FALSE, n = 100) plot(spc, bsl_snip) ## Rubberband baseline bsl_rubber <- baseline_rubberband(spc) plot(spc, bsl_rubber) ## Remove baseline spc_clean1 <- signal_correct(spc) spc_clean2 <- spc - bsl_snip all(spc_clean1 == spc_clean2) plot(spc_clean1)
An S4 Class to Represent a Spectrum Baseline
This class extends the GammaSpectrum class.
N. Frerebeau
Other class:
CalibrationCurve-class
,
GammaSpectra-class
,
GammaSpectrum-class
,
PeakPosition-class
,
coerce()
## Import a CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Remove the first 35 channels spc <- signal_slice(spc, -c(1:35)) ## Linear baseline bsl_linear <- baseline_linear(spc, from = 250, to = 750) plot(spc, bsl_linear) ## SNIP baseline bsl_snip <- baseline_snip(spc, LLS = FALSE, decreasing = FALSE, n = 100) plot(spc, bsl_snip) ## Rubberband baseline bsl_rubber <- baseline_rubberband(spc) plot(spc, bsl_rubber) ## Remove baseline spc_clean1 <- signal_correct(spc) spc_clean2 <- spc - bsl_snip all(spc_clean1 == spc_clean2) plot(spc_clean1)
## Import a CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Remove the first 35 channels spc <- signal_slice(spc, -c(1:35)) ## Linear baseline bsl_linear <- baseline_linear(spc, from = 250, to = 750) plot(spc, bsl_linear) ## SNIP baseline bsl_snip <- baseline_snip(spc, LLS = FALSE, decreasing = FALSE, n = 100) plot(spc, bsl_snip) ## Rubberband baseline bsl_rubber <- baseline_rubberband(spc) plot(spc, bsl_rubber) ## Remove baseline spc_clean1 <- signal_correct(spc) spc_clean2 <- spc - bsl_snip all(spc_clean1 == spc_clean2) plot(spc_clean1)
CRP2A Calibration Curve (LaBr)
data(BDX_LaBr_1)
data(BDX_LaBr_1)
An object of class CalibrationCurve.
Laboratory | IRAMAT-CRP2A (UMR 5060) |
Instrument | Canberra Inspector 1000 |
Detector | LaBr |
Authors | CRP2A Luminescence Team |
Other datasets:
AIX_NaI_1
,
clermont
,
clermont_2024
## Load the curve data(BDX_LaBr_1, package = "gamma") plot(BDX_LaBr_1)
## Load the curve data(BDX_LaBr_1, package = "gamma") plot(BDX_LaBr_1)
An S4 class to Represent a Dose Rate Calibration Curve
Ni
A DoseRateModel object.
NiEi
A DoseRateModel object.
details
A list
of length-one vector giving the curve metadata.
slope
A numeric
vector.
intercept
A numeric
vector.
covariance
A numeric
vector.
MSWD
A numeric
vector.
df
A numeric
vector.
p_value
A numeric
vector.
data
A data.frame
.
range
A numeric
vector.
background
A numeric
vector.
In the code snippets below, x
is a CalibrationCurve
object.
x[[i]]
Extracts information from a slot selected by subscript i
.
i
is a character
vector of length one.
N. Frerebeau
Other class:
Baseline-class
,
GammaSpectra-class
,
GammaSpectrum-class
,
PeakPosition-class
,
coerce()
Clermont Reference Data
data("clermont")
data("clermont")
A data.frame
with tabulated data and conversion factor reference.
Guérin, G., Mercier, N. & Adamiec, G. (2011). Dose-Rate Conversion Factors: Update. Ancient TL, 29(1), p. 5-8.
Miallier, D., Guérin, G., Mercier, N., Pilleyre, T. & Sanzelle, S. (2009). The Clermont Radiometric Reference Rocks: A Convenient Tool for Dosimetric Purposes. Ancient TL, 27(2), p. 37-44.
Other datasets:
AIX_NaI_1
,
BDX_LaBr_1
,
clermont_2024
An updated version for the clermont
dataset with additional columns
for the applied dose rate conversion factors and their reference. The dataset
also contains gamma dose rate values and uncertainties for different published
conversion factors. Please note that the values for the conversion factors
applied in the original clermont
dataset differ slightly due to rounding
errors.
data("clermont_2024")
data("clermont_2024")
A data.frame
with tabulated data and conversion factor reference.
Adamiec, G. & Aitken, M.J. (1998). Dose-rate conversion factors: update. Ancient TL, 16, p. 37–50.
Cresswell, A.J., Carter, J. & Sanderson, D.C.W. (2018). Dose rate conversion parameters: Assessment of nuclear data. Radiation Measurements, 120, p. 195–201.
Guérin, G., Mercier, N. & Adamiec, G. (2011). Dose-Rate Conversion Factors: Update. Ancient TL, 29(1), p. 5-8.
Liritzis, I., Stamoulis, K., Papachristodoulou, C. & Ioannides, K. (2013). A re-evaluation of radiation dose-rate conversion factors. Mediterranean Archaeology and Archaeometry, 12, p. 1–15.
Miallier, D., Guérin, G., Mercier, N., Pilleyre, T. & Sanzelle, S. (2009). The Clermont Radiometric Reference Rocks: A Convenient Tool for Dosimetric Purposes. Ancient TL, 27(2), p. 37-44.
Other datasets:
AIX_NaI_1
,
BDX_LaBr_1
,
clermont
Coerce
## S3 method for class 'GammaSpectrum' as.matrix(x, ...)
## S3 method for class 'GammaSpectrum' as.matrix(x, ...)
x |
An object to be coerced. |
... |
Currently not used. |
A coerced object.
N. Frerebeau
Other class:
Baseline-class
,
CalibrationCurve-class
,
GammaSpectra-class
,
GammaSpectrum-class
,
PeakPosition-class
## Import a Canberra CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Coerce mtx <- as.matrix(spc) df <- as.data.frame(spc) head(df)
## Import a Canberra CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Coerce mtx <- as.matrix(spc) df <- as.data.frame(spc) head(df)
dose_fit()
builds a calibration curve for gamma dose rate estimation.
dose_predict()
predicts in situ gamma dose rate.
dose_fit(object, background, doses, ...) dose_predict(object, spectrum, ...) ## S4 method for signature 'GammaSpectra,GammaSpectrumOrNumeric,matrix' dose_fit( object, background, doses, range_Ni, range_NiEi, details = list(authors = "", date = Sys.time()) ) ## S4 method for signature 'GammaSpectra,GammaSpectrumOrNumeric,data.frame' dose_fit( object, background, doses, range_Ni, range_NiEi, details = list(authors = "", date = Sys.time()) ) ## S4 method for signature 'CalibrationCurve,missing' dose_predict( object, sigma = 1, epsilon = 0.015, water_content = NULL, use_MC = FALSE ) ## S4 method for signature 'CalibrationCurve,GammaSpectrum' dose_predict( object, spectrum, sigma = 1, epsilon = 0.015, water_content = NULL, use_MC = FALSE ) ## S4 method for signature 'CalibrationCurve,GammaSpectra' dose_predict( object, spectrum, sigma = 1, epsilon = 0.015, water_content = NULL, use_MC = FALSE )
dose_fit(object, background, doses, ...) dose_predict(object, spectrum, ...) ## S4 method for signature 'GammaSpectra,GammaSpectrumOrNumeric,matrix' dose_fit( object, background, doses, range_Ni, range_NiEi, details = list(authors = "", date = Sys.time()) ) ## S4 method for signature 'GammaSpectra,GammaSpectrumOrNumeric,data.frame' dose_fit( object, background, doses, range_Ni, range_NiEi, details = list(authors = "", date = Sys.time()) ) ## S4 method for signature 'CalibrationCurve,missing' dose_predict( object, sigma = 1, epsilon = 0.015, water_content = NULL, use_MC = FALSE ) ## S4 method for signature 'CalibrationCurve,GammaSpectrum' dose_predict( object, spectrum, sigma = 1, epsilon = 0.015, water_content = NULL, use_MC = FALSE ) ## S4 method for signature 'CalibrationCurve,GammaSpectra' dose_predict( object, spectrum, sigma = 1, epsilon = 0.015, water_content = NULL, use_MC = FALSE )
object |
A GammaSpectra or CalibrationCurve object. |
background |
A GammaSpectrum object or a length-two |
doses |
A |
... |
Currently not used. |
spectrum |
An optional GammaSpectrum or GammaSpectra object in which to look for variables with which to predict. If omitted, the fitted values are used. |
range_Ni , range_NiEi
|
A length-two |
details |
A |
sigma |
A |
epsilon |
A |
water_content |
|
use_MC |
A |
To estimate the gamma dose rate, one of the calibration curves distributed with this package can be used. These built-in curves are in use in several luminescence dating laboratories and can be used to replicate published results. As these curves are instrument specific, the user may have to build its own curve.
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 (York et al., 2004).
dose_fit()
returns a CalibrationCurve object.
dose_predict()
returns a data.frame
with the following columns:
name
(character
) the name of the spectra.
signal_Ni
(numeric
) the integrated signal value (according to
the value of threshold
; see signal_integrate()
) for energy = FALSE
signal_err_Ni
(numeric
) the integrated signal error value
(according to the value of threshold
; see signal_integrate()
) for energy = FALSE
.
dose_Ni
(numeric
) the predicted gamma dose rate for energy = FALSE
.
dose_err_Ni
(numeric
) the predicted gamma dose rate error for energy = FALSE
.
signal_Ni
(numeric
) the integrated signal value (according to
the value of threshold
; see signal_integrate()
).
signal_err_NiEi
(numeric
) the integrated signal error value
(according to the value of threshold
; see signal_integrate()
) for energy = TRUE
.
dose_NiEi
(numeric
) the predicted gamma dose rate for energy = TRUE
.
dose_err_NiEi
(numeric
) the predicted gamma dose rate error for energy = TRUE
.
dose_final
(numeric
) the predicted final gamma dose rate as the mean of dose_Ni
and dose_NiEi
dose_err_final
(numeric
) the predicted final gamma dose rate error as
The analytical uncertainties of the final gamma-dose rate () are calculated as
follows:
with and
being the slope of the fit an its uncertainty,
the error scaler for the slope uncertainty,
and
the integrated signal and its uncertainty, and
an additional relative uncertainty
term that can be set by the user using the argument
epsilon
.
If the parameter use_MC
is set to TRUE
, the a Monte Carlo sampling approach
is chosen to approximate the uncertainties on the dose rate:
is the parameter
sigma
provided with the function call, equals the
the call to
sd()
, i.e. the calculation of the standard deviation. To achieve a good
Gaussian normal approximation with sample 1+e06 times (the values is fixed).
If gamma-dose rates are measured in the field, they are measured at "as-is"
conditions. In dating studies, however, using the dry dose rate is often
more desirable to model the long-term effect of different assumptions for
the water content. If the parameter water_content
, either as numeric
vector or as matrix with the number of rows equal to the number of
processed spectra, if different values are desired, the final
gamma-dose rate is corrected for the water content provided. Final
uncertainties are obtained using the square root of the summed squared
relative uncertainties of the dose rate and the water content.
A word of caution: When estimating the water content in the laboratory, the water analytical uncertainty is usually minimal, and it does not make sense to correct with a relative water content of, e.g., c(0.02,0.02) (2% +/- 2%) because this massively inflates the final dose rate error.
See vignette(doserate)
for a reproducible example.
N. Frerebeau
Aitken, M.J. (1985). Thermoluminescence dating. London: Academic Press.
Mercier, N. & Falguères, C. (2007). Field Gamma Dose-Rate Measurement with a NaI(Tl) Detector: Re-Evaluation of the "Threshold" Technique. Ancient TL, 25(1), p. 1-4.
York, D., Evensen, N. M., Martínez, M. L. & De Basabe Delgado, J. (2004). Unified Equations for the Slope, Intercept, and Standard Errors of the Best Straight Line. American Journal of Physics, 72(3), p. 367-75. doi:10.1119/1.1632486.
## Import CNF files ## Spectra spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") spc <- read(spc_dir) ## Background bkg_dir <- system.file("extdata/BDX_LaBr_1/background", package = "gamma") bkg <- read(bkg_dir) ## Get dose rate values data("clermont") (doses <- clermont[, c("gamma_dose", "gamma_error")]) ## Build the calibration curve calib_curve <- dose_fit(spc, bkg, doses, range_Ni = c(300, 2800), range_NiEi = c(165, 2800)) ## Plot the curve plot(calib_curve, threshold = "Ni") ## Estimate gamma dose rates dose_predict(calib_curve, spc)
## Import CNF files ## Spectra spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") spc <- read(spc_dir) ## Background bkg_dir <- system.file("extdata/BDX_LaBr_1/background", package = "gamma") bkg <- read(bkg_dir) ## Get dose rate values data("clermont") (doses <- clermont[, c("gamma_dose", "gamma_error")]) ## Build the calibration curve calib_curve <- dose_fit(spc, bkg, doses, range_Ni = c(300, 2800), range_NiEi = c(165, 2800)) ## Plot the curve plot(calib_curve, threshold = "Ni") ## Estimate gamma dose rates dose_predict(calib_curve, spc)
Calibrates the energy scale of a gamma spectrum.
energy_calibrate(object, lines, ...) has_energy(object) has_calibration(object) ## S4 method for signature 'GammaSpectrum,lm' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,CalibrationCurve' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,list' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,PeakPosition' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,list' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,PeakPosition' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,lm' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,GammaSpectrum' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,CalibrationCurve' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum' has_energy(object) ## S4 method for signature 'GammaSpectra' has_energy(object) ## S4 method for signature 'GammaSpectrum' has_calibration(object) ## S4 method for signature 'GammaSpectra' has_calibration(object) ## S4 method for signature 'CalibrationCurve' has_calibration(object)
energy_calibrate(object, lines, ...) has_energy(object) has_calibration(object) ## S4 method for signature 'GammaSpectrum,lm' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,CalibrationCurve' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,list' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum,PeakPosition' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,list' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,PeakPosition' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,lm' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,GammaSpectrum' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectra,CalibrationCurve' energy_calibrate(object, lines, ...) ## S4 method for signature 'GammaSpectrum' has_energy(object) ## S4 method for signature 'GammaSpectra' has_energy(object) ## S4 method for signature 'GammaSpectrum' has_calibration(object) ## S4 method for signature 'GammaSpectra' has_calibration(object) ## S4 method for signature 'CalibrationCurve' has_calibration(object)
object |
A GammaSpectrum or GammaSpectra object. |
lines |
A PeakPosition object or a |
... |
Currently not used. |
The energy calibration of a spectrum is the most tricky part. To do this, the user must specify the position of at least three observed peaks and the corresponding energy value (in keV). A second order polynomial model is fitted on these energy vs channel values, then used to predict the new energy scale of the spectrum.
The package allows to provide the channel-energy pairs to be 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.
energy_calibrate()
returns either a GammaSpectrum or a GammaSpectra
object depending on the input#
has_energy()
and has_calibration()
return a logical
vector.
N. Frerebeau
## Import a CNF file spc_file <- system.file("extdata/LaBr.TKA", package = "gamma") (spc <- read(spc_file)) ## Set peak positions (channel) and expected energy values calib_lines <- list( channel = c(86, 495, 879), energy = c(238, 1461, 2615) ) ## Adjust the energy scale (spc1 <- energy_calibrate(spc, lines = calib_lines)) ## Inspect results plot(spc1, xaxis = "energy", yaxis = "count") + ggplot2::geom_vline(xintercept = c(238, 1461, 2615), linetype = 3)
## Import a CNF file spc_file <- system.file("extdata/LaBr.TKA", package = "gamma") (spc <- read(spc_file)) ## Set peak positions (channel) and expected energy values calib_lines <- list( channel = c(86, 495, 879), energy = c(238, 1461, 2615) ) ## Adjust the energy scale (spc1 <- energy_calibrate(spc, lines = calib_lines)) ## Inspect results plot(spc1, xaxis = "energy", yaxis = "count") + ggplot2::geom_vline(xintercept = c(238, 1461, 2615), linetype = 3)
Represents a collection of spectra of gamma ray spectrometry measurements.
This class extends the base list
and can only contains
GammaSpectrum objects.
In the code snippets below, x
is a GammaSpectra
object.
length(x)
Get the number of elements in x
.
lengths(x)
Get the number of channels in each element of x
.
get_names(x)
, set_names(x) <- value
Retrieves or sets
the names of x
according to value
.
get_hash(x)
Get the MD5 hash of the raw data files.
get_channels(x)
Get the number of channels in each element of x
.
get_counts(x)
Get the counts of each element of x
.
get_energy(x)
Get the energy range of each element of x
.
get_rates(x)
Get the count rates of each element of x
.
In the code snippets below, x
is a GammaSpectra
object.
x[i]
Extracts the elements selected by subscript i
.
i
can be missing
or NULL
, numeric
or character
vector or a
factor
. Returns a new GammaSpectra
object.
x[i, j]
Like the above but allows to select a slot thru j
(see
examples). j
is a character
vector of length one. Returns a list
.
x[[i]]
Extracts the elements selected by subscript i
.
i
can be a numeric
or character
vector of length one. Returns the
corresponding GammaSpectrum object.
N. Frerebeau
Other class:
Baseline-class
,
CalibrationCurve-class
,
GammaSpectrum-class
,
PeakPosition-class
,
coerce()
## Import all CNF files in a given directory spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") (spc <- read(spc_dir)) ## Access get_hash(spc) get_names(spc) get_livetime(spc) get_realtime(spc) lengths(spc) range_energy(spc) ## Subset spc[] # All spectra spc[NULL] # All spectra spc[1] # The first spectrum spc[-6] # Delete the sixth spectrum spc[1:3] # The first three spectra spc[c(1, 3)] # The first and third spectra spc["BRIQUE"] # The spectrum named 'BRIQUE' spc[c("BRIQUE", "C347")] # The spectra named 'BRIQUE' and 'C347' spc[1:3, "energy"] # The slot 'energy' of the first three spectra spc[[1]] spc[["BRIQUE"]]
## Import all CNF files in a given directory spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") (spc <- read(spc_dir)) ## Access get_hash(spc) get_names(spc) get_livetime(spc) get_realtime(spc) lengths(spc) range_energy(spc) ## Subset spc[] # All spectra spc[NULL] # All spectra spc[1] # The first spectrum spc[-6] # Delete the sixth spectrum spc[1:3] # The first three spectra spc[c(1, 3)] # The first and third spectra spc["BRIQUE"] # The spectrum named 'BRIQUE' spc[c("BRIQUE", "C347")] # The spectra named 'BRIQUE' and 'C347' spc[1:3, "energy"] # The slot 'energy' of the first three spectra spc[[1]] spc[["BRIQUE"]]
Represents a single spectrum of a gamma ray spectrometry measurement.
hash
A character
string giving the 32-byte MD5 hash of
the imported file.
name
A character
string the measurement reference.
date
A POSIXct
element giving the measurement date and time.
instrument
A character
string giving the instrument name.
file_format
A character
string giving the format of the
imported file.
live_time
A numeric
value.
real_time
A numeric
value.
channel
A integer
vector giving the channel number.
Numeric values are coerced to integer as by as.integer()
(and hence truncated towards zero).
energy
A numeric
vector giving the gamma ray's energy (in keV).
count
A numeric
vector giving the counts number for each channel.
Numeric values are coerced to integer as by as.integer()
(and hence
truncated towards zero).
rate
A numeric
vector the count rate () for each channel.
calibration
A linear model used for energy scale
calibration (see energy_calibrate()
).
In the code snippets below, x
is a GammaSpectrum
object.
length(x)
Get number of channel in x
.
get_hash(x)
Get the MD5 hash of the raw data file.
get_names(x)
, set_names(x) <- value
Retrieves or sets
the name of x
according to value
.
get_channels(x)
Get the number of channels in x
.
get_counts(x)
Get the counts of x
.
get_energy(x)
Get the energy range of x
.
get_rates(x)
Get the count rates of x
.
In the code snippets below, x
is a GammaSpectrum
object.
as.matrix(x)
Coerces x
to a matrix
.
as.data.frame(x)
Coerces x
to a data.frame
.
In the code snippets below, x
is a GammaSpectrum
object.
x[[i]]
Extracts information from a slot selected by subscript i
.
i
is a character
vector of length one and will be matched to the name of
the slots.
This class retains copy construction.
N. Frerebeau
Other class:
Baseline-class
,
CalibrationCurve-class
,
GammaSpectra-class
,
PeakPosition-class
,
coerce()
## Import a Canberra CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") (spc <- read(spc_file)) ## Access get_hash(spc) get_names(spc) get_livetime(spc) get_realtime(spc) length(spc) range_energy(spc) ## Subset spc[["date"]] spc[["instrument"]] spc[["file_format"]]
## Import a Canberra CNF file spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") (spc <- read(spc_file)) ## Access get_hash(spc) get_names(spc) get_livetime(spc) get_realtime(spc) length(spc) range_energy(spc) ## Subset spc[["date"]] spc[["instrument"]] spc[["file_format"]]
Getters and setters to extract or replace parts of an object.
get_hash(x) get_names(x) set_names(x) <- value get_energy_calibration(x) set_energy_calibration(x) <- value get_livetime(x) get_realtime(x) get_channels(x) get_counts(x) get_rates(x) get_energy(x, ...) set_energy(x) <- value get_method(x) set_method(x) <- value get_residuals(x) range_channels(x, ...) range_energy(x, ...) ## S4 method for signature 'GammaSpectrum' length(x) ## S4 method for signature 'GammaSpectrum' get_hash(x) ## S4 method for signature 'GammaSpectrum' get_names(x) ## S4 method for signature 'GammaSpectrum' get_livetime(x) ## S4 method for signature 'GammaSpectrum' get_realtime(x) ## S4 method for signature 'GammaSpectrum' get_channels(x) ## S4 method for signature 'GammaSpectrum' get_counts(x) ## S4 method for signature 'GammaSpectrum' get_rates(x) ## S4 method for signature 'GammaSpectrum' get_energy(x) ## S4 method for signature 'GammaSpectrum' range_energy(x, na.rm = FALSE) ## S4 method for signature 'GammaSpectrum' range_channels(x, na.rm = FALSE) ## S4 method for signature 'Baseline' get_method(x) ## S4 method for signature 'GammaSpectra' get_hash(x) ## S4 method for signature 'GammaSpectra' get_names(x) ## S4 method for signature 'GammaSpectra' get_livetime(x) ## S4 method for signature 'GammaSpectra' get_realtime(x) ## S4 method for signature 'GammaSpectra' get_channels(x) ## S4 method for signature 'GammaSpectra' get_counts(x) ## S4 method for signature 'GammaSpectra' get_rates(x) ## S4 method for signature 'GammaSpectra' get_energy(x) ## S4 method for signature 'GammaSpectra' range_energy(x, na.rm = FALSE) ## S4 method for signature 'GammaSpectra' range_channels(x, na.rm = FALSE) ## S4 method for signature 'DoseRateModel' get_residuals(x) ## S4 method for signature 'PeakPosition' get_hash(x) ## S4 method for signature 'PeakPosition' get_channels(x) ## S4 method for signature 'PeakPosition' get_energy(x, expected = FALSE) ## S4 replacement method for signature 'GammaSpectrum' set_names(x) <- value ## S4 replacement method for signature 'GammaSpectrum' set_energy_calibration(x) <- value ## S4 method for signature 'GammaSpectrum' get_energy_calibration(x) ## S4 replacement method for signature 'Baseline' set_method(x) <- value ## S4 replacement method for signature 'GammaSpectra' set_names(x) <- value ## S4 replacement method for signature 'GammaSpectra' set_energy_calibration(x) <- value ## S4 method for signature 'GammaSpectra' get_energy_calibration(x) ## S4 replacement method for signature 'PeakPosition,numeric' set_energy(x) <- value
get_hash(x) get_names(x) set_names(x) <- value get_energy_calibration(x) set_energy_calibration(x) <- value get_livetime(x) get_realtime(x) get_channels(x) get_counts(x) get_rates(x) get_energy(x, ...) set_energy(x) <- value get_method(x) set_method(x) <- value get_residuals(x) range_channels(x, ...) range_energy(x, ...) ## S4 method for signature 'GammaSpectrum' length(x) ## S4 method for signature 'GammaSpectrum' get_hash(x) ## S4 method for signature 'GammaSpectrum' get_names(x) ## S4 method for signature 'GammaSpectrum' get_livetime(x) ## S4 method for signature 'GammaSpectrum' get_realtime(x) ## S4 method for signature 'GammaSpectrum' get_channels(x) ## S4 method for signature 'GammaSpectrum' get_counts(x) ## S4 method for signature 'GammaSpectrum' get_rates(x) ## S4 method for signature 'GammaSpectrum' get_energy(x) ## S4 method for signature 'GammaSpectrum' range_energy(x, na.rm = FALSE) ## S4 method for signature 'GammaSpectrum' range_channels(x, na.rm = FALSE) ## S4 method for signature 'Baseline' get_method(x) ## S4 method for signature 'GammaSpectra' get_hash(x) ## S4 method for signature 'GammaSpectra' get_names(x) ## S4 method for signature 'GammaSpectra' get_livetime(x) ## S4 method for signature 'GammaSpectra' get_realtime(x) ## S4 method for signature 'GammaSpectra' get_channels(x) ## S4 method for signature 'GammaSpectra' get_counts(x) ## S4 method for signature 'GammaSpectra' get_rates(x) ## S4 method for signature 'GammaSpectra' get_energy(x) ## S4 method for signature 'GammaSpectra' range_energy(x, na.rm = FALSE) ## S4 method for signature 'GammaSpectra' range_channels(x, na.rm = FALSE) ## S4 method for signature 'DoseRateModel' get_residuals(x) ## S4 method for signature 'PeakPosition' get_hash(x) ## S4 method for signature 'PeakPosition' get_channels(x) ## S4 method for signature 'PeakPosition' get_energy(x, expected = FALSE) ## S4 replacement method for signature 'GammaSpectrum' set_names(x) <- value ## S4 replacement method for signature 'GammaSpectrum' set_energy_calibration(x) <- value ## S4 method for signature 'GammaSpectrum' get_energy_calibration(x) ## S4 replacement method for signature 'Baseline' set_method(x) <- value ## S4 replacement method for signature 'GammaSpectra' set_names(x) <- value ## S4 replacement method for signature 'GammaSpectra' set_energy_calibration(x) <- value ## S4 method for signature 'GammaSpectra' get_energy_calibration(x) ## S4 replacement method for signature 'PeakPosition,numeric' set_energy(x) <- value
x |
An object from which to get or set element(s). |
value |
A possible value for the element(s) of |
... |
Currently not used. |
na.rm |
|
expected |
A |
An object of the same sort as x
with the new values assigned.
N. Frerebeau
Other mutator:
subset()
Performs common operations on GammaSpectrum
objects.
## S4 method for signature 'GammaSpectrum,GammaSpectrum' Arith(e1, e2) ## S4 method for signature 'GammaSpectrum,numeric' Arith(e1, e2) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' Compare(e1, e2) ## S4 method for signature 'GammaSpectrum,numeric' Compare(e1, e2) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' Logic(e1, e2) ## S4 method for signature 'GammaSpectrum,numeric' Logic(e1, e2) ## S4 method for signature 'GammaSpectrum,logical' Logic(e1, e2) ## S4 method for signature 'GammaSpectrum' Math(x) ## S4 method for signature 'GammaSpectrum' Math2(x, digits) ## S4 method for signature 'GammaSpectrum' Summary(x, ..., na.rm = FALSE)
## S4 method for signature 'GammaSpectrum,GammaSpectrum' Arith(e1, e2) ## S4 method for signature 'GammaSpectrum,numeric' Arith(e1, e2) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' Compare(e1, e2) ## S4 method for signature 'GammaSpectrum,numeric' Compare(e1, e2) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' Logic(e1, e2) ## S4 method for signature 'GammaSpectrum,numeric' Logic(e1, e2) ## S4 method for signature 'GammaSpectrum,logical' Logic(e1, e2) ## S4 method for signature 'GammaSpectrum' Math(x) ## S4 method for signature 'GammaSpectrum' Math2(x, digits) ## S4 method for signature 'GammaSpectrum' Summary(x, ..., na.rm = FALSE)
x , e1 , e2
|
An object (typically a GammaSpectrum object). |
digits |
A length-one |
... |
Further arguments passed to or from methods. |
na.rm |
A |
GammaSpectrum objects have support for S4 group generic functionality to operate within elements across objects:
Arith
"+
", "-
", "*
", "^
", "\%\%
", "\%/\%
", "/
"
Compare
"==
", ">
", "<
", "!=
", "<=
", ">=
"
Logic
"&
", "|
"
Math
"abs
", "sign
", "sqrt
", "ceiling
", "floor
",
"trunc
", "cummax
", "cummin
", "cumprod
", "cumsum
", "log
",
"log10
", "log2
", "log1p
", "acos
", "acosh
", "asin
", "asinh
",
"atan
", "atanh
", "exp
", "expm1
", "cos
", "cosh
", "cospi
",
"sin
", "sinh
", "sinpi
", "tan
", "tanh
", "tanpi
", "gamma
",
"lgamma
", "digamma
", "trigamma
"
Math2
"round
", "signif
"
Ops
"Arith
", "Compare
", "Logic
"
Summary
"min
", "max
", "range
", "prod
", "sum
", "any
",
"all
"
N. Frerebeau
## No examples
## No examples
An S4 Class to Represent a Set of Peaks
hash
A character
string giving the 32-byte MD5 hash of the imported
spectrum file.
noise_method
A character
string specifying the method used for peak
detection.
noise_threshold
A length one numeric
vector giving the noise
threshold.
window
A length one numeric
vector giving the half-window size.
channel
A integer
vector giving the channel number. Numeric values
are coerced to integer as by as.integer()
(and hence truncated towards
zero).
energy_observed
A numeric
vector giving the observed gamma ray
energy (in keV).
energy_expected
A numeric
vector giving the expected gamma ray
energy (in keV).
In the code snippets below, x
is a PeakPosition
object.
get_hash(x)
Get the MD5 hash of the raw data file.
get_channels(x)
Get the channels of x
.
get_energy(x)
, set_energy(x) <- value
Retrieves or sets
the energy scale of x
according to value
.
In the code snippets below, x
is a PeakPosition
object.
as.matrix(x)
Coerces x
to a matrix
.
as.data.frame(x)
Coerces x
to a data.frame
.
In the code snippets below, x
is a PeakPosition
object.
x[[i]]
Extracts information from a slot selected by subscript i
.
i
is a character
vector of length one and will be matched to the name of
the slots.
This class retains copy construction.
N. Frerebeau
Other class:
Baseline-class
,
CalibrationCurve-class
,
GammaSpectra-class
,
GammaSpectrum-class
,
coerce()
Finds local maxima in sequential data.
peaks_find(object, ...) ## S4 method for signature 'GammaSpectrum' peaks_find(object, method = c("MAD"), SNR = 2, span = NULL, ...)
peaks_find(object, ...) ## S4 method for signature 'GammaSpectrum' peaks_find(object, method = c("MAD"), SNR = 2, span = NULL, ...)
object |
A GammaSpectrum object. |
... |
Extra parameters to be passed to internal methods. |
method |
A |
SNR |
An |
span |
An |
A local maximum has to be the highest one in the given window and has to be
higher than to be recognized as peak.
The following methods are available for noise estimation:
MAD
Median Absolute Deviation.
A PeakPosition object.
N. Frerebeau
Other signal processing:
baseline
,
peaks_search()
,
signal_integrate()
,
signal_slice()
,
signal_split()
,
signal_stabilize()
,
smooth()
## Import a LaBr spectrum LaBr_file <- system.file("extdata/LaBr.TKA", package = "gamma") LaBr_spc <- read(LaBr_file) ## Find peaks by channel (LaBr_pks <- peaks_find(LaBr_spc)) # Ugly plot(LaBr_spc, LaBr_pks) ## Search peaks by channel (LaBr_pks <- peaks_search(LaBr_spc, index = c(86L, 207L, 496L), span = 7)) plot(LaBr_spc, LaBr_pks, split = TRUE) ## Import a BEGe spectrum BEGe_file <- system.file("extdata/BEGe.CNF", package = "gamma") BEGe_spc <- read(BEGe_file) ## Search peaks by energy (BEGe_pks <- peaks_search(BEGe_spc, index = c(47, 63, 911, 1460))) plot(BEGe_spc, BEGe_pks, split = TRUE)
## Import a LaBr spectrum LaBr_file <- system.file("extdata/LaBr.TKA", package = "gamma") LaBr_spc <- read(LaBr_file) ## Find peaks by channel (LaBr_pks <- peaks_find(LaBr_spc)) # Ugly plot(LaBr_spc, LaBr_pks) ## Search peaks by channel (LaBr_pks <- peaks_search(LaBr_spc, index = c(86L, 207L, 496L), span = 7)) plot(LaBr_spc, LaBr_pks, split = TRUE) ## Import a BEGe spectrum BEGe_file <- system.file("extdata/BEGe.CNF", package = "gamma") BEGe_spc <- read(BEGe_file) ## Search peaks by energy (BEGe_pks <- peaks_search(BEGe_spc, index = c(47, 63, 911, 1460))) plot(BEGe_spc, BEGe_pks, split = TRUE)
Search the maxima in sequential data around a given value.
peaks_search(object, index, ...) ## S4 method for signature 'GammaSpectrum,integer' peaks_search(object, index, span = 10, tolerance = 0.025) ## S4 method for signature 'GammaSpectrum,numeric' peaks_search(object, index, span = 10, tolerance = 0.025)
peaks_search(object, index, ...) ## S4 method for signature 'GammaSpectrum,integer' peaks_search(object, index, span = 10, tolerance = 0.025) ## S4 method for signature 'GammaSpectrum,numeric' peaks_search(object, index, span = 10, tolerance = 0.025)
object |
A GammaSpectrum object. |
index |
A vector giving the expected peak position.
If |
... |
Currently not used. |
span |
A |
tolerance |
A |
A PeakPosition object.
N. Frerebeau
Other signal processing:
baseline
,
peaks_find()
,
signal_integrate()
,
signal_slice()
,
signal_split()
,
signal_stabilize()
,
smooth()
## Import a LaBr spectrum LaBr_file <- system.file("extdata/LaBr.TKA", package = "gamma") LaBr_spc <- read(LaBr_file) ## Find peaks by channel (LaBr_pks <- peaks_find(LaBr_spc)) # Ugly plot(LaBr_spc, LaBr_pks) ## Search peaks by channel (LaBr_pks <- peaks_search(LaBr_spc, index = c(86L, 207L, 496L), span = 7)) plot(LaBr_spc, LaBr_pks, split = TRUE) ## Import a BEGe spectrum BEGe_file <- system.file("extdata/BEGe.CNF", package = "gamma") BEGe_spc <- read(BEGe_file) ## Search peaks by energy (BEGe_pks <- peaks_search(BEGe_spc, index = c(47, 63, 911, 1460))) plot(BEGe_spc, BEGe_pks, split = TRUE)
## Import a LaBr spectrum LaBr_file <- system.file("extdata/LaBr.TKA", package = "gamma") LaBr_spc <- read(LaBr_file) ## Find peaks by channel (LaBr_pks <- peaks_find(LaBr_spc)) # Ugly plot(LaBr_spc, LaBr_pks) ## Search peaks by channel (LaBr_pks <- peaks_search(LaBr_spc, index = c(86L, 207L, 496L), span = 7)) plot(LaBr_spc, LaBr_pks, split = TRUE) ## Import a BEGe spectrum BEGe_file <- system.file("extdata/BEGe.CNF", package = "gamma") BEGe_spc <- read(BEGe_file) ## Search peaks by energy (BEGe_pks <- peaks_search(BEGe_spc, index = c(47, 63, 911, 1460))) plot(BEGe_spc, BEGe_pks, split = TRUE)
Plot
## S4 method for signature 'GammaSpectrum,missing' plot(x, xaxis = c("channel", "energy"), yaxis = c("count", "rate"), ...) ## S4 method for signature 'GammaSpectrum,Baseline' plot(x, y, xaxis = c("channel", "energy"), yaxis = c("count", "rate"), ...) ## S4 method for signature 'GammaSpectra,missing' plot( x, xaxis = c("channel", "energy"), yaxis = c("count", "rate"), select = NULL, facet = FALSE, nrow = c("fixed", "auto") ) ## S4 method for signature 'GammaSpectrum,PeakPosition' plot(x, y, split = FALSE, span = 25) ## S4 method for signature 'CalibrationCurve,missing' plot( x, error_ellipse = TRUE, error_bar = FALSE, energy = FALSE, level = 0.95, n = 50, ... )
## S4 method for signature 'GammaSpectrum,missing' plot(x, xaxis = c("channel", "energy"), yaxis = c("count", "rate"), ...) ## S4 method for signature 'GammaSpectrum,Baseline' plot(x, y, xaxis = c("channel", "energy"), yaxis = c("count", "rate"), ...) ## S4 method for signature 'GammaSpectra,missing' plot( x, xaxis = c("channel", "energy"), yaxis = c("count", "rate"), select = NULL, facet = FALSE, nrow = c("fixed", "auto") ) ## S4 method for signature 'GammaSpectrum,PeakPosition' plot(x, y, split = FALSE, span = 25) ## S4 method for signature 'CalibrationCurve,missing' plot( x, error_ellipse = TRUE, error_bar = FALSE, energy = FALSE, level = 0.95, n = 50, ... )
x , y
|
Objects to be plotted. |
xaxis , yaxis
|
A |
... |
Currently not used. |
select |
A |
facet |
A |
nrow |
A |
split |
A |
span |
An |
error_ellipse |
A |
error_bar |
A |
energy |
A |
level |
length-one |
n |
A length-one |
A ggplot2::ggplot object.
N. Frerebeau
IsoplotR::ellipse()
, IsoplotR::isochron()
# Import CNF files spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") spc <- read(spc_dir) # Plot all spectra plot(spc, yaxis = "rate", facet = FALSE) + ggplot2::theme_bw() # Plot the spectrum named 'BRIQUE' plot(spc, xaxis = "energy", yaxis = "count", select = "BRIQUE") + ggplot2::theme_bw() # Plot the first three spectra plot(spc, xaxis = "channel", yaxis = "rate", select = 1:3, facet = TRUE) + ggplot2::theme_bw()
# Import CNF files spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") spc <- read(spc_dir) # Plot all spectra plot(spc, yaxis = "rate", facet = FALSE) + ggplot2::theme_bw() # Plot the spectrum named 'BRIQUE' plot(spc, xaxis = "energy", yaxis = "count", select = "BRIQUE") + ggplot2::theme_bw() # Plot the first three spectra plot(spc, xaxis = "channel", yaxis = "rate", select = 1:3, facet = TRUE) + ggplot2::theme_bw()
Reads a gamma ray spectrum file.
read(file, ...) ## S4 method for signature 'character' read(file, extensions = c("cnf", "tka", "spe"), ...)
read(file, ...) ## S4 method for signature 'character' read(file, extensions = c("cnf", "tka", "spe"), ...)
file |
A |
... |
Extra parameters to be passed to |
extensions |
A |
A GammaSpectra object if more than one spectrum are imported at once, else a GammaSpectrum object.
Supports Canberra CNF and TKA and Kromek SPE files.
N. Frerebeau
Other IO:
summarise()
## Import a Canberra CNF file cnf_file <- system.file("extdata/LaBr.CNF", package = "gamma") (cnf_spc <- read(cnf_file)) ## Import a TKA file tka_file <- system.file("extdata/LaBr.TKA", package = "gamma") (tka_spc <- read(tka_file)) ## Import all files in a given directory spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") (spc <- read(spc_dir))
## Import a Canberra CNF file cnf_file <- system.file("extdata/LaBr.CNF", package = "gamma") (cnf_spc <- read(cnf_file)) ## Import a TKA file tka_file <- system.file("extdata/LaBr.TKA", package = "gamma") (tka_spc <- read(tka_file)) ## Import all files in a given directory spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") (spc <- read(spc_dir))
Integration of the spectrum including uncertainty calculation.
signal_integrate(object, background, ...) ## S4 method for signature 'GammaSpectrum,missing' signal_integrate(object, range = NULL, energy = FALSE) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' signal_integrate(object, background, range = NULL, energy = FALSE) ## S4 method for signature 'GammaSpectrum,numeric' signal_integrate(object, background, range = NULL, energy = FALSE) ## S4 method for signature 'GammaSpectra,missing' signal_integrate(object, range = NULL, energy = FALSE, simplify = TRUE) ## S4 method for signature 'GammaSpectra,GammaSpectrum' signal_integrate( object, background, range = NULL, energy = FALSE, simplify = TRUE ) ## S4 method for signature 'GammaSpectra,numeric' signal_integrate( object, background, range = NULL, energy = FALSE, simplify = TRUE )
signal_integrate(object, background, ...) ## S4 method for signature 'GammaSpectrum,missing' signal_integrate(object, range = NULL, energy = FALSE) ## S4 method for signature 'GammaSpectrum,GammaSpectrum' signal_integrate(object, background, range = NULL, energy = FALSE) ## S4 method for signature 'GammaSpectrum,numeric' signal_integrate(object, background, range = NULL, energy = FALSE) ## S4 method for signature 'GammaSpectra,missing' signal_integrate(object, range = NULL, energy = FALSE, simplify = TRUE) ## S4 method for signature 'GammaSpectra,GammaSpectrum' signal_integrate( object, background, range = NULL, energy = FALSE, simplify = TRUE ) ## S4 method for signature 'GammaSpectra,numeric' signal_integrate( object, background, range = NULL, energy = FALSE, simplify = TRUE )
object |
A GammaSpectrum or GammaSpectra object. |
background |
A GammaSpectrum object. |
... |
Currently not used. |
range |
A length-two |
energy |
A |
simplify |
A |
The function supports two integration techniques (see Guérin & Mercier 2011), the (1) count threshold integration and the (2) energy integration method:
The count integration technique (energy = FALSE
) integrates
all counts in given range
:
Contrary, the energy integration techniques is the integrated cross-product of counts and corresponding energy per channel:
is the area,
is the signal in the
channel,
the number of channels,
the energy of the corresponding
channel in keV.
is the live time of the measurement in s.
For calculating the uncertainties, Poisson statistics are assumed and hence the errors is calculated as:
If simplify
is FALSE
(the default) returns a list
of numeric vectors
(the signal value and its error), else returns a matrix
.
The integration assumes that each spectrum has an energy scale.
N. Frerebeau
Guérin, G. & Mercier, M. (2011). Determining Gamma Dose Rates by Field Gamma Spectroscopy in Sedimentary Media: Results of Monte Carlo Simulations. Radiation Measurements, 46(2), p. 190-195. doi:10.1016/j.radmeas.2010.10.003.
Mercier, N. & Falguères, C. (2007). Field Gamma Dose-Rate Measurement with a NaI(Tl) Detector: Re-Evaluation of the "Threshold" Technique. Ancient TL, 25(1), p. 1-4.
Other signal processing:
baseline
,
peaks_find()
,
peaks_search()
,
signal_slice()
,
signal_split()
,
signal_stabilize()
,
smooth()
Choose channels by position.
signal_slice(object, ...) ## S4 method for signature 'GammaSpectrum' signal_slice(object, ...) ## S4 method for signature 'GammaSpectra' signal_slice(object, ...)
signal_slice(object, ...) ## S4 method for signature 'GammaSpectrum' signal_slice(object, ...) ## S4 method for signature 'GammaSpectra' signal_slice(object, ...)
object |
A GammaSpectrum or GammaSpectra object. |
... |
|
Either positive values to keep, or negative values to drop, should be provided. The values provided must be either all positive or all negative.
If no 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.
A GammaSpectrum or GammaSpectra object.
N. Frerebeau
Other signal processing:
baseline
,
peaks_find()
,
peaks_search()
,
signal_integrate()
,
signal_split()
,
signal_stabilize()
,
smooth()
## Import CNF files spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Plot spectrum plot(spc) ## Slice sliced <- signal_slice(spc) plot(sliced) sliced <- signal_slice(spc, -c(1:35)) plot(sliced) sliced <- signal_slice(sliced, 450:550) plot(sliced) ## Split g <- rep(c("A", "B", "C"), c(250, 500, 274)) splited <- signal_split(spc, g) plot(splited, facet = TRUE)
## Import CNF files spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Plot spectrum plot(spc) ## Slice sliced <- signal_slice(spc) plot(sliced) sliced <- signal_slice(spc, -c(1:35)) plot(sliced) sliced <- signal_slice(sliced, 450:550) plot(sliced) ## Split g <- rep(c("A", "B", "C"), c(250, 500, 274)) splited <- signal_split(spc, g) plot(splited, facet = TRUE)
Split
signal_split(object, ...) ## S4 method for signature 'GammaSpectrum' signal_split(object, groups)
signal_split(object, ...) ## S4 method for signature 'GammaSpectrum' signal_split(object, groups)
object |
A GammaSpectrum object. |
... |
Currently not used. |
groups |
A a |
A GammaSpectra object.
N. Frerebeau
Other signal processing:
baseline
,
peaks_find()
,
peaks_search()
,
signal_integrate()
,
signal_slice()
,
signal_stabilize()
,
smooth()
## Import CNF files spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Plot spectrum plot(spc) ## Slice sliced <- signal_slice(spc) plot(sliced) sliced <- signal_slice(spc, -c(1:35)) plot(sliced) sliced <- signal_slice(sliced, 450:550) plot(sliced) ## Split g <- rep(c("A", "B", "C"), c(250, 500, 274)) splited <- signal_split(spc, g) plot(splited, facet = TRUE)
## Import CNF files spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) ## Plot spectrum plot(spc) ## Slice sliced <- signal_slice(spc) plot(sliced) sliced <- signal_slice(spc, -c(1:35)) plot(sliced) sliced <- signal_slice(sliced, 450:550) plot(sliced) ## Split g <- rep(c("A", "B", "C"), c(250, 500, 274)) splited <- signal_split(spc, g) plot(splited, facet = TRUE)
Transform Intensities
signal_stabilize(object, ...) ## S4 method for signature 'GammaSpectrum' signal_stabilize(object, f, ...) ## S4 method for signature 'GammaSpectra' signal_stabilize(object, f, ...)
signal_stabilize(object, ...) ## S4 method for signature 'GammaSpectrum' signal_stabilize(object, f, ...) ## S4 method for signature 'GammaSpectra' signal_stabilize(object, f, ...)
object |
A GammaSpectrum object. |
... |
Extra arguments to be passed to |
f |
A |
The stabilization step aims at improving the identification of peaks with a low signal-to-noise ratio. This particularly targets higher energy peaks.
A GammaSpectrum or GammaSpectra object with transformed intensities.
N. Frerebeau
Other signal processing:
baseline
,
peaks_find()
,
peaks_search()
,
signal_integrate()
,
signal_slice()
,
signal_split()
,
smooth()
Smoothes intensities.
signal_smooth(object, ...) smooth_rectangular(object, ...) smooth_triangular(object, ...) smooth_savitzky(object, ...) ## S4 method for signature 'GammaSpectrum' signal_smooth(object, method = c("rectangular", "triangular", "savitzky"), ...) ## S4 method for signature 'GammaSpectra' signal_smooth(object, method = c("rectangular", "triangular", "savitzky"), ...) ## S4 method for signature 'GammaSpectrum' smooth_rectangular(object, m = 3, ...) ## S4 method for signature 'GammaSpectra' smooth_rectangular(object, m = 3, ...) ## S4 method for signature 'GammaSpectrum' smooth_savitzky(object, m = 3, p = 2, ...) ## S4 method for signature 'GammaSpectra' smooth_savitzky(object, m = 3, p = 2, ...) ## S4 method for signature 'GammaSpectrum' smooth_triangular(object, m = 3, ...) ## S4 method for signature 'GammaSpectra' smooth_triangular(object, m = 3, ...)
signal_smooth(object, ...) smooth_rectangular(object, ...) smooth_triangular(object, ...) smooth_savitzky(object, ...) ## S4 method for signature 'GammaSpectrum' signal_smooth(object, method = c("rectangular", "triangular", "savitzky"), ...) ## S4 method for signature 'GammaSpectra' signal_smooth(object, method = c("rectangular", "triangular", "savitzky"), ...) ## S4 method for signature 'GammaSpectrum' smooth_rectangular(object, m = 3, ...) ## S4 method for signature 'GammaSpectra' smooth_rectangular(object, m = 3, ...) ## S4 method for signature 'GammaSpectrum' smooth_savitzky(object, m = 3, p = 2, ...) ## S4 method for signature 'GammaSpectra' smooth_savitzky(object, m = 3, p = 2, ...) ## S4 method for signature 'GammaSpectrum' smooth_triangular(object, m = 3, ...) ## S4 method for signature 'GammaSpectra' smooth_triangular(object, m = 3, ...)
object |
A GammaSpectrum or GammaSpectra object. |
... |
Extra parameters to be passed to further methods. |
method |
A |
m |
An odd |
p |
An |
The following smoothing methods are available:
rectangular
Unweighted sliding-average or rectangular smooth.
It replaces each point in the signal with the average of adjacent
points.
triangular
Weighted sliding-average or triangular smooth.
It replaces each point in the signal with the weighted mean of
adjacent points.
savitzky
Savitzky-Golay filter. This method is based on the
least-squares fitting of polynomials to segments of adjacent
points.
There will be points both at the beginning and at the end
of the spectrum for which a complete
-width smooth cannot be
calculated. To prevent data loss, progressively smaller smooths are used at
the ends of the spectrum if
method
is unweighted
or weighted
. If the
Savitzky-Golay filter is used, the original points at the
ends of the spectrum are preserved.
A GammaSpectrum or GammaSpectra object.
N. Frerebeau
Gorry, P. A. (1990). General Least-Squares Smoothing and Differentiation by the Convolution (Savitzky-Golay) Method. Analytical Chemistry, 62(6), p. 570-573. doi:10.1021/ac00205a007.
Savitzky, A. & Golay, M. J. E. (1964). Smoothing and Differentiation of Data by Simplified Least Squares Procedures. Analytical Chemistry, 36(8), p. 1627-1639. doi:10.1021/ac60214a047.
Other signal processing:
baseline
,
peaks_find()
,
peaks_search()
,
signal_integrate()
,
signal_slice()
,
signal_split()
,
signal_stabilize()
# Import CNF files spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) spc <- signal_slice(spc, -c(1:35)) # Plot raw spectrum spc_clean <- signal_correct(spc) plot(spc_clean) # Rectangular smooth spc_unweighted <- smooth_rectangular(spc, m = 3) spc_unweighted_clean <- signal_correct(spc_unweighted) plot(spc_unweighted_clean) # Triangular smooth spc_weighted <- smooth_triangular(spc, m = 5) spc_weighted_clean <- signal_correct(spc_weighted) plot(spc_weighted_clean) # Savitzky–Golay spc_savitzky <- smooth_savitzky(spc, m = 21, p = 2) spc_savitzky_clean <- signal_correct(spc_savitzky) plot(spc_savitzky_clean)
# Import CNF files spc_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(spc_file) spc <- signal_slice(spc, -c(1:35)) # Plot raw spectrum spc_clean <- signal_correct(spc) plot(spc_clean) # Rectangular smooth spc_unweighted <- smooth_rectangular(spc, m = 3) spc_unweighted_clean <- signal_correct(spc_unweighted) plot(spc_unweighted_clean) # Triangular smooth spc_weighted <- smooth_triangular(spc, m = 5) spc_weighted_clean <- signal_correct(spc_weighted) plot(spc_weighted_clean) # Savitzky–Golay spc_savitzky <- smooth_savitzky(spc, m = 21, p = 2) spc_savitzky_clean <- signal_correct(spc_savitzky) plot(spc_savitzky_clean)
Operators acting on objects to extract or replace parts.
## S4 method for signature 'GammaSpectrum' x[[i]] ## S4 method for signature 'GammaSpectra' x[i, j] ## S4 method for signature 'DoseRateModel' x[[i]] ## S4 method for signature 'CalibrationCurve' x[[i]] ## S4 method for signature 'PeakPosition' x[[i]]
## S4 method for signature 'GammaSpectrum' x[[i]] ## S4 method for signature 'GammaSpectra' x[i, j] ## S4 method for signature 'DoseRateModel' x[[i]] ## S4 method for signature 'CalibrationCurve' x[[i]] ## S4 method for signature 'PeakPosition' x[[i]]
x |
An object from which to extract element(s) or in which to replace element(s). |
i , j
|
Indices specifying elements to extract or replace. Indices are
|
A subsetted object.
N. Frerebeau
Other mutator:
mutator
Summarize
summarise(object, ...) ## S4 method for signature 'GammaSpectrum' summarise(object) ## S4 method for signature 'GammaSpectra' summarise(object) ## S4 method for signature 'DoseRateModel' summarise(object) ## S4 method for signature 'CalibrationCurve' summarise(object)
summarise(object, ...) ## S4 method for signature 'GammaSpectrum' summarise(object) ## S4 method for signature 'GammaSpectra' summarise(object) ## S4 method for signature 'DoseRateModel' summarise(object) ## S4 method for signature 'CalibrationCurve' summarise(object)
object |
A GammaSpectrum or GammaSpectra object. |
... |
Currently not used. |
A data.frame
.
N. Frerebeau
Other IO:
read()
## Import a Canberra CNF file cnf_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(cnf_file) summarise(spc) ## Import all CNF files in a given directory spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") spc <- read(spc_dir) summarise(spc)
## Import a Canberra CNF file cnf_file <- system.file("extdata/LaBr.CNF", package = "gamma") spc <- read(cnf_file) summarise(spc) ## Import all CNF files in a given directory spc_dir <- system.file("extdata/BDX_LaBr_1/calibration", package = "gamma") spc <- read(spc_dir) summarise(spc)