CropWat

CropWat is an R Implementation of the FAO CropWat Model.

This implements the functions describing water balance on an irrigated crop as described in FAO publications of the Irrigation and Drainage Series, namely, No. 56 “Crop Evapotranspiration - Guidelines for computing crop water requirements” and No. 33 titled”Yield response to water”.

Installation

You can install the development version of CropWat like so:

install.packages(
  'CropWat',
  repos = c('https://inrae.r-universe.dev', 'https://cloud.r-project.org')
)

Example

This is a basic example which shows you how to simulate water balance of an irrigated crop.

# Load library
library(CropWat)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

# Import example climate dataset
data(ZH_3_clim)

# Selecting year 2010-2014
meteo <- ZH_3_clim[ZH_3_clim$Date >= as.Date("2010-01-01") &
                   ZH_3_clim$Date <= as.Date("2014-12-31"), ]

# Formatting model input
cw_input <- CW_create_input("SB2023-soja",
                            DatesR = meteo$Date,
                            ETo = meteo$ETP,
                            P = meteo$Ptot,
                            soil_depth = 1.2,
                            AWC = 140)
#> Ytot set to default value (1)
#> Yini  set to Ytot
#> Ydev  set to Ytot
#> Ymid  set to Ytot
#> Yend  set to Ytot
p <- plot(cw_input)
print(p[[1]])

# Set up of the initial state of the model
X <- CW_create_state(cw_input = cw_input)

# Choose an irrigation management
# Example: Refill Soil to field capacity when soil moisture depletion is 150% of readily available water (RAW)
fun_irrig_150pc_RAW <- CW_irrig_fun_factory(RAW_ratio = 1.5, apply_Dr = TRUE)

# Simulate water balance with an irrigation management
cw_output <- CW_run_simulation(X, cw_input, FUN_IRRIG = fun_irrig_150pc_RAW)

# Plot daily outputs and yields
p <- plot(cw_output, c("daily", "yields"))
print(p[[1]])
print(p[[2]])

# Plot only yield values computed over the whole cycle
p <- plot(cw_output, c("yields"), which_yields = c("cycle_stagewise", "cycle"))
print(p[[1]])

# Yearly amount of irrigation applied (mm)
cw_output |> group_by(lubridate::year(DatesR)) |> summarise(irrig_volume = sum(Ir))
#> # A tibble: 5 × 2
#>   `lubridate::year(DatesR)` irrig_volume
#>                       <dbl>        <dbl>
#> 1                      2010        169. 
#> 2                      2011        166. 
#> 3                      2012        253. 
#> 4                      2013        169. 
#> 5                      2014         85.0