Skip to content

Commit

Permalink
outputting two variables for spraying
Browse files Browse the repository at this point in the history
- the n_spray at the current timestep
- spray_last_year the number with spraying over the last 365 timesteps
  • Loading branch information
htopazian committed May 15, 2024
1 parent 13d65f1 commit b7b4a12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 8 additions & 2 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,12 @@ create_processes <- function(
if (parameters$spraying) {
processes <- c(
processes,
indoor_spraying(variables$spray_time, parameters, correlations),
spray_renderer(variables$spray_time, renderer)
indoor_spraying(
variables$spray_time,
renderer,
parameters,
correlations
)
)
}

Expand All @@ -271,7 +275,9 @@ create_processes <- function(
create_mortality_process(variables, events, renderer, parameters)
)

# ======================
# Combined interventions
# ======================
# PEV & bednets
if (parameters$pev & parameters$bednets) {
processes <- c(
Expand Down
18 changes: 7 additions & 11 deletions R/vector_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ prob_bitten <- function(
#' `get_correlation_parameters`
#'
#' @param spray_time the variable for the time of spraying
#' @param renderer items to render
#' @param parameters the model parameters
#' @param correlations correlation parameters
#' @noRd
indoor_spraying <- function(spray_time, parameters, correlations) {
indoor_spraying <- function(spray_time, renderer, parameters, correlations) {
renderer$set_default("n_spray", 0)
renderer$set_default("spray_last_year", 0)
function(timestep) {
matches <- timestep == parameters$spraying_timesteps
if (any(matches)) {
Expand All @@ -116,10 +119,13 @@ indoor_spraying <- function(spray_time, parameters, correlations) {
correlations
))
spray_time$queue_update(timestep, target)
renderer$render("n_spray", length(target), timestep)
}
renderer$render("spray_last_year", used_intervention(spray_time, timestep, 365)$size(), timestep)
}
}


#' @title Distribute nets
#' @description distributes nets to individuals according to the strategy
#' from `set_bednets` and correlation parameters from
Expand Down Expand Up @@ -196,13 +202,3 @@ net_usage_renderer <- function(net_time, renderer) {
)
}
}

spray_renderer <- function(spray_time, renderer) {
function(t) {
renderer$render(
'n_spray_retain',
spray_time$get_index_of(-1)$not(TRUE)$size(),
t
)
}
}

0 comments on commit b7b4a12

Please sign in to comment.