constraints_r: Establishes per pixel probability of fields being converted...

Description Usage Arguments Details Value Examples

View source: R/constraints_r.R

Description

This function determines the per pixel probability of a field being converted for a crop as a function of that crop's yield, as well as any constraints related to carbon, biodiversity, and travel costs, factoring in any prior yield modifications made (e.g. due to climate change or added irrigation)

Usage

1
constraints_r(inlist, cbetas, code, cropnames, ctype = "X", silent = TRUE)

Arguments

inlist

A list of the four constraint Raster*s

cbetas

4 element vector with values 0-1 for land use weights

code

Unique simulation code resulting from run_code function

cropnames

Vector of crop names in analysis

ctype

Specific multiplicative ("X") or additive ("+") constraints

silent

Silent or verbose mode (TRUE [default] or FALSE)

Details

For inlist, the input should be a named list, with the first element named "y_std, then "C", "bd", and "cost".

Value

Brick of conversion probabilities for each crop

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
rc <- run_code(input_key = "ZA")
#code <- rc
il <- fetch_inputs(input_key = "ZA")  # fetch all necessary inputs
ybetas <- list(1, 1)
ybeta <- yield_mod_r(inlist = il[c("p_yield", "pp_curr")], ybetas = ybetas,
                     code = rc, cropnames = il$cropnames)
cbetas <- c("y_std" = 0, "C" = 1, "bd" = 1, "cost" = 1)
clist <- list("y_std" = ybeta$y_std, "C" = il$carbon_p, "bd" = il$cons_p,
              "cost" = il$cost)
p_y <- constraints_r(inlist = clist, cbetas = cbetas, code = rc,
                     cropnames = il$cropnames)
plot(p_y - Reduce("*", clist[2:4]))

cbetas <- c("y_std" = 0, "C" = 0, "bd" = 0, "cost" = 0)
p_y <- constraints_r(inlist = clist, cbetas = cbetas, code = rc,
                     cropnames = il$cropnames)
plot(p_y - clist$y_std)

cbetas <- c("y_std" = 0, "C" = 0.5, "bd" = 0, "cost" = 0)
p_y <- constraints_r(inlist = clist, cbetas = cbetas, code = rc,
                     cropnames = il$cropnames)
plot(clist$C * 0.5) - p_y$maize

cbetas <- c("y_std" = 1, "C" = 0.5, "bd" = 0, "cost" = 0)
p_y <- constraints_r(inlist = clist, cbetas = cbetas, code = rc,
                     cropnames = il$cropnames)
plot(p_y - (clist$y_std * clist$C * 0.5))

cbetas <- c("y_std" = 1, "C" = 1, "bd" = 0, "cost" = 1)
p_y <- constraints_r(inlist = clist, cbetas = cbetas, code = rc,
                     cropnames = il$cropnames)
plot(p_y - (clist$y_std * clist$C * clist$cost))

cbetas <- c("y_std" = 0, "C" = 1, "bd" = 0.5, "cost" = 1)
p_y <- constraints_r(inlist = clist, cbetas = cbetas, code = rc,
                     cropnames = il$cropnames)
plot(p_y - (clist$C * clist$bd * 0.5 * clist$cost))

marcusspiegel/agroEcoTradeoff documentation built on May 21, 2019, 11:44 a.m.