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

Bug in C4 calculation #15

Open
davidorme opened this issue Jun 22, 2021 · 0 comments
Open

Bug in C4 calculation #15

davidorme opened this issue Jun 22, 2021 · 0 comments

Comments

@davidorme
Copy link
Contributor

davidorme commented Jun 22, 2021

There is a problem with the test for assimilation == GPP when using C4=TRUE:

> ret <- rpmodel(tc = 20, vpd = 1000, co2 = 400, ppfd = 30, elv = 0, c4=TRUE, fapar=1)
Error in rpmodel(tc = 20, vpd = 1000, co2 = 400, ppfd = 30, elv = 0, c4 = TRUE,  : 
  rpmodel(): Assimilation and GPP are not identical.
> ret <- rpmodel(tc = 20, vpd = 1000, co2 = 400, ppfd = 30, elv = 0, c4=FALSE, fapar=1)
>

The lines are:

    assim <- ifelse(a_j < a_c, a_j, a_c)
    if (any(abs(assim - gpp/c_molmass) > 0.001)) 
        stop("rpmodel(): Assimilation and GPP are not identical.")

I can't immediately see what is wrong - it isn't NA issues as in #11 and the values genuinely are unequal. Having said that, I think all.equal is more robust here as well.

Also - the first line there creating assim: the previous code has just tested that a_j == a_c, so presumably a_j or a_c could be used directly rather than going to the computational expense of combining them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant