Skip to content

Commit

Permalink
Add in boolean for using data for initial pests/pathogens in soil.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJones687 committed Sep 25, 2023
1 parent ae4891d commit 5ac8f23
Show file tree
Hide file tree
Showing 10 changed files with 815 additions and 935 deletions.
4 changes: 3 additions & 1 deletion R/calibrate.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ calibrate <- function(infected_years_file,
multiple_random_seeds = FALSE,
file_random_seeds = NULL,
use_soils = FALSE,
soil_starting_pest_file = "") {
soil_starting_pest_file = "",
start_with_soil_populations = FALSE) {

# add all data to config list
config <- c()
Expand Down Expand Up @@ -293,6 +294,7 @@ calibrate <- function(infected_years_file,
config$file_random_seeds <- file_random_seeds
config$use_soils <- use_soils
config$soil_starting_pest_file <- soil_starting_pest_file
config$start_with_soil_populations <- start_with_soil_populations

# call configuration function to perform data checks and transform data into
# format used in pops c++
Expand Down
34 changes: 19 additions & 15 deletions R/configuration.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,26 @@ configuration <- function(config) {

# check that soils raster has the same crs, resolutin, and extent.
if (config$use_soils) {
if (config$function_name %in% aws_bucket_list) {
soils_check <-
secondary_raster_checks(
config$soil_starting_pest_file, infected, config$use_s3, config$bucket)
} else {
soils_check <- secondary_raster_checks(config$soil_starting_pest_file, infected)
}
if (soils_check$checks_passed) {
soil_pests <- soils_check$raster
config$soil_pests <- terra::as.matrix(soil_pests, wide = TRUE)
} else {
config$failure <- soils_check$failed_check
if (config$failure == file_exists_error) {
config$failure <- detailed_file_exists_error(config$soil_starting_pest_file)
if (config$start_with_soil_populations) {
if (config$function_name %in% aws_bucket_list) {
soils_check <-
secondary_raster_checks(
config$soil_starting_pest_file, infected, config$use_s3, config$bucket)
} else {
soils_check <- secondary_raster_checks(config$soil_starting_pest_file, infected)
}
return(config)
if (soils_check$checks_passed) {
soil_pests <- soils_check$raster
config$soil_pests <- terra::as.matrix(soil_pests, wide = TRUE)
} else {
config$failure <- soils_check$failed_check
if (config$failure == file_exists_error) {
config$failure <- detailed_file_exists_error(config$soil_starting_pest_file)
}
return(config)
}
} else {
config$soil_pests <- zero_matrix
}
} else {
config$soil_pests <- zero_matrix
Expand Down
306 changes: 141 additions & 165 deletions R/pops.r

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion R/pops_multirun.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ pops_multirun <- function(infected_file,
multiple_random_seeds = FALSE,
file_random_seeds = NULL,
use_soils = FALSE,
soil_starting_pest_file = "") {
soil_starting_pest_file = "",
start_with_soil_populations = FALSE) {
config <- c()
config$random_seed <- random_seed
config$infected_file <- infected_file
Expand Down Expand Up @@ -192,6 +193,7 @@ pops_multirun <- function(infected_file,
config$file_random_seeds <- file_random_seeds
config$use_soils <- use_soils
config$soil_starting_pest_file <- soil_starting_pest_file
config$start_with_soil_populations <- start_with_soil_populations

config <- configuration(config)

Expand Down
4 changes: 3 additions & 1 deletion R/validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ validate <- function(infected_years_file,
multiple_random_seeds = FALSE,
file_random_seeds = NULL,
use_soils = FALSE,
soil_starting_pest_file = "") {
soil_starting_pest_file = "",
start_with_soil_populations = FALSE) {
config <- c()
config$infected_years_file <- infected_years_file
config$infected_file <- infected_file
Expand Down Expand Up @@ -211,6 +212,7 @@ validate <- function(infected_years_file,
config$file_random_seeds <- file_random_seeds
config$use_soils <- use_soils
config$soil_starting_pest_file <- soil_starting_pest_file
config$start_with_soil_populations <- start_with_soil_populations

config <- configuration(config)

Expand Down
307 changes: 143 additions & 164 deletions man/calibrate.Rd

Large diffs are not rendered by default.

316 changes: 146 additions & 170 deletions man/pops.Rd

Large diffs are not rendered by default.

152 changes: 68 additions & 84 deletions man/pops_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ac8f23

Please sign in to comment.