Source code for emodpy_generic.interventions.complex_import
from emod_api import schema_to_class as s2c
import json
schema_path = None
[docs]def ComplexImportationEvent(camp, dips=[1/(774*10)], durs=[100000], timestep=1, nods=[]):
"""
Seed infection (over time) in the modeled population.
Be careful when configuring import pressure in multi-node simulations. Daily_Import_Pressures defines a rate of
per-day importation for each node that the intervention is distributed to. In a 10 node simulation with
Daily_Import_Pressures = [0.1, 5.0], the total importation rate summed over all nodes will be 1/day and 50/day
during the two time periods. You must divide the per-day importation rates by the number of nodes. Note that
there is no control over the ages of the individuals imported, or their monte-carlo weight, like you might find
with the Outbreak intervention.
:param dips: DailyImportPressures. An array of rates of per-day importation (per-node).
:param durs: An array of durations over which to apply import pressure. Goes with dips.
:param timestep: WHEN: Day to start campaign event.
:param nods: WHERE: List of nodes at which infections will be seeded.
Returns:
Campaign event that can be added to campaign.
"""
if camp is not None:
schema_path = camp.schema_path
event = s2c.get_class_with_defaults( "CampaignEvent", schema_path )
coordinator = s2c.get_class_with_defaults( "StandardEventCoordinator", schema_path )
if coordinator is None:
print( "s2c.get_class_with_defaults returned None. Maybe no schema.json was provided." )
return ""
try:
coordinator.Max_Distributions_Per_Node = cases
except Exception as ex:
# This can be fine because this is a new parameter only in some branches.
# Obviously this question is more general and needs a better general solution
# if at all possible. Max_Distributions_Per_Node is an event coordinator optional param.
print( str( ex ) )
event.Event_Coordinator_Config = coordinator
intervention = s2c.get_class_with_defaults( "ImportPressure", schema_path )
coordinator.Intervention_Config = intervention
event.Start_Day = float(timestep+1)
if len( durs ) == 0:
Ex = ValueError()
Ex.strerror = "durations not set."
raise Ex
if len( dips ) == 0:
Ex = ValueError()
Ex.strerror = "daily_import_pressures not set."
raise Ex
if len( dips ) != len( durs ):
Ex = ValueError()
Ex.strerror = "durations and daily_import_pressures neeed to have same number of entries."
raise Ex
intervention.Durations = durs
intervention.Daily_Import_Pressures = dips
intervention.Import_Age=40*365 #Make these cases obvious by making them all exactly 40 years old
if len(nods) > 0:
nodelist = s2c.get_class_with_defaults( "NodeSetNodeList", schema_path )
nodelist.Node_List = nods
event.Nodeset_Config = nodelist
event["Event_Name"] = "Import 1 cases per 10 days somewhere on the network"
return event