mrc-ide / helios

Simulating far UVC for pathogen control
https://mrc-ide.github.io/helios/
Other
5 stars 0 forks source link

Issue 83 (partial): Add USA schools #99

Closed athowes closed 4 months ago

athowes commented 5 months ago

Design decisions to highlight:

Code to look at this PR

# Loading library
library(helios)

# Checking country is present as new argument and can be overridden 
model_params <- get_parameters()
model_params$school_distribution_country
model_params <- get_parameters(overrides = list(school_distribution_country = "USA"))
model_params$school_distribution_country

# Checking create variables works with USA and UK
uk_variables <- create_variables(get_parameters(overrides = list(school_distribution_country = "UK")))

usa_variables <- create_variables(get_parameters(overrides = list(school_distribution_country = "USA")))

usa_school_id <- usa_variables$variables_list$school$get_categories()
usa_school_sizes <- vector()
usa_schools <- 1:max(as.numeric(usa_variables$variables_list$school$get_categories()))

for(i in usa_schools) {
  usa_school_sizes[i] <- usa_variables$variables_list$school$get_size_of(as.character(i))
}

usa_results <- run_simulation(get_parameters(overrides = list(school_distribution_country = "USA"), archetype = "sars_cov_2"))
plot(usa_results$timestep, usa_results$E_new, type = "l")
cwhittaker1000 commented 4 months ago

Commit f779dba was to sort merge conflicts, not for the merge itself. Sorry for confusing commit message.

cwhittaker1000 commented 4 months ago

Think we're pretty much sorted now, thanks @athowes for doing the heavy lifting on this! Have gone through and reviewed and looks good to me. Some minor changes to the way the data is processed to remove a redundant category (doesn't matter as we subsequently filter anyway) and adopt the convention we've decided where we only specify the country not empirical or synthetic. Test this PR with:

# Loading library
library(helios)

# Checking country is present as new argument and can be overridden 
model_params <- get_parameters()
model_params$school_distribution_country
model_params <- get_parameters(overrides = list(school_distribution_country = "custom"))
model_params$school_distribution_country

# Checking create variables works with USA and UK
uk_variables <- create_variables(get_parameters(overrides = list(school_distribution_country = "UK")))

usa_variables <- create_variables(get_parameters(overrides = list(school_distribution_country = "USA",
                                                                  human_population = 100000)))

usa_school_id <- usa_variables$variables_list$school$get_categories()
usa_school_sizes <- vector()
usa_schools <- 1:max(as.numeric(usa_variables$variables_list$school$get_categories()))

for(i in usa_schools) {
  usa_school_sizes[i] <- usa_variables$variables_list$school$get_size_of(as.character(i))
}
hist(usa_school_sizes, breaks = 50)

usa_results <- run_simulation(get_parameters(overrides = list(school_distribution_country = "USA",
                                                              workplace_distribution_country = "USA",
                                                              household_distribution_country = "USA"), 
                                             archetype = "sars_cov_2"))
plot(usa_results$timestep, usa_results$E_new, type = "l")

Will do one last check, but as I've reviewed and everything appears to be working, will merge when I'm done.