Source code for emodpy_measles.interventions.complex_import

from emod_api import schema_to_class as s2c
from emod_api.interventions import utils


[docs]def ComplexImportationEvent(camp, dips=[1/(774*10)], durs=[100000], timestep=1, nodes=None): """Import the Disease :param DailyImportPressures: How Much? A rate of per-day importation for each node that the intervention is distributed to. :param Durations: How Long? The durations over which to apply import pressure. :param timestep: When? Day to start campaign event. :param nodes: Where? Geographic nodes to target. 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. """ event = s2c.get_class_with_defaults( "CampaignEvent", camp.schema_path ) coordinator = s2c.get_class_with_defaults( "StandardEventCoordinator", camp.schema_path ) if coordinator is None: print( "s2c.get_class_with_defaults returned None. Maybe no schema.json was provided." ) return "" event.Event_Coordinator_Config = coordinator intervention = s2c.get_class_with_defaults( "ImportPressure", camp.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 nodes and len(nodes) > 0: event.Nodeset_Config = utils.do_nodes( camp.schema_path, nodes ) event["Event_Name"] = "Import 1 cases per 10 days somewhere on the network" return event
[docs]def new_intervention_as_file( camp, timestep, filename=None ): camp.add( ComplexImportationEvent( camp, timestep=timestep ) ) if filename is None: filename = "complex_import.json" camp.save( filename ) return filename