-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibrate_2014.R
121 lines (111 loc) · 4.03 KB
/
calibrate_2014.R
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Jones, C., Jones, S., Petrasova, A., Petras, V., Gaydos, D., Skrip, M.,
# Takeuchi, Y., Bigsby, K., and Meentemeyer, R., 2021. Iteratively forecasting
# biological invasions with PoPS and a little help from our friends. Frontiers
# in Ecology and the Environment DOI: 10.1002/fee.2357
# install.packages("remotes")
# remotes::install_github("ncsu-landscape-dynamics/rpops")
library(PoPS)
library(terra)
cbs_path = "Z:/Data/Raster/USA/pops_casestudies/citrus_black_spot/"
cbs_out = "Z:/Data/Raster/USA/pops_casestudies/citrus_black_spot/outputs/"
prior_means <- read.csv(paste0(cbs_out, "posterior_means_pa_2013.csv"))
prior_means <- prior_means[[1]]
prior_cov_matrix <- read.csv(paste0(cbs_out, "posterior_cov_matrix_pa_2013.csv"))
start_time <- Sys.time()
# Calibration for PoPS model
cal_2014 <- PoPS::calibrate(
infected_years_file = paste0(cbs_path, "infection/cbs_pa_2015.tif"),
number_of_observations = 33,
prior_number_of_observations = 190,
prior_means,
prior_cov_matrix,
params_to_estimate = c(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE),
number_of_generations = 7,
generation_size = 1000,
pest_host_table = paste0(cbs_path, "pest_host_table_cbs.csv"),
competency_table = paste0(cbs_path, "competency_table_cbs.csv"),
infected_file_list = paste0(cbs_path, "infection/cbs_pa_2014.tif"),
host_file_list = paste0(cbs_path, "host/host.tif"),
total_populations_file = paste0(cbs_path, "total_pops_file.tif"),
temp = TRUE,
temperature_coefficient_file = paste0(cbs_path, "temp/temp_coeff_2015.tif"),
precip = TRUE,
precipitation_coefficient_file = paste0(cbs_path, "precip/prcp_coeff_2015.tif"),
model_type = "SI",
latency_period = 0,
time_step = 'day',
season_month_start = 4,
season_month_end = 9,
start_date = "2015-01-01",
end_date = "2015-12-31",
use_survival_rates = FALSE,
survival_rate_month = 3,
survival_rate_day = 15,
survival_rates_file = "",
use_lethal_temperature = FALSE,
temperature_file = "",
lethal_temperature = -12.87,
lethal_temperature_month = 1,
mortality_frequency = "day",
mortality_frequency_n = 1,
management = TRUE,
treatment_dates = "2015-04-01",
treatments_file = paste0(cbs_path, "trt.tif"),
treatment_method = "ratio",
natural_kernel_type = "cauchy",
anthropogenic_kernel_type = "cauchy",
natural_dir = "NONE",
natural_kappa = 0,
anthropogenic_dir = "NONE",
anthropogenic_kappa = 0,
pesticide_duration = 180,
pesticide_efficacy = 0.829,
mask = NULL,
output_frequency = "year",
output_frequency_n = 1,
movements_file = "",
use_movements = FALSE,
start_exposed = FALSE,
generate_stochasticity = TRUE,
establishment_stochasticity = TRUE,
movement_stochasticity = TRUE,
dispersal_stochasticity = TRUE,
establishment_probability = 0.5,
dispersal_percentage = 0.99,
quarantine_areas_file = "",
use_quarantine = FALSE,
use_spreadrates = FALSE,
use_overpopulation_movements = FALSE,
overpopulation_percentage = 0,
leaving_percentage = 0,
leaving_scale_coefficient = 1,
calibration_method = "ABC",
number_of_iterations = 1e+05,
exposed_file_list = "",
verbose = TRUE,
write_outputs = c("summary_outputs"),
output_folder_path = cbs_out,
network_filename = "",
network_movement = "walk",
success_metric = "quantity, allocation, and configuration",
use_initial_condition_uncertainty = FALSE,
use_host_uncertainty = FALSE,
weather_type = "deterministic",
temperature_coefficient_sd_file = "",
precipitation_coefficient_sd_file = "",
dispersers_to_soils_percentage = 0,
quarantine_directions = "",
multiple_random_seeds = FALSE,
file_random_seeds = NULL,
use_soils = FALSE,
soil_starting_pest_file = "",
start_with_soil_populations = FALSE,
county_level_infection_data = FALSE
)
end_time <- Sys.time()
time_taken <- round(end_time - start_time, 2)
time_taken
file_name <- paste0(cbs_out, "posterior_means_pa_2014.csv")
write.csv(cal_2014$posterior_means, file_name, row.names = FALSE)
file_name <- paste0(cbs_out, "posterior_cov_matrix_pa_2014.csv")
write.csv(cal_2014$posterior_cov_matrix, file_name, row.names = FALSE)