Source code for emodpy_generic.interventions.simple_sia

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

cases = -1
nodes = []
schema_path =  None

[docs]def SimpleSIA(camp, Event_Name = "SIA", timestep=1, Target_Age_Min=0.75, Target_Age_Max=5.0, Coverage=1.0, nods = []): """ Create an intervention that represents a highly-effective acquisition-blocking vaccination. :param Event_Name: :param timestep: WHEN to distribute the intervention. :param Target_Age_Min: WHO to distribute the intervention to (lower age bound). :param Target_Age_Max: WHO to distribute the intervention to (upper age bound). :param Coverage: WHO to distribute the intervention to (%age of population). :param nods: WHERE to distribute (list of nodes). 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( "StandardInterventionDistributionEventCoordinator", 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 ) ) #coordinator.Target_Demographic = "ExplicitAgeRanges" # implicit coordinator.Target_Age_Max=Target_Age_Max coordinator.Target_Age_Min=Target_Age_Min coordinator.Demographic_Coverage = Coverage event.Event_Coordinator_Config = coordinator # The intervention itself should be reused from another module # intervention = emodpy-generic.interventions.standard_generic_vaccine intervention = s2c.get_class_with_defaults( "Vaccine", schema_path ) efficacy_profile = "WaningEffect" waning = s2c.get_class_with_defaults( efficacy_profile, schema_path ) waning.Initial_Effect = 0.999 intervention.Acquire_Config = waning coordinator.Intervention_Config = intervention event.Start_Day = float(timestep+1) if len(nods) > 0: nodelist = do_nodes( camp, nods ) event["Event_Name"] = Event_Name return event
[docs]def new_intervention_as_file( timestep, filename=None ): """ This function mostly exists for testing so one can exercise the functionality in a single function call. """ camp.add( SimpleSIA( timestep, vaccine_type, iv_name ) ) if filename is None: filename = "sia.json" camp.save( filename ) return filename