Source code for emodpy_tbhiv.interventions.ramp_dtn

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

[docs]def RampDTN( camp, trigger_treatment_list, ramp_time=30, base_sensitivity_smearpos=1.0, base_sensitivity_smearneg=1.0, base_sensitivity_smearpos2=1.0, base_sensitivity_smearneg2=1.0, treatment_fraction=1.0, treatment_fraction2=1.0, pos_event= 'TBTestPositive', neg_event= 'TBTestNegative', defaulters_event='TBTestDefault', pos_event2='TBTestPositive', neg_event2='TBTestNegative', defaulters_event2='TBTestDefault', start_day=1, duration=-1, property_restrictions_list=[], nodeIDs=[], black_period=0, black_trigger='Blackout', event_name='RampDTN'): """ Create and return triggered campaign event that (TBD). Args: camp: The :py:obj:`emod_api:emod_api.campaign` module instance which serves as the campaign accumulator. trigger_treatment_list: List of 1 or more triggers (or events or signals) which are listened to and trigger the distribution of the intervention. There is no default. active_sensitivity: Sensitivity. Defaults to 1.0. active_specificity: Specificity. Defaults to 1.0. pos_event: Signal (or trigger) which is broadcast if the test is positive. Defaults to 'TBTestPositive', treatment_fraction: Fraction of population testing positive you get the positive result effect. start_day: The timestep when this campaign event takes effect. Defaults to 1. duration: How long the campaign event remains in effect. Defaults to forever. property_restrictions_list: Optiional list of Individual Properties to limit the intervention to. nodeIDs: Optiona list of node ids to target. Defaults to all. black_period: Undocumented. black_trigger: Undocumented. event_name: Undocumented. Returns: New campaign event that can be added to the campaign. """ schema_path = camp.schema_path # First, get the objects 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 "" intervention1 = s2c.get_class_with_defaults( "DiagnosticTreatNeg", schema_path ) intervention2 = s2c.get_class_with_defaults( "DiagnosticTreatNeg", schema_path ) meta_intervention = s2c.get_class_with_defaults( "NodeLevelHealthTriggeredIVScaleUpSwitch", schema_path ) #meta_intervention.Demographic_Coverage=coverage meta_intervention.Duration=duration meta_intervention.Trigger_Condition_List = [camp.get_recv_trigger(e) for e in trigger_treatment_list] meta_intervention.Blackout_Period = black_period meta_intervention.Blackout_Event_Trigger = black_trigger meta_intervention.Property_Restrictions = property_restrictions_list meta_intervention.Primary_Time_Constant = ramp_time meta_intervention.Demographic_Coverage_Time_Profile = 'Linear' meta_intervention.Initial_Demographic_Coverage = 0 meta_intervention.Actual_IndividualIntervention_Config = intervention1 meta_intervention.Not_Covered_IndividualIntervention_Configs = [ intervention2 ] meta_intervention.pop("Actual_NodeIntervention_Config") meta_intervention.pop("Node_Property_Restrictions") meta_intervention.pop("Property_Restrictions_Within_Node") # Second, hook them up event.Event_Coordinator_Config = coordinator coordinator.Intervention_Config = meta_intervention event.Start_Day = float(start_day) # Third, do the actual settings intervention1.Base_Sensitivity = base_sensitivity_smearpos intervention1.Base_Specificity = 1.0 - base_sensitivity_smearneg intervention1.Treatment_Fraction = treatment_fraction intervention1.Event_Or_Config = 'Event' intervention1.Positive_Diagnosis_Event = camp.get_send_trigger( pos_event ) intervention1.Negative_Diagnosis_Event = camp.get_send_trigger( neg_event ) intervention1.Defaulters_Event = camp.get_send_trigger( defaulters_event ) intervention2.Base_Sensitivity = base_sensitivity_smearpos2 intervention2.Base_Specificity = 1.0 - base_sensitivity_smearneg2 intervention2.Treatment_Fraction = treatment_fraction2 intervention2.Event_Or_Config = 'Event' intervention2.Positive_Diagnosis_Event = camp.get_send_trigger(pos_event2) intervention2.Negative_Diagnosis_Event = camp.get_send_trigger(neg_event2) intervention2.Defaulters_Event = camp.get_send_trigger(defaulters_event2) purge_campaign_event( event ) return event
[docs]def new_intervention_as_file( camp, filename="ramp.json" ): camp.add( RampDTN( camp, trigger_treatment_list=[ "Births" ] ) ) camp.save( filename ) return filename