0.1 Preparation

Using:

Daniel Wallach, David Makowski, James W. Jones, François Brun (2019), ‘Working with dynamic crop models: Methods, tools, and examples for agriculture and enviromnent’, Academic Press.

Model description in p. 24-28, R code example in p. 116-122. Another, possibly newer version of the R code can be found at: https://github.com/cran/ZeBook/blob/master/R/watbal.model.r

Original model from:

Woli P, Jones J W, Ingram K T and Fraisse C W (2012) ‘Agricultural Reference Index for Drought (ARID)’ Agron. J. 104-287. Online: https://www.agronomy.org/publications/aj/abstracts/104/2/287

Load functions from ‘Soil Water Balance model’ library file:

source("source/watbal.model.R")

Technical note: The ZeBook package, watbal.model.R has a bug in lines 21-25 and 58. The problem is that the code fails to extract values from the param object generated by watbal.define.param because it does not account for both dimensions of this object: (WHC, MUF, DC, z, CN) x (nominal, binf, bsup). I solve this problem by adding “typeOfParameterValue” as an argument in watbal.model that is passed also to watbal.update.

Load function to estimate reference evapotranspiration:

source("source/estimateETr.R")

< begin parentesis >

To reproduce Figure 4.5 in Wallach et al. 2006, load weather daily data and select site and year :

weather <- watbal.weather(working.year = 2008, working.site = 1)

Or following code on the book:

weather <- ZeBook::weather_FranceWest
weather <- weather[(weather$idsite == 1 & weather$WEYR == 2008),]

And skip to the steps related to the Soil Water Balance model (bellow).

< end parentesis >


We use the data downloaded at NASA´s POWER access viewer (power.larc.nasa.gov/data-access-viewer/) selecting the user community ‘Agroclimatology’ and pin-pointing the archaeological site of Rakhigarhi (Haryana, India; Lat 29.1687, Lon 76.0687) between 01/01/1984 and 31/12/2018.

We selected the ICASA Format’s parameters:


Loading data:

weather <- watbal.weather.file("data/POWER_SinglePoint_Daily_19840101_20181231_029d17N_076d70E_0bd5f9c2.csv", 
                               year = 1984:2018, linesToSkip = 17)

# convert missing data in all sky insolation (I) from -99.0 to Na
weather$I[weather$I == -99] <- NA

0.2 Reference evapotranspiration (ETr)

Estimating reference evapotranspiration using Penman-Monteith (default) and Priestley-Taylor equation:

weather$ETr <- estimateETr(weather$I, 
                           weather$T2M, weather$Tmax, weather$Tmin, 
                           weather$T2MDEW, weather$WS2M)

weather$ETr_PT <- estimateETr(weather$I, 
                              weather$T2M, weather$Tmax, weather$Tmin, 
                              weather$T2MDEW, weather$WS2M, 
                              method = "PT")

# this last version uses FAO recommedations when dealing with even less input data:
weather$ETr_fewData <- estimateETr(weather$I, 
                                   weather$T2M, weather$Tmax, weather$Tmin)

Plot comparison of methods:

plotName = "plots/SoilWaterBalanceModel_Rakhigarhi_1982-2014-ETr.png"

png(plotName, width = 1000, height = 600)

plot(weather[weather$year == 2008, "ETr"], type = 'l',
     ylab = "ETr (mm)", xlab = "day of year (2008)")
lines(weather[weather$year == 2008, "ETr_fewData"], col = "blue")
lines(weather[weather$year == 2008, "ETr_PT"], col = "red")

legend(250, 0.8 * max(weather$ETr[weather$year == 2008], na.rm = T), 
       legend = c("ETr (Penman-Monteith)", 
                  "ETr (Penman-Monteith),no wind/dew", 
                  "ETr (Priestley-Taylor)"),
       col = c("black", "blue", "red"), lty = c(1,1,1)
       )

dev.off()
## png 
##   2
knitr::include_graphics(plotName)

0.3 Soil Water Balance model

Define parameters of the model:

parameters <- watbal.define.param()
# Default values from book:
# WHC = 0.15
# MUF = 0.096
# DC = 0.55
# z = 40
# CN = 65

# input variables describing soil (from book)
soil.WP = 0.06
soil.FC = soil.WP + parameters["nominal", "WHC"]

Initialise and run the model between 1990 and 2000 (must avoid selecting years with Na values):

aWatbal <- watbal.model(parameters, 
                        weather[weather$year >= 1990 & weather$year <= 2000,], 
                        WP = soil.WP, FC = soil.FC, 
                        typeOfParValue = "nominal")

Load function for marking the end of each year:

markEndYears <- function(lengthOfData, offset = 1){
  for (i in 1:lengthOfData)
  {
    if (i %% (365 * offset) == 0)
    {
      abline(v = i, lty = 3)
    }
  }
}

Plot precipitation, ETr and model results:

# graphic output following style of Figure 4.5 in Wallach et al. 2006

plotName = "plots/SoilWaterBalanceModel_Rakhigarhi_1990-2000-plotSet.png"

png(plotName, width = 1000, height = 600)

layout(matrix(1:4, nrow = 4, ncol = 1), heights = c(1, 1, 1, 1.5))

par(mar = c(1.1, 4.1, 1.1, 0.2))

barplot(aWatbal$RAIN, 
        #xlab = "day", 
        ylab = "Rain (mm)")
markEndYears(nrow(aWatbal), offset = 1.2)
abline(v = nrow(aWatbal) + 365, lty = 3)
abline(v = nrow(aWatbal) + 2.2 * 365, lty = 3)
# not sure why, but barplot() x coordinates do not behave as in plot()

barplot(aWatbal$ETr, 
        #xlab = "day", 
        ylab = "ETr (mm)")
markEndYears(nrow(aWatbal), offset = 1.2)
abline(v = nrow(aWatbal) + 365, lty = 3)
abline(v = nrow(aWatbal) + 2.2 * 365, lty = 3)
# not sure why, but barplot() x coordinates do not behave as in plot()

plot(1:nrow(aWatbal), aWatbal$WATp * 100, 
     xlab = "",#"day", 
     ylab = "WATp (%)",
     type = "l", lwd = 2, ylim = c(0, soil.FC * 110))
abline(h = soil.FC * 100, lty = 2)
abline(h = soil.WP * 100, lty = 2)
markEndYears(nrow(aWatbal))

par(mar = c(4.1, 4.1, 1.1, 0.2))

plot(1:nrow(aWatbal), aWatbal$ARID, 
     xlab = "day", ylab = "ARID index",
     type = "l", lwd = 2, ylim = c(0, 1))
markEndYears(nrow(aWatbal))

dev.off()
## png 
##   2
knitr::include_graphics(plotName)