Skip to content

Commit

Permalink
New cholera branch. Started to make more cholera-like. 1) Removed EUL…
Browse files Browse the repository at this point in the history
…A-ification; 2) Added waning immunity upon recovery (too short at first, to test); 3) Fixed some math bugs in enviro transmission.
  • Loading branch information
Jonathan Bloedow committed Sep 11, 2024
1 parent c37e473 commit 8924700
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 32 deletions.
12 changes: 6 additions & 6 deletions nnmm/cholera.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ class Model:
from idmlaser.utils import PropertySet

meta_params = PropertySet({
"ticks": int(365*10),
"ticks": int(365*2),
"cbr": 40, # Nigeria 2015 according to (somewhat random internet source): https://fred.stlouisfed.org/series/SPDYNCBRTINNGA
"output": Path.cwd() / "outputs",
"eula_age": 5
#"eula_age": 5
})
# parameter?
prevalence = 0.025 # 2.5% prevalence

measles_params = PropertySet({
"exp_mean": np.float32(7.0),
"exp_mean": np.float32(2.0),
"exp_std": np.float32(1.0),
"inf_mean": np.float32(7.0),
"inf_std": np.float32(1.0),
"inf_mean": np.float32(6.0),
"inf_std": np.float32(2.0),
"r_naught": np.float32(14.0),
"seasonality_factor": np.float32(0.125),
"seasonality_phase": np.float32(182),
"ri_coverage": np.float32(0.75),
"beta_env": np.float32(0.1), # beta(j,0) -- The baseline rate of environment-to-human transmission (all destinations)
"beta_env": np.float32(1.0), # beta(j,0) -- The baseline rate of environment-to-human transmission (all destinations)
"kappa": np.float32(5e5), # The concentration (number of cells per mL) of V. cholerae required for a 50% probability of infection.
})

Expand Down
12 changes: 0 additions & 12 deletions nnmm/measles.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
commit 2ce4764876daa91d69b2212c02d1bec3b5b8ec7e
Author: Christopher Lorton <christopher.lorton@gatesfoundation.org>
Date: Fri Aug 2 15:45:04 2024 -0700

Add plain script of FUSION code.

diff --git a/nnmm/measles.py b/nnmm/measles.py
new file mode 100644
index 0000000..3ec43ae
--- /dev/null
++ b/nnmm/measles.py
@@ -0,0 +1,1194 @@
#!/usr/bin/env python
# coding: utf-8

Expand Down
6 changes: 3 additions & 3 deletions nnmm/measles_cache_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,9 @@ def save_initial_pop():
tfinish = datetime.now(tz=None) # noqa: DTZ005
delta = tfinish - tstart
metrics.append(delta.seconds * 1_000_000 + delta.microseconds) # delta is a timedelta object, let's convert it to microseconds
#if tick == 1824: # 365*5:
#model.population.save(filename="pop_5yrs.hd5", tail_number=total_births)
#model.population.save_npz(filename="pop_5yrs.npz", tail_number=total_births)
#if tick == 1824: # 365*5:
#model.population.save(filename="pop_5yrs.hd5", tail_number=total_births)
#model.population.save_npz(filename="pop_5yrs.npz", tail_number=total_births)
model.metrics.append(metrics)


Expand Down
13 changes: 8 additions & 5 deletions nnmm/mods/intrahost.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ def do_exposure_update(model, tick):
return


@nb.njit((nb.uint32, nb.uint8[:]), parallel=True)
def _infection_update(count, itimers):
@nb.njit((nb.uint32, nb.uint8[:], nb.uint16[:], nb.uint8[:]), parallel=True)
def _infection_update(count, itimer, sus_timer, susceptibility):
for i in nb.prange(count):
if itimers[i] > 0:
itimers[i] -= 1
if itimer[i] > 0:
itimer[i] -= 1
if itimer[i] <= 0:
susceptibility = 0
sus_timer[i] = 1*365

return

def do_infection_update(model, tick):

_infection_update(nb.uint32(model.population.count), model.population.itimer)
_infection_update(nb.uint32(model.population.count), model.population.itimer, model.population.susceptibility_timer, model.population.susceptibility)

return

Expand Down
2 changes: 1 addition & 1 deletion nnmm/mods/maternal_immunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def init( model, istart, iend ):
model.population.susceptibility_timer[istart:iend] = int(0.5*365) # 6 months

# Define the function to decrement susceptibility_timer and update susceptibility
@nb.njit((nb.uint32, nb.uint8[:], nb.uint8[:]), parallel=True)
@nb.njit((nb.uint32, nb.uint16[:], nb.uint8[:]), parallel=True)
def _update_susceptibility_based_on_sus_timer_nb(count, susceptibility_timer, susceptibility):
for i in nb.prange(count):
if susceptibility_timer[i] > 0:
Expand Down
10 changes: 6 additions & 4 deletions nnmm/mods/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ def do_transmission_update(model, tick) -> None:
# This reduces the amount of environmental contagion each timestep
# HARDCODE FOR NOW
nodes.enviro_contagion *= (1 - 0.5)

# Add newly shed contagion to the environmental contagion
# This accumulates the current infections into the environmental contagion
# (Assuming `contagion` represents newly shed contagion at each node)
# TBD: Use zeta to calculate environmentally shed contagion vs contact shed contagion
nodes.enviro_contagion += contagion

nodes.enviro_contagion *= 1-model.nodes.WASH_fraction

# Calculate the effective environmental transmission rate for all nodes at the current timestep
beta_env_effective = get_enviro_beta_from_psi(model.params.beta_env, model.nodes.psi[:, tick])
Expand All @@ -155,17 +157,17 @@ def do_transmission_update(model, tick) -> None:

# Normalize the environmental forces by dividing by the population at each node
# This scales the environmental forces to be a probability per individual
forces_environmental /= model.nodes.population[:, tick]
#forces_environmental /= model.nodes.population[:, tick]

# Combine the contact transmission forces with the environmental transmission forces
# `forces` are the contact transmission forces calculated elsewhere
# `forces_environmental` are the environmental transmission forces computed in this section
total_forces = forces + forces_environmental
total_forces = (forces + forces_environmental).astype(np.float32)

tx_inner(
population.susceptibility,
population.nodeid,
forces,
total_forces,
population.etimer,
population.count,
model.params.exp_mean,
Expand Down
2 changes: 1 addition & 1 deletion nnmm/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ri_timer": np.uint16,
"etimer": np.uint8,
"itimer": np.uint8,
"susceptibility_timer": np.uint8,
"susceptibility_timer": np.uint16,
"accessibility": np.uint8
}

0 comments on commit 8924700

Please sign in to comment.