Enable seasonality on human-to-human transmission¶
Turn on the two-mode seasonal envelope that modulates the human-to-human transmission rate beta_j0_hum. This guide assumes you already have a working laser-cholera configuration with non-zero beta_j0_hum and just want to add per-patch seasonal forcing.
At each tick t and patch j the simulator multiplies beta_j0_hum[j] by the harmonic
1 + a_1_j[j] * cos(2*pi*t/p) + b_1_j[j] * sin(2*pi*t/p)
+ a_2_j[j] * cos(4*pi*t/p) + b_2_j[j] * sin(4*pi*t/p)
Both a_* and b_* are cosine/sine amplitudes — none of them appears in a denominator. The only divide-by-zero hazard is the period p, so leave p strictly positive. Zeroing all four amplitudes collapses the bracket to a constant 1.0, which is the canonical "seasonality off" form.
Prerequisites¶
laser-cholerais installed and importable aslaser.cholera.- You have a parameter dictionary or
modsoverlay that already builds a validPropertySetviaget_parameters(mods=...). - You know
npatchesfor your configuration. beta_j0_humis non-zero in at least one patch (otherwise the seasonal envelope multiplies zero and has no observable effect).
Steps¶
-
Pick the period
pin days. Use365for an annual cycle.pmust be a positive integer; never setp = 0(it is the denominator of2*pi*t/p). -
Set the first-mode amplitudes
a_1_jandb_1_j. These give one annual cycle, witha_1_jon the cosine andb_1_jon the sine. Both are length-npatchesvectors; typical magnitudes are in the0.1to0.3range. -
(Optional) Set the second-mode amplitudes
a_2_jandb_2_jto add a semi-annual cycle. Same shape as the first mode; typical magnitudes0.05to0.15. -
Verify the resulting envelope by evaluating the multiplier across one full period for one patch and plotting it.
Turning seasonality back off¶
Zero all four amplitudes; leave p at any positive integer (365 is fine):
mods["a_1_j"] = np.zeros(npatches)
mods["a_2_j"] = np.zeros(npatches)
mods["b_1_j"] = np.zeros(npatches)
mods["b_2_j"] = np.zeros(npatches)
mods["p"] = 365
The harmonic bracket collapses to 1.0 and the per-tick transmission rate becomes a flat beta_j0_hum.
Full example¶
import numpy as np
from laser.cholera.metapop.params import get_parameters
# Start from the bundled defaults to discover npatches.
defaults = get_parameters(None, do_validation=False)
npatches = len(defaults.location_name)
mods = {
"p": 365,
"a_1_j": np.full(npatches, 0.30, dtype=np.float32),
"b_1_j": np.full(npatches, 0.10, dtype=np.float32),
"a_2_j": np.full(npatches, 0.10, dtype=np.float32),
"b_2_j": np.full(npatches, 0.05, dtype=np.float32),
}
params = get_parameters(mods=mods)
t = np.arange(365)
j = 0
seasonal = (1
+ params.a_1_j[j] * np.cos(2 * np.pi * t / params.p)
+ params.b_1_j[j] * np.sin(2 * np.pi * t / params.p)
+ params.a_2_j[j] * np.cos(4 * np.pi * t / params.p)
+ params.b_2_j[j] * np.sin(4 * np.pi * t / params.p))
See also¶
- Human-to-human transmission parameter reference — full per-parameter shapes, ranges, and off-values for
beta_j0_hum,a_1_j,a_2_j,b_1_j,b_2_j, andp. - Seasonality explanation — why the two-mode harmonic, what each amplitude does to the envelope shape.
- Single-location tutorial — Step 5a turns seasonality on inside a guided build.