laser_cholera.metapop package¶
- class laser_cholera.metapop.DerivedValues(model)[source]¶
Bases:
object- __call__(model, tick: int) None[source]¶
Calculate derived values for the model.
Spatial hazard and coupling are calculated at the end of the simulation.
\[h(j,t) = \frac {\beta^{hum}_{jt} (1 - e^{-((1 - \tau_j) (S_{jt} + V^{sus}_{1,jt} + V^{sus}_{2,jt}) / N_{jt}) \sum_{\forall i \ne j} \pi_{ij} \tau_i ((I^{sym}_{it} + I^{asym}_{it}) / N_{it})})} {1/(1 + \beta^{hum}_{jt}(1 - \tau_j) (S_{jt} + V^{sus}_{1,jt} + V^{sus}_{2,jt}))}\]\[y_{it} = \frac {I^{sym}_{it} + I^{asym}_{it}} {N_{it}}\]\[\bar y_{i} = \frac 1 T \sum_{t=1}^{T} y_{it}\]\[C_{ij} = \frac { \sum_{t=1}^T {(y_{it} - \bar y_i) (y_{jt} - \bar y_j)} } { \sqrt {\sum_{t=1}^T {(y_{it} - \bar y_i)}^2} \sqrt {\sum_{t=1}^T {(y_{jt} - \bar y_j)}^2} }\]\[C_{ij} = \frac {(y_{it} - \bar y_{i}) (y_{jt} - \bar y_{j})} { \sqrt {\text {var}(y_{i}) \text {var}(y_{j})} }\]
- class laser_cholera.metapop.HumanToHuman(model)[source]¶
Bases:
object
- class laser_cholera.metapop.HumanToHumanVax(model)[source]¶
Bases:
object
- laser_cholera.metapop.get_parameters(paramsource: str | Path | dict | None = None, do_validation: bool = True, overrides: dict | None = None) PropertySetEx[source]¶
Submodules¶
laser_cholera.metapop.analyzer module¶
laser_cholera.metapop.census module¶
laser_cholera.metapop.derivedvalues module¶
- class laser_cholera.metapop.derivedvalues.DerivedValues(model)[source]¶
Bases:
object- __call__(model, tick: int) None[source]¶
Calculate derived values for the model.
Spatial hazard and coupling are calculated at the end of the simulation.
\[h(j,t) = \frac {\beta^{hum}_{jt} (1 - e^{-((1 - \tau_j) (S_{jt} + V^{sus}_{1,jt} + V^{sus}_{2,jt}) / N_{jt}) \sum_{\forall i \ne j} \pi_{ij} \tau_i ((I^{sym}_{it} + I^{asym}_{it}) / N_{it})})} {1/(1 + \beta^{hum}_{jt}(1 - \tau_j) (S_{jt} + V^{sus}_{1,jt} + V^{sus}_{2,jt}))}\]\[y_{it} = \frac {I^{sym}_{it} + I^{asym}_{it}} {N_{it}}\]\[\bar y_{i} = \frac 1 T \sum_{t=1}^{T} y_{it}\]\[C_{ij} = \frac { \sum_{t=1}^T {(y_{it} - \bar y_i) (y_{jt} - \bar y_j)} } { \sqrt {\sum_{t=1}^T {(y_{it} - \bar y_i)}^2} \sqrt {\sum_{t=1}^T {(y_{jt} - \bar y_j)}^2} }\]\[C_{ij} = \frac {(y_{it} - \bar y_{i}) (y_{jt} - \bar y_{j})} { \sqrt {\text {var}(y_{i}) \text {var}(y_{j})} }\]
- laser_cholera.metapop.derivedvalues.calculate_coupling(Isym, Iasym, N, C)[source]¶
Calculate the coupling between locations.
\[C_{ij} = \frac {(y_{it} - \bar y_{i}) (y_{jt} - \bar y_{j})} { \sqrt {\text {var}(y_{i}) \text {var}(y_{j})} }\]
- laser_cholera.metapop.derivedvalues.calculate_coupling_for_model(model)[source]¶
Calculate the coupling for the model.
Helpful for calling from R without needing to specify all the parameters.
- laser_cholera.metapop.derivedvalues.calculate_spatial_hazard(nticks, beta_jt_human, tau_i, S, V1sus, V2sus, Njt, pi_ij, Iasym, Isym, spatial_hazard)[source]¶
Calculate the spatial hazard for each location at each time step. The spatial hazard is calculated using the formula:
https://institutefordiseasemodeling.github.io/MOSAIC-docs/model-description.html#the-spatial-hazard
\[h(j,t) = \frac {\beta^{hum}_{jt} (1 - e^{-((1 - \tau_j) (S_{jt} + V^{sus}_{1,jt} + V^{sus}_{2,jt}) / N_{jt}) \sum_{\forall i \ne j} \pi_{ij} \tau_i ((I^{sym}_{it} + I^{asym}_{it}) / N_{it})})} {1/(1 + \beta^{hum}_{jt}(1 - \tau_j) (S_{jt} + V^{sus}_{1,jt} + V^{sus}_{2,jt}))}\]Note: To simplify coding and debugging, all arrays are passed in R order: [j, t]
laser_cholera.metapop.environmental module¶
- laser_cholera.metapop.environmental.map_suitability_to_decay(fast, slow, suitability, beta_a, beta_b)[source]¶
Map suitability to decay using a beta distribution.
$ delta_{jt} = frac { 1 } { text {days}_short + f( psi_{jt}) ( text {days}_long - text {days}_short ) } $
We use a parameterized beta distribution to map suitability values [0, 1] to [0, 1] in a, potentially, non-linear way.
The resulting suitability factor determines a decay rate that is large when suitability is low, i.e., when suitability is 0, the decay rate is 1/fast and since fast is a short time or small number of days, 1/fast is relatively large, and small when suitability is high, i.e. when suitability is 1, the decay rate is 1/slow and since slow is a long time or larger number of days, 1/slow is relatively small.
- Parameters:
fast (float) – Fast decay time.
slow (float) – Slow decay time.
suitability (np.ndarray) – Suitability values.
beta_a (float) – Alpha parameter for the beta distribution.
beta_b (float) – Beta parameter for the beta distribution.
- Returns:
np.ndarray – Decay rates corresponding to the suitability values.
laser_cholera.metapop.envtohuman module¶
Environmental transmission rate.
laser_cholera.metapop.envtohumanvax module¶
Environmental transmission rate.
laser_cholera.metapop.exposed module¶
laser_cholera.metapop.humantohuman module¶
Human-to-human transmission rate.
- class laser_cholera.metapop.humantohuman.HumanToHuman(model)[source]¶
Bases:
object
laser_cholera.metapop.humantohumanvax module¶
Human-to-human transmission rate.
- class laser_cholera.metapop.humantohumanvax.HumanToHumanVax(model)[source]¶
Bases:
object
laser_cholera.metapop.infectious module¶
laser_cholera.metapop.logsetup module¶
laser_cholera.metapop.model module¶
- class laser_cholera.metapop.model.Model(parameters: PropertySet, name: str = 'Cholera Metapop')[source]¶
Bases:
object- property components: list¶
Retrieve the list of model components.
- Returns:
list – A list containing the components.
- run() None[source]¶
Execute the model for a specified number of ticks, recording the time taken for each phase.
This method initializes the start time, iterates over the number of ticks specified in the model parameters, and for each tick, it executes each phase of the model while recording the time taken for each phase.
The metrics for each tick are stored in a list. After completing all ticks, it records the finish time and, logs a summary of the timing metrics.
- Variables:
tstart (datetime) – The start time of the model execution.
tfinish (datetime) – The finish time of the model execution.
metrics (list) – A list of timing metrics for each tick and phase.
- Returns:
None
laser_cholera.metapop.params module¶
- class laser_cholera.metapop.params.PseEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoder- default(obj)[source]¶
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- laser_cholera.metapop.params.dict_to_propertysetex(parameters: dict) PropertySetEx[source]¶
- laser_cholera.metapop.params.get_parameters(paramsource: str | Path | dict | None = None, do_validation: bool = True, overrides: dict | None = None) PropertySetEx[source]¶
- laser_cholera.metapop.params.load_compressed_hdf5_parameters(filename: str | Path) PropertySetEx[source]¶
- laser_cholera.metapop.params.load_compressed_json_parameters(filename: str | Path) PropertySetEx[source]¶
- laser_cholera.metapop.params.load_hdf5(h5file) PropertySetEx[source]¶
- laser_cholera.metapop.params.load_hdf5_parameters(filename: str | Path) PropertySetEx[source]¶
- laser_cholera.metapop.params.load_json_parameters(filename: str | Path) PropertySetEx[source]¶
- laser_cholera.metapop.params.validate_parameters(params: PropertySetEx) None[source]¶