derivedvalues
laser.cholera.metapop.derivedvalues
¶
End-of-run derived diagnostics: spatial hazard and inter-location coupling.
DerivedValues
runs every tick but only does its real work on the final tick, computing:
patches.spatial_hazard— per-patch, per-tick infection-pressure metric incorporating local susceptibility, emigration / immigration viapi_ij, and the seasonality envelopebeta_jt_human.patches.coupling—(npatches × npatches)Pearson correlation matrix of the per-tick prevalence-fraction series across patch pairs.
Module-level helpers
calculate_spatial_hazard
and
calculate_coupling
do the math; the per-model wrappers exist primarily so R callers can
invoke them with a single argument.
DerivedValues
¶
Computes end-of-run diagnostics: spatial hazard and coupling matrix.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The parent |
Source code in src/laser/cholera/metapop/derivedvalues.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
__init__
¶
Allocate spatial_hazard and coupling arrays on model.patches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The |
required |
Raises:
| Type | Description |
|---|---|
AttributeError
|
When |
Source code in src/laser/cholera/metapop/derivedvalues.py
check
¶
Validate every upstream attribute and parameter the final-tick math needs.
Verifies model.people has S/Isym/Iasym; model.patches
has N/beta_jt_human/pi_ij; and params provides
beta_j0_hum, p, and tau_i. These are populated by
Susceptible,
Infectious,
Census, and
HumanToHuman
earlier in the pipeline.
Raises:
| Type | Description |
|---|---|
AttributeError
|
When |
ValueError
|
When |
Source code in src/laser/cholera/metapop/derivedvalues.py
__call__
¶
Calculate derived values for the model.
Spatial hazard and coupling are calculated at the end of the simulation.
Spatial hazard per location and tick:
Prevalence fraction and its time-average per location:
Inter-location coupling — Pearson correlation between prevalence fractions:
Equivalently:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The parent |
required |
tick
|
int
|
Current simulation tick. The computation is a no-op
for every tick except the last
( |
required |
Source code in src/laser/cholera/metapop/derivedvalues.py
plot
¶
Yield one Matplotlib heatmap of spatial_hazard (patch × tick).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure | None
|
Optional existing Matplotlib |
None
|
Yields:
| Type | Description |
|---|---|
str
|
The string label |
Source code in src/laser/cholera/metapop/derivedvalues.py
calculate_spatial_hazard_for_model
¶
Calculate the spatial hazard for the model.
Helpful for calling from R without needing to specify all the parameters.
Source code in src/laser/cholera/metapop/derivedvalues.py
calculate_spatial_hazard
¶
calculate_spatial_hazard(
nticks,
beta_jt_human,
tau_i,
S,
Njt,
pi_ij,
Iasym,
Isym,
spatial_hazard,
)
Calculate the spatial hazard for each location at each time step.
The spatial hazard is calculated using the formula (reference):
Note: To simplify coding and debugging, all arrays are passed in R
order: [j, t].
Source code in src/laser/cholera/metapop/derivedvalues.py
calculate_coupling_for_model
¶
Calculate the coupling for the model.
Helpful for calling from R without needing to specify all the parameters.
Source code in src/laser/cholera/metapop/derivedvalues.py
calculate_coupling
¶
Calculate the coupling between locations.
Pearson correlation between per-tick prevalence fractions, computed as (reference):