if (FALSE) {
#### Spatially-implicit simulation with a single 1-km^2 patch 100% cultivated
# with a susceptible cultivar
simul_landsepi()
#### Spatially-implicit simulation with 2 patches (S + R) during 3 years ####
## Simulation parameters
time_param <- list(Nyears = 3, nTSpY = 120)
area <- c(100000, 100000)
rotation <- data.frame(year_1 = c(0, 1), year_2 = c(0, 1), year_3 = c(0, 1), year_4 = c(0, 1))
croptype_names <- c("Susceptible crop", "Resistant crop")
croptypes_cultivars_prop <- data.frame(
croptypeID = c(0, 1),
cultivarID = c(0, 1),
proportion = c(1, 1)
)
cultivars <- rbind(
loadCultivar(name = "Susceptible", type = "growingHost"),
loadCultivar(name = "Resistant", type = "growingHost")
)
genes <- loadGene(name = "MG", type = "majorGene")
cultivars_genes_list <- list(numeric(0), 0)
## Run simulation
simul_landsepi(
seed = 12345, time_param, croptype_names, croptypes_cultivars_prop, cultivars,
cultivars_genes_list, genes, landscape = NULL, area, rotation,
basic_patho_param = loadPathogen(disease = "rust"),
disp_patho_clonal = c(0.99, 0.01, 0.01, 0.99),
disp_patho_sex = c(0.99, 0.01, 0.01, 0.99),
disp_host = c(1, 0, 0, 1),
pI0 = c(5e-4)
)
#### Spatially-explicit simulation with built-in landscape during 10 years ####
# Generate a mosaic of four croptypes in balanced proportions
# and medium level of spatial aggregation
## Simulation and Landscape parameters
Nyears <- 10
nTSpY <- 120
landscape <- loadLandscape(1)
Npoly <- length(landscape)
library(sf)
area <- st_area(st_as_sf(landscape))
rotation <- AgriLand(landscape, Nyears,
rotation_period = 1, rotation_realloc = FALSE,
rotation_sequence = c(0, 1, 2, 3),
prop = rep(1 / 4, 4), aggreg = 0.5, graphic = TRUE, outputDir = getwd()
)
rotation <- data.frame(rotation)[, 1:(Nyears + 1)]
croptype_names <- c("Susceptible crop"
, "Resistant crop 1"
, "Resistant crop 2"
, "Resistant crop 3")
croptypes_cultivars_prop <- data.frame(croptypeID = c(0, 1, 2, 3), cultivarID = c(0, 1, 2, 3),
proportion = c(1, 1, 1, 1))
cultivars <- data.frame(rbind(
loadCultivar(name = "Susceptible", type = "growingHost"),
loadCultivar(name = "Resistant1", type = "growingHost"),
loadCultivar(name = "Resistant2", type = "growingHost"),
loadCultivar(name = "Resistant3", type = "growingHost")
), stringsAsFactors = FALSE)
Nhost <- nrow(cultivars)
genes <- data.frame(rbind(
loadGene(name = "MG 1", type = "majorGene"),
loadGene(name = "MG 2", type = "majorGene"),
loadGene(name = "MG 3", type = "majorGene")
), stringsAsFactors = FALSE)
cultivars_genes_list <- list(numeric(0), 0, 1, 2)
Npatho <- prod(genes$Nlevels_aggressiveness)
## Run simulation
simul_landsepi(
seed = 12345, time_param = list(Nyears = Nyears, nTSpY = nTSpY),
croptype_names, croptypes_cultivars_prop, cultivars,
cultivars_genes_list, genes, landscape, area, rotation,
basic_patho_param = loadPathogen(disease = "rust"),
disp_patho_clonal = loadDispersalPathogen(1)[[1]],
disp_patho_sex = as.numeric(diag(Npoly)),
disp_host = as.numeric(diag(Npoly)),
pI0 = c(5E-4)
)
}
Run the code above in your browser using DataLab