Shiny-kc-ClimaticCorrection

Introduction & context

The ASCROM crop model has a main factor driving the plant developmnent dynamic : Kcb (Basal crop coefficient, provided by the ClimaticWaterDemand atomic model)

References: “Crop evapotranspiration - Guidelines for computing crop water requirements - FAO Irrigation and drainage paper 56” - See documentation http://www.fao.org/3/X0490E/X0490E00.htm#Contents

The ClimaticWaterDemand atomic model use a kcb_interp daily input value to compute Kcb (with a crop failure process).

This daily input is generated by an another atomic model (Interpolate from vle.discrete-time.generic package: a generic linear interpolator). There a single crop kcb dynamics is defined with a parametric approach using 7 sets of date/value pairs (built around 3 reference values for kc : KC_ini, KC_mid, KC_end)

Example of 7 sets of pairs defining a crop
date kc
59 (T_ini_1 -1) 0
60 (T_ini_1) 0.3 (KC_ini)
69 (T_ini_2) 0.3 (KC_ini)
74 (T_mid_1) 1.1 (KC_mid)
79 (T_mid_2) 1.1 (KC_mid)
89 (T_end) 0.6 (KC_end)
90 (T_end + 1) 0

On top of that in order to take into account a climatic effect on KC values we use the following correction equation to alter the KC_mid, KC_end values (leaving all dates unchanged) (http://www.fao.org/3/X0490E/x0490e0c.htm#basal%20crop%20coefficient%20(kcb)) :

\[ kc\_climate\_correction = \left\{ \begin{array}{@{}ll@{}} kc, & \text{if}\ kc < 0.45 \\ kc + (\frac{u2\_mean-2.}{25}-\frac{RHmin\_mean-45.}{250})*(\frac{h}{3})^{0.3}, & \text{otherwise} \\ \end{array}\right. \]
with
u2_mean : a mean wind speed value (in m.s-1)
RHmin_mean : a mean relative air humidity value (in %)
h : plant max height (in m)

The periods used for computing u2_mean and RHmin_mean values from climate daily values are :


Climatic Correction for kc parameters of ASCROM

pander::pandoc.table(unlist_pairs(.kc_climate_correction(KC_FUN_noCC$KC_PARAMS, weatherdata, DEBUT_SIMULATION,h)$pairs))
date kc
59 0
60 0.3
69 0.3
74 1.148
79 1.148
89 0.6457
90 0
91 0
92 0.4
101 0.4
106 1.209
111 1.209
121 0.7125
122 0
.kc_climate_correction
#> function (XX_params, weatherdata, debut_sim, h, dbgLog = FALSE) 
#> {
#>     XX_params_new <- XX_params
#>     weatherdates <- chron(paste(weatherdata$annee, weatherdata$mois, 
#>         weatherdata$jour, sep = "-"), format = c(dates = "y-m-d"))
#>     date_debut <- chron(debut_sim, format = c(dates = "y-m-d"))
#>     stage_dates <- date_debut + as.integer(sapply(XX_params$pairs, 
#>         function(x) {
#>             x$date
#>         })) - 1
#>     kc_periods <- data.frame(start = stage_dates[c(FALSE, FALSE, 
#>         FALSE, TRUE, TRUE, FALSE, FALSE)], end = stage_dates[c(FALSE, 
#>         FALSE, FALSE, FALSE, TRUE, TRUE, FALSE)])
#>     RHmin_mean <- sapply(1:nrow(kc_periods), function(i) {
#>         mean(weatherdata$RHmin[(weatherdates >= kc_periods$start[i]) & 
#>             (weatherdates <= kc_periods$end[i])])
#>     })
#>     u2_mean <- sapply(1:nrow(kc_periods), function(i) {
#>         mean(weatherdata$u2[(weatherdates >= kc_periods$start[i]) & 
#>             (weatherdates <= kc_periods$end[i])])
#>     })
#>     kc_values <- sapply(XX_params$pairs, function(x) {
#>         x$kcb
#>     })[c(FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE)]
#>     kc_corrected_values <- kc_values
#>     index_to_correct <- (kc_values > 0.45)
#>     kc_corrected_values[index_to_correct] <- .kc_climate_correction_eq(kc = kc_values[index_to_correct], 
#>         u2_mean = u2_mean[index_to_correct], RHmin_mean = RHmin_mean[index_to_correct], 
#>         h = rep(h, each = 2)[index_to_correct], dbgLog)
#>     for (idseq_index in 1:(length(kc_corrected_values)%/%2)) {
#>         pairs_current_start_index <- (idseq_index - 1) * 7
#>         kcc_current_start_index <- (idseq_index - 1) * 2
#>         XX_params_new$pairs[[pairs_current_start_index + 4]]$kcb <- kc_corrected_values[kcc_current_start_index + 
#>             1]
#>         XX_params_new$pairs[[pairs_current_start_index + 5]]$kcb <- kc_corrected_values[kcc_current_start_index + 
#>             1]
#>         XX_params_new$pairs[[pairs_current_start_index + 6]]$kcb <- kc_corrected_values[kcc_current_start_index + 
#>             2]
#>     }
#>     return(XX_params_new)
#> }
#> <bytecode: 0x560da405c1d0>

.kc_climate_correction_eq
#> function (kc, u2_mean, RHmin_mean, h, dbgLog = FALSE) 
#> {
#>     kc_corrected <- kc + (0.04 * (u2_mean - 2) - 0.004 * (RHmin_mean - 
#>         45)) * (h/3)^0.3
#>     if (dbgLog) 
#>         cat(file = stderr(), "\tkc: ", kc, "\n\tu2_mean:", u2_mean, 
#>             "\n\tRHmin_mean:", RHmin_mean, "\n\th:", h, "\n\t\t->", 
#>             kc_corrected, "\n")
#>     return(kc_corrected)
#> }
#> <bytecode: 0x560da5b30ae8>
date kc kc_CC
59 0 0
60 0.3 0.3
69 0.3 0.3
74 1.1 1.148
79 1.1 1.148
89 0.6 0.6457
90 0 0
91 0 0
92 0.4 0.4
101 0.4 0.4
106 1.2 1.209
111 1.2 1.209
121 0.7 0.7125
122 0 0
stage_dates (continued below)
2456717 2456718 2456727 2456732 2456737 2456747 2456748 2456749
2456750 2456759 2456764 2456769 2456779 2456780
kc_periods
start end
2456718 2456727
2456732 2456737
2456737 2456747
2456750 2456759
2456764 2456769
2456769 2456779
RHmin_mean
39.6 19 20.32 28.9 34.83 33.32
u2_mean
0.7702 0.7512 0.8219 1.448 1.228 1.186
index_to_correct
TRUE TRUE TRUE TRUE TRUE TRUE