# NOT RUN {
if(requireNamespace('hydromad')) {
# 4" water storage ~ 100mm
# AWC in mm
AWC <- 200
# monthly PET and PPT in mm
PET <- c(0,0,5,80,90,120,130,140,110,90,20,5)
PPT <- c(0, 150, 200, 120, 20, 0, 0, 0, 10, 20, 30, 60)
# run water balance
# start with soil AWC "empty"
(x.wb <- monthlyWB(AWC, PPT, PET, S_init = 0))
# plot the results
par(mar=c(4,4,2,1), bg = 'white')
plotWB(WB = x.wb, AWC = AWC)
# compute fraction of AWC filled after the last month of simulation
(last.S <- x.wb$S[12] / AWC)
# re-run the water balance with this value
(x.wb <- monthlyWB(AWC, PPT, PET, S_init = last.S))
# not much difference
par(mar=c(4,4,2,1), bg = 'white')
plotWB(WB = x.wb, AWC = AWC)
}
# }
Run the code above in your browser using DataLab