@@ -112,7 +112,9 @@ getMeanPotentialCapillaryRiseRate <- function(
112112 ]
113113 )
114114
115- as.integer(estimateDaysOfGrowth(usage , yieldPower ) * kr )
115+ days_of_growth <- estimateDaysOfGrowth(usage , yieldPower )
116+
117+ as.integer(round(days_of_growth * kr ))
116118}
117119
118120# MEAN_POTENTIAL_CAPILLARY_RISE_RATES_SUMMER_MATRIX ----------------------------
@@ -152,24 +154,20 @@ MEAN_POTENTIAL_CAPILLARY_RISE_RATES_SUMMER_MATRIX <- local({
152154})
153155
154156# estimateDaysOfGrowth ---------------------------------------------------------
155- estimateDaysOfGrowth <- function (usage , yield )
157+ estimateDaysOfGrowth <- function (usage , yield , default = 50 )
156158{
159+ # Special case for agricultural use
157160 if (usage == " agricultural_L" ) {
158161 return (ifelse(yield < = 50 , 60 , 75 ))
159162 }
160163
161- if (usage == " vegetationless_D" ) {
162- return (50 )
163- }
164-
165- if (usage == " horticultural_K" ) {
166- return (100 )
167- }
168-
169- if (usage == " forested_W" ) {
170- return (90 )
171- }
164+ # Constant estimates for other uses
165+ days_of_growth <- list (
166+ vegetationless_D = 50 ,
167+ horticultural_K = 100 ,
168+ forested_W = 90
169+ )
172170
173- # default value for any other case
174- 50
171+ # Lookup constant estimate. Return default if use is not in list
172+ kwb.utils :: defaultIfNULL( days_of_growth [[ usage ]], default )
175173}
0 commit comments