laser_cholera.metapop package

class laser_cholera.metapop.Analyzer(model)[source]

Bases: object

__call__(model, tick: int) None[source]

Calculate log likelihood on the final tick.

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Census(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
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})} }\]
check()[source]
plot(fig=None)[source]
class laser_cholera.metapop.EnvToHuman(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.EnvToHumanVax(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Environmental(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Exposed(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.HumanToHuman(model)[source]

Bases: object

__call__(model, tick: int) None[source]

Calculate the current human-to-human transmission rate per patch.

$Lambda_{j,t+1} = frac {beta^{hum}_{jt}((S_{jt}(1 - tau_j))(I_{jt}(1 - tau_j) + sum_{forall i neq j (pi_{ij} tau_j I_{it})}))^{alpha_1}} {N^{alpha_2}_{jt}}$

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.HumanToHumanVax(model)[source]

Bases: object

__call__(model, tick: int) None[source]

Calculate the current human-to-human transmission rate per patch.

$Lambda_{j,t+1} = frac {beta^{hum}_{jt}((S_{jt}(1 - tau_j))(I_{jt}(1 - tau_j) + sum_{forall i neq j (pi_{ij} tau_j I_{it})}))^{alpha_1}} {N^{alpha_2}_{jt}}$

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Infectious(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Parameters(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Recorder(model)[source]

Bases: object

check()[source]
class laser_cholera.metapop.Recovered(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Susceptible(model)[source]

Bases: Component

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.Vaccinated(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
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

class laser_cholera.metapop.analyzer.Analyzer(model)[source]

Bases: object

__call__(model, tick: int) None[source]

Calculate log likelihood on the final tick.

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.census module

class laser_cholera.metapop.census.Census(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]

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})} }\]
check()[source]
plot(fig=None)[source]
laser_cholera.metapop.derivedvalues.calculate_coupling(Isym, Iasym, N, C)[source]

Calculate the coupling between locations.

https://institutefordiseasemodeling.github.io/MOSAIC-docs/model-description.html#coupling-among-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.derivedvalues.calculate_spatial_hazard_for_model(model)[source]

Calculate the spatial hazard for the model.

Helpful for calling from R without needing to specify all the parameters.

laser_cholera.metapop.environmental module

class laser_cholera.metapop.environmental.Environmental(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
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.

class laser_cholera.metapop.envtohuman.EnvToHuman(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.envtohumanvax module

Environmental transmission rate.

class laser_cholera.metapop.envtohumanvax.EnvToHumanVax(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
laser_cholera.metapop.envtohumanvax.plot_helper(fig, title, data, names)[source]

laser_cholera.metapop.exposed module

class laser_cholera.metapop.exposed.Exposed(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.humantohuman module

Human-to-human transmission rate.

class laser_cholera.metapop.humantohuman.HumanToHuman(model)[source]

Bases: object

__call__(model, tick: int) None[source]

Calculate the current human-to-human transmission rate per patch.

$Lambda_{j,t+1} = frac {beta^{hum}_{jt}((S_{jt}(1 - tau_j))(I_{jt}(1 - tau_j) + sum_{forall i neq j (pi_{ij} tau_j I_{it})}))^{alpha_1}} {N^{alpha_2}_{jt}}$

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.humantohumanvax module

Human-to-human transmission rate.

class laser_cholera.metapop.humantohumanvax.HumanToHumanVax(model)[source]

Bases: object

__call__(model, tick: int) None[source]

Calculate the current human-to-human transmission rate per patch.

$Lambda_{j,t+1} = frac {beta^{hum}_{jt}((S_{jt}(1 - tau_j))(I_{jt}(1 - tau_j) + sum_{forall i neq j (pi_{ij} tau_j I_{it})}))^{alpha_1}} {N^{alpha_2}_{jt}}$

check()[source]
plot(fig: Figure | None = None)[source]
laser_cholera.metapop.humantohumanvax.plot_helper(fig, title, data, names)[source]

laser_cholera.metapop.infectious module

class laser_cholera.metapop.infectious.Infectious(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.logsetup module

laser_cholera.metapop.logsetup.setup_logging(loglevel, outdir: Path)[source]

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.

plot(fig: Figure | None = None)[source]
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

visualize(pdf: bool = True) str | None[source]

Visualize each compoonent instances either by displaying plots or saving them to a PDF file.

Parameters:

pdf (bool) – If True, save the plots to a PDF file. If False, display the plots interactively. Default is True.

Returns:

None

class laser_cholera.metapop.model.RInterface(model)[source]

Bases: object

A simple interface to store results trimmed and transposed for R.

laser_cholera.metapop.model.run_model(paramfile, **kwargs)[source]

laser_cholera.metapop.params module

class laser_cholera.metapop.params.Parameters(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]
class laser_cholera.metapop.params.PropertySetEx(*kvps)[source]

Bases: PropertySet

__str__() str[source]

Return a string representation of the PropertySet.

Include converters for datetime and NumPy types.

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 a TypeError).

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.as_ndarray(input, dtype)[source]
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]

laser_cholera.metapop.recorder module

class laser_cholera.metapop.recorder.Recorder(model)[source]

Bases: object

check()[source]
laser_cholera.metapop.recorder.save_compressed_hdf5_parameters(model, filename: str | Path) Path[source]
laser_cholera.metapop.recorder.save_hdf5(h5file: File, model) None[source]
laser_cholera.metapop.recorder.save_hdf5_parameters(model, filename: str | Path) Path[source]

laser_cholera.metapop.recovered module

class laser_cholera.metapop.recovered.Recovered(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.scenario module

laser_cholera.metapop.susceptible module

class laser_cholera.metapop.susceptible.Component[source]

Bases: object

class laser_cholera.metapop.susceptible.Susceptible(model)[source]

Bases: Component

check()[source]
plot(fig: Figure | None = None)[source]

laser_cholera.metapop.utils module

laser_cholera.metapop.utils.get_daily_seasonality(params)[source]
laser_cholera.metapop.utils.get_pi_from_lat_long(params)[source]
laser_cholera.metapop.utils.override_helper(overrides) dict[source]

laser_cholera.metapop.vaccinated module

class laser_cholera.metapop.vaccinated.Vaccinated(model)[source]

Bases: object

check()[source]
plot(fig: Figure | None = None)[source]