EarthSystemDiagnostics / TrenchR

An R package to analyse and plot trench-like proxy records
Other
0 stars 0 forks source link

Uninformative warning when estimated autocorrelation is < 0 #12

Open thomas-muench opened 1 month ago

thomas-muench commented 1 month ago

When it happens that the lag-1 autocorrelation (either horizontal or vertical) estimated within estimateTrenchDecorrelation() is < 0, the user gets an uninformative warning produced from taking the log of a negative number when attempting to calculate the corresponding decorrelation length.

Rather, the code should set the decorrelation length to NA when the a1 is < 0, to that the output decorrelation length is also NA, together with a warning why it is NA.

The current behaviour can be reproduced with the T15 trench2 data in the package:

x <- dplyr::filter(t15.trench2, depth <= 175.5)
estimateTrenchDecorrelation(x)

where, by chance, this depth subset of the trench data produces a negative a1 in horizontal direction.

thomas-muench commented 1 month ago

decorrelation length should be NA when a1 is <= 0.