R-Lum/Luminescence

analyse_IRSAR.RF: 'sequence_structure' argument fails

Closed this issue · 2 comments

When using another sequence_structure in my RLum.Analysis object than "NATURAL" and afterwards "REGENERATED" in some circumstances there appears an unexpected error. Here an example (tested with dev_0.8.0):

data(ExampleData.RLum.Analysis, envir = environment())

## add 3rd RF curve (copy of 1st), change 1st and 2nd, remove 3rd

IRSAR.RF.Data@records[[3]] <- IRSAR.RF.Data@records[[1]]
IRSAR.RF.Data@records[[1]] <- IRSAR.RF.Data@records[[2]]
IRSAR.RF.Data@records[[2]] <- IRSAR.RF.Data@records[[3]]
IRSAR.RF.Data@records[[3]] <- NULL

structure_RLum(IRSAR.RF.Data)
id recordType curveType protocol.step n.channels
1 RF NA NA 524
2 RF NA NA 5

So now my first element in IRSAR.RF@records is my regenerated curve and my second one the natural.

analyse_IRSAR.RF(
  object = IRSAR.RF.Data,
  sequence_structure = c("REGENERATED", "NATURAL"),
  method = "SLIDE")

Error in analyse_IRSAR.RF(object = IRSAR.RF.Data, sequence_structure = c("REGENERATED", :
[analyse_IRSAR.RF()] Number of data channels in RF_nat > RF_reg. This is not supported!

This is not the case ... Just the order was switched.

In my opinion the problem is the following code lines (593-597):

 ##check if the first curve is shorter than the first curve
 if (temp.sequence_structure[1,"n.channels"] > temp.sequence_structure[2,"n.channels"]) {
   stop(
      "[analyse_IRSAR.RF()] Number of data channels in RF_nat > RF_reg. This is not supported!"
    )

The code just checks rows 1 and 2 but afterwards (line 609) the code checks where NATURAL and REGENERATED is located. And in the example above switching the order without recognizing the argument sequence_structure will break the code.

In my case I have three RF curves, submit the argument sequence_structure= c("LAB", "NATURAL", "REGENERATED") and the calculation also fails.

Thanks and fixed.