episimlab package
Subpackages
- episimlab.models package
- episimlab.partition package
- episimlab.setup package
- Subpackages
- episimlab.setup.greek package
- Submodules
- episimlab.setup.greek.eta module
- episimlab.setup.greek.gamma module
- episimlab.setup.greek.mu module
- episimlab.setup.greek.nu module
- episimlab.setup.greek.omega module
- episimlab.setup.greek.pi module
- episimlab.setup.greek.rho module
- episimlab.setup.greek.sigma module
- episimlab.setup.greek.tau module
- Module contents
- episimlab.setup.greek package
- Submodules
- episimlab.setup.coords module
- episimlab.setup.seed module
- episimlab.setup.state module
- episimlab.setup.sto module
- Module contents
- Subpackages
- episimlab.utils package
Submodules
episimlab.compt_model module
- class episimlab.compt_model.ComptModel(*, tm_subset={}, state, compt_graph, stochastic, seed_state)
Bases:
object
Applies the compartmental disease model defined in compt_graph to the current state of the system.
- _tm_subset
attr.Attribute
Mapping of all variables that belong to group ‘edge_weight’
Variable properties:
type :
group_dict
intent :
in
default value : {}
- state
attr.Attribute
The current state of the simulation. in the context of a compartmental model, this tensor contains the current populations of all compartments along every demographic axis (e.g. age, risk, geospatial vertex).
Variable properties:
type :
variable
intent :
inout
global name : state
dimensions : (‘vertex’, ‘compt’, ‘age’, ‘risk’)
- tm
attr.Attribute
The transition matrix (tm for short) that is added to the state at time t to get the state for the state at the t + 1 timestep.
Variable properties:
type :
variable
intent :
out
global name : edge_weight
dimensions : (‘vertex’, ‘compt’, ‘age’, ‘risk’)
- compt_graph
attr.Attribute
The compartment graph is a networkx graph where nodes are compartments and edges are allowed transitions between them in the compartmental model.
Variable properties:
type :
variable
intent :
in
global name : compt_graph
dimensions : (‘compt_graph’,)
- stochastic
attr.Attribute
Boolean flag that determines whether to sample edge weights stochastically (stochastic=true) or not (deterministic, stochastic=false)
Variable properties:
type :
variable
intent :
in
global name : stochastic
dimensions : ()
- seed_state
attr.Attribute
Integer seed for generating the random number generator at every time step.
Variable properties:
type :
variable
intent :
in
global name : seed_state
dimensions : ()
- STATE_DIMS = ('vertex', 'compt', 'age', 'risk')
- TAGS = ('essential',)
- apply_edges() None
Iterate over edges in compt_graph in ascending order of priority. Apply each edge to the TM.
- calc_k(*edges) xarray.core.dataarray.DataArray
Find some scaling factor k such that origin node u will not be depleted if all edges (u, v) are applied simultaneously. All edges must share the same origin node u.
- edge_to_tm(*edges, k=1.0) None
Applies to the transition matrix (TM) the weight of directed edges (u, v) from compartment u to compartment v. Scale edge weights by k to ensure that population of origin node u is always non-negative after edge weight has been applied.
- edge_weight(u, v)
- property edges_by_priority: tuple
Parses the compt_graph attribute into tuples of edges sorted by edges’ priority attribute. Basically, only used in the apply_edges method.
- finalize_step()
- get_edge_weight(u, v)
Try to find an edge weight for (u, v) in tm_subset, then in the edge attribute. Default to zero weight if none can be found.
- poisson(val)
- property rng
- run_step()
In particular, we need to ensure that tm_subset and tm refresh at every timestep.
- stochastic_draw(*args, **kwargs)
- _tm_subset
episimlab.foi module
- class episimlab.foi.BaseFOI(*, phi, state, beta, coords={})
Bases:
object
Base class for calculating force of infection (FOI).
- phi
attr.Attribute
Pairwise contact patterns
Variable properties:
type :
variable
intent :
in
global name : phi
dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)
- state
attr.Attribute
No description given
Variable properties:
type :
global
intent :
in
global name : state
- beta
attr.Attribute
No description given
Variable properties:
type :
variable
intent :
in
global name : beta
dimensions : ()
- _coords
attr.Attribute
Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dict
intent :
in
default value : {}
- property I
- I_COMPT_LABELS = 'I'
- PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
- property S
- S_COMPT_LABELS = 'S'
- TAGS = ('FOI', 'essential', 'example')
- property foi: xarray.core.dataarray.DataArray
- property foi_coords: dict
- property foi_dims: tuple
We assume that we want to include all phi dimensions in the FOI calculation.
- normalize_index(index)
Generate an index that that is compatible with DataArray.loc.
- property phi_dims
- phi
- class episimlab.foi.BruteForceFOI(*, phi, state, beta, coords={})
Bases:
episimlab.foi.BaseFOI
Calculate force of infection (FOI) using naive for looping. Similar to BruteForceFOI process in Episimlab v1
- phi
attr.Attribute
Pairwise contact patterns
Variable properties:
type :
variable
intent :
in
global name : phi
dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)
- state
attr.Attribute
No description given
Variable properties:
type :
global
intent :
in
global name : state
- beta
attr.Attribute
No description given
Variable properties:
type :
variable
intent :
in
global name : beta
dimensions : ()
- _coords
attr.Attribute
Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dict
intent :
in
default value : {}
- PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
- TAGS = ('model::SIR', 'FOI', 'brute_force', 'deprecated')
- property foi: xarray.core.dataarray.DataArray
Brute force FOI, like BruteForceFOI in Episimlab v1.0
- run_step()
- phi