Add check and warning for validity of (stoichiometric) food-web and taxon processes parameters
Following up on #9, while re-factoring for #8 (closed), I've came across the issue in streambugs.example.model.extended() that for no target state variable matching the food-web stoichiometric specification of taxon2, the corresponding food-web processes parameters list entry would still have input indices and default parameters values. Namely, in the:
> library(streambugs)
> model = streambugs.example.model.extended()
> y.names = model$y.names
> par = model$par
> # add Pref input change for change of input of stoichiometrically-related taxa2
> stopifnot(is.na(model$inp))
> inp <- list()
> inp[paste0(y.names$habitats[1], "_Pref")] <- list(cbind(c(0, 0), c(10, 1)))
> sys.def = streambugs::streambugs.get.sys.def(y.names, par, inp)
> sys.def$par.proc.web$`108_hab1_Chironomidae_Invertebrates`$Cons$taxa2$SusPOM
$inpinds
inpind i
[1,] 1 1
$parvals
Pref
1
$stoich
Chironomidae FPOM
statevar 5 1.0000000
coeff 1 0.1358025
but there is no state variable matching "108_hab1_Chironomidae_Invertebrates" variable and "SusPOM" taxa in its reach and habitat:
> i.y.name = which(y.names$y.names == "108_hab1_Chironomidae_Invertebrates")
> "SusPOM" %in% y.names$y.taxa[ y.names$y.reaches == y.names$y.reaches[i.y.name] & y.names$y.habitats == y.names$y.habitats[i.y.name] ]
[1] FALSE
The reason "SusPOM" is in $taxa2 is because it is in par.stoich.web where it gets from parameters specification, but it's not matched because "SusPOM" is not in taxa specification which might be issue in this model specification - see #9. However, shouldn't such taxa inconsistency be caught possibly earlier after creating food-web stoichiometric parameters from parameter names (ver 1.1)? For instance, the not matching taxa (and related parameters) could produce warnings and simply be not included in par.stoich.web (and in results also have no entires in sys.def$par.proc.web[[var.name]][[proc.name]]$taxa2 sublists).
In version 1.1 this issue is circumvented by an ifelse hack that generates empty group queries for parameter values.