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

calc_FadingCorr() doesn't check length of inputs #599

Closed
mcol opened this issue Mar 6, 2025 · 1 comment · Fixed by #600
Closed

calc_FadingCorr() doesn't check length of inputs #599

mcol opened this issue Mar 6, 2025 · 1 comment · Fixed by #600
Labels
bug (potentially) Is seems like a bug, but it's unclear what real effect it may have
Milestone

Comments

@mcol
Copy link
Contributor

mcol commented Mar 6, 2025

The age.faded and g_value parameters are expected to be of length 2, but this is not enforced. This leads to warnings and NAs in the results:

calc_FadingCorr(age.faded = 0.1, g_value = 5.0,
                tc = 2592000,  tc.g_value = 172800, n.MC = 10, seed = 1)
 >> Fading correction according to Huntley & Lamothe (2001)
 >> g-value re-calculated for the given tc

 .. used g-value:	5.312 ± NA %/decade
 .. used tc:		8.214e-05 ka
 .. used kappa:		0.0231 ± NA
 ----------------------------------------------
 seed: 			1
 n.MC: 			10
 observations: 		0
 ----------------------------------------------
 Age (faded):		0.1 ka ± NA ka
 Age (corr.):		0.1169 ka ± NA ka
 ----------------------------------------------

 [RLum.Results-class]
	 originator: calc_FadingCorr()
	 data: 2
 	 .. $age.corr : data.frame
	 .. $age.corr.MC : numeric
	 additional info elements:  1
Warning messages:
1: In rnorm(n.MC.i, mean = g_value[1], sd = g_value[2]) : NAs produced
2: In rnorm(n.MC.i, mean = age.faded[1], sd = age.faded[2]) : NAs produced
@mcol mcol added the bug (potentially) Is seems like a bug, but it's unclear what real effect it may have label Mar 6, 2025
@mcol mcol added this to the v1.0.1 milestone Mar 6, 2025
@mcol
Copy link
Contributor Author

mcol commented Mar 6, 2025

If tc or tc.g_value is given a negative input, the following unhelpful message is given:

calc_FadingCorr(age.faded = c(1, 0), g_value = c(5, 1), tc = -2592000)

# [calc_FadingCorr()] Error: No solution found, NULL returned: this usually happens for very large,
#   unrealistic g-values, please consider another model for the fading correction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (potentially) Is seems like a bug, but it's unclear what real effect it may have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant