Skip to content

Commit 03e94fc

Browse files
authored
Merge pull request #397 from R-Lum/issue_396
Consider also VSLIDE when preparing some arguments for method = SLIDE [skip ci]
2 parents 38070b9 + d09edc4 commit 03e94fc

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

NEWS.Rmd

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ above, the function now only accepts CSV files as input (#237, fixed in #270).
5151
### `analyse_IRSAR.RF()`
5252
* The function is more robust against `sequence_structure` misspecifications
5353
(#393, fixed in #394).
54+
* Some data preparation steps where not correctly applied for `method = VSLIDE`
55+
(#396, fixed in #397).
5456

5557
### `analyse_pIRIRSequence()`
5658
* The function crashed with a object merge error if run in a loop because of a `merge_RLum()` error. This

R/analyse_IRSAR.RF.R

+5-11
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ analyse_IRSAR.RF<- function(
533533
##check whether both curve have the same length, in this case we cannot proceed (sliding
534534
##is not allowed)
535535
if(length(unique(temp.sequence_structure[["x.max"]])) == 1 &&
536-
method == "SLIDE" &&
536+
grepl("SLIDE", method) &&
537537
(is.null(RF_nat.lim) & is.null(RF_reg.lim))) {
538538
.throw_error("There is no further sliding space left. All curves have ",
539539
"the same length and no limitation was set")
@@ -724,27 +724,24 @@ analyse_IRSAR.RF<- function(
724724
temp.sequence_structure[temp.sequence_structure$protocol.step=="REGENERATED","id"]]]@data)
725725

726726
##correct of the onset of detection by using the first time value
727-
if (method == "SLIDE" &
727+
if (grepl("SLIDE", method) &&
728728
method.control.settings$correct_onset == TRUE) {
729729
RF_reg[,1] <- RF_reg[,1] - RF_reg[1,1]
730730
}
731731

732-
733732
RF_reg.x <- RF_reg[RF_reg.lim[1]:RF_reg.lim[2],1]
734733
RF_reg.y <- RF_reg[RF_reg.lim[1]:RF_reg.lim[2],2]
735734

736-
737735
##grep values from natural signal
738736
RF_nat <- as.data.frame(object@records[[
739737
temp.sequence_structure[temp.sequence_structure$protocol.step=="NATURAL","id"]]]@data)
740738

741-
##correct of the onset of detection by using the first time value
742-
if (method == "SLIDE" &
739+
## correct the onset of detection by using the first time value
740+
if (grepl("SLIDE", method) &&
743741
method.control.settings$correct_onset == TRUE) {
744742
RF_nat[,1] <- RF_nat[,1] - RF_nat[1,1]
745743
}
746744

747-
748745
##limit values to fit range (at least to the minimum)
749746
RF_nat.limited<- RF_nat[min(RF_nat.lim):max(RF_nat.lim),]
750747

@@ -766,7 +763,7 @@ analyse_IRSAR.RF<- function(
766763
-lambda * x
767764
)) ^ beta)))
768765

769-
##stretched expontial function according to Erfurt et al. (2003)
766+
## stretched exponential function according to Erfurt et al. (2003)
770767
## + phi.0 >> initial IR-RF flux
771768
## + delta.phi >> dose dependent change of the IR-RF flux
772769
## + lambda >> exponential parameter
@@ -960,9 +957,6 @@ analyse_IRSAR.RF<- function(
960957

961958
##(1) calculate sum of residual squares using internal Rcpp function
962959

963-
#pre-allocate object
964-
temp.sum.residuals <- vector("numeric", length = t_max.id - t_max_nat.id)
965-
966960
##initialise slide range for specific conditions, namely NULL and "auto"
967961
if (is.null(vslide_range)) {
968962
vslide_range <- 0

tests/testthat/_snaps/analyse_IRSAR.RF.md

+10-10
Large diffs are not rendered by default.

tests/testthat/test_analyse_IRSAR.RF.R

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ test_that("input validation", {
4848
"'RF_reg.lim' defines too short an interval, reset to")
4949
)
5050

51+
## curves of the same length
52+
expect_error(analyse_IRSAR.RF(set_RLum("RLum.Analysis",
53+
records = list(IRSAR.RF.Data[[1]],
54+
IRSAR.RF.Data[[1]])),
55+
method = "VSLIDE"),
56+
"There is no further sliding space left")
57+
5158
SW({
5259
expect_warning(analyse_IRSAR.RF(IRSAR.RF.Data,
5360
method.control = list(unknown = "test")),
@@ -153,7 +160,7 @@ test_that("test edge cases", {
153160

154161
SW({
155162
expect_warning(expect_s4_class(analyse_IRSAR.RF(
156-
object,
163+
list(object),
157164
method = "SLIDE",
158165
method.control = list(vslide_range = 'auto', correct_onset = FALSE,
159166
show_fit = TRUE, trace = TRUE, n.MC = 2,

0 commit comments

Comments
 (0)