knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
See De Wit et al. (2019) for details.
Python version available at ajdewit/pcse as part of the Python Crop Simulation Environment (PCSE/WOFOST).
Install with:
devtools::install_github('lucabutikofer/WofostR', build_opts = c("--no-resave-data", "--no-manual"), build_vignettes = T)
After installation is complete you can test the program with test()
.This command uses the files published by De Wit et al. downloading a copy from the WofostR_testData repository to test either a specific routine (e.g. test(component = "leafdynamics")
) or all available components if none is specified. Currently only "astro", "leafdynamics" and "potentialproduction" are implemented. Many routines are not independent funtions like in PCSE/WOFOST but are hardcoded within function Wofost()
, which is run in the "potentialproduction" and "waterlimitedproduction" tests. Passing the "potentialproduction" or "waterlimitedproduction" tests means also passing "assimilation", "astro", "leafdynamics", "partitioning", "phenology", "respiration", "rootdynamics" and "transpiration" (although transpiration is not actually used to copute potential production).
By default only three test sets are randomly chosen to perform tests on. This is done to speed up the process. To perform tests on all available sets call test(complete = TRUE)
.
library(WofostR)
test(component = 'phenology', complete = TRUE) test()
Four types of input files are required to run the Wofost():
These are S4 classes containing the variables required by function Wofost()
. Crop objects can be generated by calling dwn.crop()
or load.crop()
to download crops from the web or to load them from a local repository respectively. dwn.crop()
retrieves specific crop parameters from ajwdewit/WOFOST_crop_parameters by specifying the crop and variety names. A list of corp and varieties names can be printed with cropVarList
.
load.crop()
works in a similar way as dwn.crop()
but reads .yaml files saved in the local directory crLocal
.
cr <- dwn.crop(cropName = "sugarbeet", variety = "Sugarbeet_601") cr str(cr, list.len = 3)
Weather objects must contain minimum and maximum temperature, radiation and latitude at daily time-steps starting from the day the model expected to start. An example weather object can be seen with randomWeather
. WeatherObjects can be printed with the plot()
function.
randomWeather str(randomWeather, list.len = 3) plot(randomWeather, var = c('RAIN','TMIN'))
SoilObjects are used to compute water-limited production (Wofost(... , waterLimited = T)
) and contain soil variables for a single location. An example weather object can be seen with randomSoil
.
randomSoil
str(randomSoil)
ManagerObjects are used to run a sequence of crops simulation in succession for the same location (e.g. a crop rotation or the same crop over multiple years). An example ManagerObject can be seen with exampleManager
.
mo <- ManagerObject( cropSequence = c( 'barley-Spring_barley_301', 'millet-Millet_VanHeemst_1988', 'maize-Grain_maize_201'), sequenceStart = '2010/04/16', sequenceFinish = '2012/01/01', cropStartType = c('sowing', 'sowing', 'sowing'), cropStartDate = c(NA, '2011/04/16', NA), cropFinish = c('maturity','2011/05/16','maturity'), spacing = c(0, NA, 10 ) ) mo
Wofost crop simulation model is run by functions Wofost()
. Potential Production and Free Draining water-limited production are called by setting variable waterLimited
to FALSE
or TRUE
respectively.
# Run Potential Production outPP <- Wofost(crop = dwn.crop(), w = randomWeather) # Run Water-Limited Production outFD <- Wofost(crop = dwn.crop(), w = randomWeather, soil = randomSoil, waterLimited = TRUE) plot(outFD)
# Run crop rotation with ManagerObject outMN <- Wofost(w = randomWeatherLong, manager = exampleManager) plot(outMN, var = 'tagp')
knitr::kable(cropVarList)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.