AgroCares/Open-Bodem-Index-Calculator

calc_waterstressindex checks wrong groundwaterclass object

BrentWHR opened this issue · 1 comments

Groundwater class (B_GWL_CLASS) passed to calc_waterstressindex is updated to more generic ones within the function before checks are performed.
# update B_GWL_CLASS to more generic ones B_GWL_CLASS.wi <- gsub("b$","", B_GWL_CLASS)
A check is performed on B_GWL_CLASS instead of the more generic B_GWL_CLASS.wi :
checkmate::assert_subset(B_GWL_CLASS, choices = c('-',unique(waterstress.obic$gt)), empty.ok = FALSE)
While B_GWL_CLASS.wi is actually used in the function:
# Collect data in a table dt <- data.table( id = 1:arg.length, B_HELP_WENR = B_HELP_WENR, B_LU_BRP = B_LU_BRP, B_GWL_CLASS = B_GWL_CLASS.wi )

The result is that passing a valid gwl class such as "GtIIb" results in an error
Either the check on B_GWL_CLASS must be extended with more options or the check should be replaced with a check on B_GWL_CLASS.wi.

is solved in branch gr_fix_management_score, merged into master in v1.0.2