Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More coverage and typos #150

Merged
merged 12 commits into from
Aug 16, 2024
2 changes: 1 addition & 1 deletion R/Analyse_SAR.OSLdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Analyse_SAR.OSLdata <- function(
set,
dtype,
keep.SEL = FALSE,
info.measurement = "unkown measurement",
info.measurement = "unknown measurement",
output.plot = FALSE,
output.plot.single = FALSE,
cex.global = 1,
Expand Down
6 changes: 3 additions & 3 deletions R/RLum.Data.Curve-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ setAs("list", "RLum.Data.Curve",
function(from,to){

new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = NA_character_,
data = matrix(unlist(from), ncol = 2),
info = list())
Expand All @@ -124,7 +124,7 @@ setAs("data.frame", "RLum.Data.Curve",
function(from,to){

new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = NA_character_,
data = as.matrix(from),
info = list())
Expand All @@ -144,7 +144,7 @@ setAs("RLum.Data.Curve", "data.frame",
setAs("matrix", "RLum.Data.Curve",
function(from,to){
new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = NA_character_,
data = from,
info = list())
Expand Down
8 changes: 4 additions & 4 deletions R/RLum.Data.Image-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ setClass(
setAs("data.frame", "RLum.Data.Image",
function(from,to){
new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = "NA",
data = array(unlist(from), dim = c(nrow(from),ncol(from),1)),
info = list())
Expand All @@ -110,7 +110,7 @@ setAs("RLum.Data.Image", "data.frame",
setAs("matrix", "RLum.Data.Image",
function(from,to){
new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = "NA",
data = array(from, c(nrow(from), ncol(from), 1)),
info = list())
Expand All @@ -131,7 +131,7 @@ setAs("RLum.Data.Image", "matrix",
setAs("array", "RLum.Data.Image",
function(from, to){
new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = "NA",
data = from,
info = list())
Expand All @@ -149,7 +149,7 @@ setAs("list", "RLum.Data.Image",
array_list <- lapply(from, function(x) array(unlist(as.vector(x)), c(nrow(x), ncol(x), 1)))

new(to,
recordType = "unkown curve type",
recordType = "unknown curve type",
curveType = "NA",
data = array(unlist(array_list),
c(nrow(array_list[[1]]), ncol(array_list[[1]]), length(array_list))),
Expand Down
2 changes: 1 addition & 1 deletion R/Second2Gray.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Second2Gray <- function(

if(dose.rate@originator != "calc_SourceDoseRate"){

stop("[Second2Gray()] Wrong originator for dose.rate 'RLum.Results' object.")
stop("[Second2Gray()] Wrong originator for dose.rate 'RLum.Results' object.")

}else{

Expand Down
14 changes: 12 additions & 2 deletions R/analyse_Al2O3C_CrossTalk.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ analyse_Al2O3C_CrossTalk <- function(

##modify on request
if(!is.null(method_control)){
if (!is.list(method_control)) {
stop("[analyse_Al2O3C_CrossTalk()] 'method_control' is expected ",
"to be a list", call. = FALSE)
}
method_control_settings <- modifyList(x = method_control_settings, val = method_control)

}
Expand All @@ -146,6 +150,14 @@ analyse_Al2O3C_CrossTalk <- function(

##check irradiation time correction
if (!is.null(irradiation_time_correction)) {

if (!is.numeric(irradiation_time_correction) &&
!is(irradiation_time_correction, "RLum.Results")) {
stop("[analyse_Al2O3C_CrossTalk()] 'irradiation_time_correction' ",
"is expected to be a numeric value or an RLum.Results object",
call. = FALSE)
}

if (is(irradiation_time_correction, "RLum.Results")) {
if (irradiation_time_correction@originator == "analyse_Al2O3C_ITC") {
irradiation_time_correction <- get_RLum(irradiation_time_correction)
Expand All @@ -164,9 +176,7 @@ analyse_Al2O3C_CrossTalk <- function(
"[analyse_Al2O3C_CrossTalk()] The object provided for the argument 'irradiation_time_correction' was created by an unsupported function!",
call. = FALSE
)

}

}
}

Expand Down
27 changes: 8 additions & 19 deletions R/analyse_SAR.TL.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,14 @@ analyse_SAR.TL <- function(
...
){

if (missing("object")) {
stop("[analyse_SAR.TL()] No value set for 'object'!", call. = FALSE)
}

# Self-call -----------------------------------------------------------------------------------
if(inherits(object, "list")){
if(!all(sapply(object, class) == "RLum.Analysis"))
stop("[analyse_SAR.TL()] All elements in the input list need to be of class 'RLum.Analysis'!",
stop("[analyse_SAR.TL()] All elements in the input list must be of class 'RLum.Analysis'!",
call. = FALSE)

##run sequence
Expand Down Expand Up @@ -160,13 +163,7 @@ analyse_SAR.TL <- function(
##=============================================================================#
# General Integrity Checks ---------------------------------------------------

##GENERAL

##MISSING INPUT
if(missing("object")==TRUE){
stop("[analyse_SAR.TL()] No value set for 'object'!", call. = FALSE)
}

if(missing("signal.integral.min") == TRUE){
stop("[analyse_SAR.TL()] No value set for 'signal.integral.min'!", call. = FALSE)
}
Expand Down Expand Up @@ -321,9 +318,7 @@ analyse_SAR.TL <- function(
LnLxTnTx[,"Name"]<-as.character(LnLxTnTx[,"Name"])

# Calculate Recycling Ratio -----------------------------------------------

##Calculate Recycling Ratio

RecyclingRatio <- NA
if(length(LnLxTnTx[LnLxTnTx[,"Repeated"]==TRUE,"Repeated"])>0){

##identify repeated doses
Expand Down Expand Up @@ -351,19 +346,14 @@ analyse_SAR.TL <- function(
##Just transform the matrix and add column names
RecyclingRatio<-t(RecyclingRatio)
colnames(RecyclingRatio)<-temp.ColNames

}else{RecyclingRatio<-NA}

}

# Calculate Recuperation Rate ---------------------------------------------


##Recuperation Rate
Recuperation <- NA
if("R0" %in% LnLxTnTx[,"Name"]==TRUE){
Recuperation<-round(LnLxTnTx[LnLxTnTx[,"Name"]=="R0","LxTx"]/
LnLxTnTx[LnLxTnTx[,"Name"]=="Natural","LxTx"],digits=4)
}else{Recuperation<-NA}

}

# Combine and Evaluate Rejection Criteria ---------------------------------

Expand Down Expand Up @@ -702,4 +692,3 @@ analyse_SAR.TL <- function(
return(newRLumResults.analyse_SAR.TL)

}

36 changes: 17 additions & 19 deletions R/analyse_pIRIRSequence.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ analyse_pIRIRSequence <- function(
...
){

if (missing("object")) {
stop("[analyse_pIRIRSequence()] No value set for 'object'!")
}

# SELF CALL -----------------------------------------------------------------------------------
if(is.list(object)){

Expand Down Expand Up @@ -267,14 +271,10 @@ analyse_pIRIRSequence <- function(

##GENERAL

##MISSING INPUT
if(missing("object")==TRUE){
stop("[analyse_pIRIRSequence()] No value set for 'object'!")
}

##INPUT OBJECTS
if(is(object, "RLum.Analysis")==FALSE){
stop("[analyse_pIRIRSequence()] Input object is not of type 'RLum.Analyis'!")
stop("[analyse_pIRIRSequence()] Input object is not of type 'RLum.Analyis'!",
call. = FALSE)
}

##CHECK ALLOWED VALUES IN SEQUENCE STRUCTURE
Expand All @@ -293,20 +293,18 @@ analyse_pIRIRSequence <- function(

# Deal with extra arguments -------------------------------------------------------------------

## default values
mtext.outer <- "MEASUREMENT INFO"
main <- ""
log <- ""
cex <- 0.7

##deal with addition arguments
extraArgs <- list(...)

mtext.outer <- if("mtext.outer" %in% names(extraArgs)) {extraArgs$mtext.outer} else
{"MEASUREMENT INFO"}

main <- if("main" %in% names(extraArgs)) {extraArgs$main} else
{""}

log <- if("log" %in% names(extraArgs)) {extraArgs$log} else
{""}

cex <- if("cex" %in% names(extraArgs)) {extraArgs$cex} else
{.7}
mtext.outer <- if ("mtext.outer" %in% names(extraArgs)) extraArgs$mtext.outer
main <- if ("main" %in% names(extraArgs)) extraArgs$main
log <- if ("log" %in% names(extraArgs)) extraArgs$log
cex <- if ("cex" %in% names(extraArgs)) extraArgs$cex


# Protocol Integrity Checks --------------------------------------------------
Expand Down Expand Up @@ -526,7 +524,7 @@ analyse_pIRIRSequence <- function(
temp.signal.integral.min <- signal.integral.min[i]
temp.signal.integral.max <- signal.integral.max[i]
temp.background.integral.min <- background.integral.min[i]
temp.backbround.integral.max <- background.integral.max[i]
temp.background.integral.max <- background.integral.max[i]

}else{

Expand Down
11 changes: 2 additions & 9 deletions R/apply_CosmicRayRemoval.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' @param object [RLum.Data.Spectrum-class] or [RLum.Analysis-class] (**required**): input
#' object to be treated. This can be also provided as [list]. If an [RLum.Analysis-class] object
#' is provided, only the [RLum.Data.Spectrum-class] objects are treated. Please note: this mixing of
#' objects do not work for a list of `RLum.Data` objects.
#' objects does not work for a list of `RLum.Data` objects.
#'
#' @param method [character] (*with default*):
#' Defines method that is applied for cosmic ray removal. Allowed methods are
Expand Down Expand Up @@ -334,14 +334,7 @@ apply_CosmicRayRemoval <- function(
mtext(side = 3, paste0("Frame: ", x, " (",
colnames(object.data.temp)[x],
") - no threshold applied!"))



}




}

##(9) - return information on the amount of removed cosmic-rays
Expand All @@ -366,7 +359,7 @@ apply_CosmicRayRemoval <- function(

}else{

stop("[apply_CosmicRayRemoval()] Unkown method for cosmic ray removal.")
stop("[apply_CosmicRayRemoval()] Unknown method for cosmic ray removal.")

}

Expand Down
13 changes: 6 additions & 7 deletions R/calc_CosmicDoseRate.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,18 @@ calc_CosmicDoseRate<- function(
##============================================================================##

if(any(depth < 0) || any(density < 0)) {
cat(paste("\nNo negative values allowed for depth and density"))
stop(domain=NA)
stop("[calc_CosmicDoseRate()] No negative values allowed for ",
"depth and density", call. = FALSE)
}

if(corr.fieldChanges == TRUE) {
if(is.na(est.age) == TRUE) {
cat(paste("\nCorrection for geomagnetic field changes requires",
"an age estimate."), fill = FALSE)
stop(domain=NA)
stop("[calc_CosmicDoseRate()] Correction for geomagnetic field ",
"changes requires an age estimate.", call. = FALSE)
}
if(est.age > 80) {
cat(paste("\nCAUTION: No geomagnetic field change correction for samples",
"older >80 ka possible!"), fill = FALSE)
cat("\nCAUTION: No geomagnetic field change correction for samples",
"older >80 ka possible!")
corr.fieldChanges<- FALSE
}
}
Expand Down
13 changes: 5 additions & 8 deletions R/calc_FadingCorr.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ calc_FadingCorr <- function(
g_value <- as.numeric(get_RLum(g_value)[,c("FIT", "SD")])

}else{
try({
stop("[calc_FadingCorr()] Unknown originator for the provided RLum.Results object via 'g_value'!",
call. = FALSE)

})
message("[calc_FadingCorr()] Error: Unknown originator for the ",
"provided RLum.Results object via 'g_value'!")
return(NULL)
}
}
Expand Down Expand Up @@ -350,11 +347,11 @@ calc_FadingCorr <- function(

##otherwise the automatic error value finding
##will never work
res <- NA
if(!is(temp,"try-error") && temp$root<1e8) {
return(temp$root)
} else{
return(NA)
res <- temp$root
}
return(res)

}, FUN.VALUE = 1))

Expand Down
2 changes: 1 addition & 1 deletion R/calc_FuchsLang2001.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' **Basic steps of the approach**
#'
#' 1. Estimate natural relative variation of the sample using a dose recovery test
#' 2. Sort the input values ascendantly
#' 2. Sort the input values in ascending order
#' 3. Calculate a running mean, starting with the lowermost two values and add values iteratively.
#' 4. Stop if the calculated `c[v]` exceeds the specified `cvThreshold`
#'
Expand Down
4 changes: 2 additions & 2 deletions R/internals_RLum.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
#+ .smoothing() +
#+++++++++++++++++++++

#' Allows smmoothing of data based on the function zoo::rollmean
#' Allows smoothing of data based on the function zoo::rollmean
#'
#' The function just allows a direct and meaningfull access to the functionality of the zoo::rollmean()
#' The function just allows a direct and meaningful access to the functionality of the zoo::rollmean()
#' function. Arguments of the function are only partly valid.
#'
#' @param x [numeric] (**required**):
Expand Down
13 changes: 4 additions & 9 deletions R/merge_Risoe.BINfileData.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,17 @@ merge_Risoe.BINfileData <- function(

# Integrity Checks --------------------------------------------------------
if(length(input.objects) < 2){
message("[merge_Risoe.BINfileData()] Nothing done at least two input objects are needed!")
message("[merge_Risoe.BINfileData()] Nothing done: at least two input objects are needed!")
return(input.objects)

}

if(is(input.objects, "character") == TRUE){
for(i in 1:length(input.objects)){
if(file.exists(input.objects[i])==FALSE){
stop("[merge_Risoe.BINfileData()] File ",input.objects[i]," does not exist!", call. = FALSE)

stop("[merge_Risoe.BINfileData()] File '", input.objects[i],
"' does not exist!", call. = FALSE)
}

}

}else{
Expand All @@ -114,12 +113,8 @@ merge_Risoe.BINfileData <- function(
}

}else{

stop("[merge_Risoe.BINfileData()]
Input object is not a 'character' nor a 'list'!")

stop("[merge_Risoe.BINfileData()] Input object is neither a character nor a list!")
}

}


Expand Down
Loading