-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from dd-harp/dev
Travel and exposure while traveling
- Loading branch information
Showing
30 changed files
with
395 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#' @title Travel EIR | ||
#' @description Compute the EIR while traveling | ||
#' @param t the time | ||
#' @param pars an **`xds`** object | ||
#' @param i the host species index | ||
#' @return the daily travel EIR, a [numeric] vector | ||
#' @export | ||
travel_eir <- function(t, pars, i){ | ||
with(pars$travel_eir[[i]], return(travelEIR*F_season(t)*F_trend(t))) | ||
} | ||
|
||
#' @title Setup Travel EIR | ||
#' @description Set up a function to compute the travel EIR | ||
#' @param pars a [list] | ||
#' @param travelEIR the time spent traveling | ||
#' @param F_season a function describing a seasonal pattern | ||
#' @param F_trend a function describing a trend | ||
#' @param i the host species index | ||
#' @return an **`xds`** object | ||
#' @export | ||
setup_travel_eir = function(pars, travelEIR=0, F_season=F_flat, F_trend=F_flat, i=1){ | ||
trv <- list() | ||
trv$travelEIR <- travelEIR | ||
trv$F_season <- F_season | ||
trv$F_trend <- F_trend | ||
pars$travel_eir[[i]] <- trv | ||
return(pars) | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
#' @title A model for the travel FoI | ||
#' @description Implements [traveling]. The function is | ||
#' called by [make_TaR] to set the fraction of time spent | ||
#' traveling | ||
#' @param t current simulation time | ||
#' @param pars a [list]# | ||
#' @param i host species index | ||
#' @return an **`xds`** object | ||
#' @export | ||
traveling <- function(t, pars, i) { | ||
UseMethod("traveling", pars$travel[[i]]) | ||
} | ||
|
||
#' @title A model for the travel FoI | ||
#' @description Implements [traveling] through a model for the travel FoI | ||
#' @inheritParams traveling | ||
#' @return an **`xds`** object | ||
#' @export | ||
traveling.static <- function(t, pars, i) { | ||
return(pars) | ||
} | ||
|
||
#' @title A model for the travel FoI | ||
#' @description Implements [traveling] through a model for the travel FoI | ||
#' @inheritParams traveling | ||
#' @return an **`xds`** object | ||
#' @export | ||
traveling.setup <- function(t, pars, i) { | ||
pars$time_traveling[[i]] <- pars$travel[[i]]$traveling_fraction | ||
pars <- trigger_setup(pars$BFpar) | ||
return(pars) | ||
} | ||
|
||
#' @title A model for the travel FoI | ||
#' @description Implements [traveling] through a model for the travel FoI | ||
#' @inheritParams traveling | ||
#' @return an **`xds`** object | ||
#' @export | ||
traveling.dynamic <- function(t, pars, i) { | ||
with(pars$travel[[i]],{ | ||
pars$time_traveling[[i]] = traveling*F_season(t)*F_trend(t) | ||
return(pars) | ||
}) | ||
} | ||
|
||
#' @title A function to set up malaria importation | ||
#' @description Setup a static model for travel malaria | ||
#' @param pars a [list] | ||
#' @param i the host species index | ||
#' @return a [list] | ||
#' @export | ||
setup_no_travel = function(pars, i=1){ | ||
trv <- list() | ||
class(trv) <- "static" | ||
trv$traveling_fraction <- 0 | ||
pars$travel[[i]] <- trv | ||
return(pars) | ||
} | ||
|
||
#' @title A function to set up malaria importation | ||
#' @description Setup a static model for travel malaria | ||
#' @param pars an **`xds`** object | ||
#' @param traveling_fraction the fraction of time spent traveling | ||
#' @param i the host species index | ||
#' @return a [list] | ||
#' @export | ||
setup_static_travel = function(pars, traveling_fraction=0, i=1){ | ||
trv <- list() | ||
class(trv) <- "setup" | ||
trv$traveling_fraction <- traveling_fraction | ||
pars$travel[[i]] <- trv | ||
return(pars) | ||
} | ||
|
||
#' @title A function to set up malaria importation | ||
#' @description Setup a static model for travel malaria | ||
#' @param pars a [list] | ||
#' @param traveling the time spent traveling | ||
#' @param F_season a function describing a seasonal pattern | ||
#' @param F_trend a function describing a trend | ||
#' @param i the host species index | ||
#' @return a [list] | ||
#' @export | ||
setup_dynamic_travel = function(pars, traveling=0, F_season=F_flat, F_trend=F_flat, i=1){ | ||
trv <- list() | ||
class(trv) <- "dynamic" | ||
class(pars$BFpar) <- "dynamic" | ||
trv$traveling <- traveling | ||
trv$F_season <- F_season | ||
trv$F_trend <- F_trend | ||
pars$travel[[i]] <- trv | ||
return(pars) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.