Description Usage Arguments Details Value Note Examples
View source: R/input_handler.R
Data preparation function
1 2 | input_handler(input_key = "ZA", ybetas, code, ybeta_update,
exist_list = NULL, silent = TRUE)
|
input_key |
Two letter country/location code (but possibly arbitrary) indicating input data to load. |
ybetas |
list of either 2 rasters or 2 vectors providing yield modifications for climate & irrigation. |
code |
Unique simulation code. |
ybeta_update |
1 or 0; determines whether yield_mod_* is run or not. |
exist_list |
Default is NULL, other an existing list of processed inputs |
silent |
Hide or show print statements describing processing steps (TRUE [default] or FALSE) |
input |
"D" or "R". "D" runs the (faster) data.table version of the model, "R" the raster version. |
This function reads in the necessary raster or data.table inputs for tradeoff_mod, but will pass through an existing list if they are provided in exist_list. Yield modifications and standardizations are performed when ybeta_update = 1 and/or exist_list = NULL. In exist_list is NULL, then the full routine will always be run.
List of input variables for model
It is currently used internally by tradeoff_mod, but could well be pulled outside of it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | load("data/cropnames.rda")
rc <- run_code(input_key = "ZA")
dfact <- c(0.9, 1.2)
ybetas <- lapply(1:2, function(x) {
m <- brick("external/ext_data/ZA-crop-areas.tif")
r <- m
r <- setValues(r, values = rnorm(n = ncell(r) * nlayers(r), mean = dfact[x],
sd = 0.05))
nm_up(mask(r, m, maskvalue = 0), cropnames)
})
input_handler(input_key = "ZA", ybetas = ybetas, code = rc,
ybeta_update = 1)
il <- fetch_inputs(input_key = "ZA") #' fetch all necessary inputs
input_handler(input_key = "ZA", ybetas = ybetas, code = rc,
ybeta_update = 0, exist_list = il)
input_handler(input_key = "ZA", ybetas = ybetas, code = rc,
ybeta_update = 0, exist_list = il[-1])
input_handler(input_key = "ZA", ybetas = ybetas, code = rc,
ybeta_update = 1, exist_list = il)
input_handler(input_key = "ZA", ybetas = list(1, 1), code = rc,
ybeta_update = 1, exist_list = il)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.