Source code for emodpy_tbhiv.interventions.hiv_seeding

from emod_api import schema_to_class as s2c
from emodpy_tbhiv.interventions import purge_campaign_event

[docs]def seed( camp, disease= 'TB', coverage=0.01, reps= -1, interval=1, start_day=1, nodeIDs=[], time_offset=1, event_name='HIV Incidence'): """ Create a scheduled campaign event that issues an OutbreakIndividualTBorHIV intervention. Useful for seeding interventions in TBHIV_SIM. Args: camp: The :py:obj:`emod_api:emod_api.campaign` module instance which serves as the campaign accumulator. disease: "TB" or "HIV". Default is "TB" (used to be "HIV"). coverage: Percentage of otherwise qualifying individuals who will be infected. reps: Number of repetitions (integer). Defaults to no repetition. interval: Timesteps between repetitions, if reps is set. Defaults to every day. start_day: The timestep when this campaign event takes effect. Defaults to 1. nodeIDs: Optiona list of node ids to target. Defaults to all. time_offset: ... Defaults to 1. event_name: Not used. Returns: New campaign event that can be added to the campaign. """ schema_path = camp.schema_path iv_name = "OutbreakIndividualTBorHIV" event = s2c.get_class_with_defaults( "CampaignEvent", schema_path ) coordinator = s2c.get_class_with_defaults( "GroupInterventionDistributionEventCoordinatorHIV", schema_path ) if coordinator is None: print( "s2c.get_class_with_defaults returned None. Maybe no schema.json was provided." ) return "" intervention = s2c.get_class_with_defaults( iv_name, schema_path ) intervention.Infection_Type = disease event.Start_Day = float(start_day) coordinator.Time_Offset = time_offset coordinator.Number_Repetitions = reps coordinator.Timesteps_Between_Repetitions = interval event.Event_Coordinator_Config = coordinator coordinator.Intervention_Config = intervention purge_campaign_event( event ) return event
[docs]def new_intervention_as_file( camp, filename="hiv.json" ): camp.add( seed( camp ) ) camp.save( filename ) return filename