[docs]defDistributeIVByRefTrackCoord(camp,Start_Year,Intervention_Config,Time_Value_Map,Tracking_Config,Targeting_Config=None,End_Year=None,node_ids=None,Node_Property_Restrictions=None,Property_Restrictions=None,Property_Restrictions_Within_Node=None,Target_Age_Max=None,Target_Age_Min=None,Target_Demographic="Everyone",Target_Gender="All",Target_Residents_Only=None,Update_Period=365):""" Create and return a ReferenceTrackingEventCoordinatorTrackingConfig EventCoordinator. Args: camp: emod_api.campaign object with schema_path set. Start_Year: When to start. Intervention_Config: Valid intervention to be distributed together as necessary to track coverage targets. Can be single intervention or list (list is useful where you want a co-event). If list, actual intervention should be first. Time_Value_Map: A pairing of time (in years) and the fraction of the targeted group to have the attribute specified by Tracking_Config at that time. E.g. {"1960": 0.1, "1970": 0.2, "1980": 0.3} Tracking_Config: Defines the attribute to be tracked within the targeted group; the intervention will be distributed to people without the attribute, if coverage is below the target level the time of polling. Targeting_Config: Allows you to specify more detail on the targeted group that you want to have the given attribute. End_Year: When to end. node_ids: Nodes to target with this intervention, return from utils.do_nodes(). Node_Property_Restrictions: A list of NodeProperty key:value pairs. A node must have the value for the given key in order for its humans to be considered. Property_Restrictions: Individual Properties a person must have to receive the intervention(s). Property_Restrictions_Within_Node: A list of the IndividualProperty key:value pairs, as defined in the demographics file, that individuals must have to be targeted by this intervention. Target_Age_Max: Maximum age (in years). Target_Age_Min: Minimum age (in years). Target_Demographic: Everyone, ExplicitAgeRanges, ExplicitAgeRangesAndGender, etc. Target_Gender: All, Male, or Female. Target_Residents_Only: Distribute intervention only to individuals that began the simulation in the node. Update_Period: This duration between distributions is used to calculate the number of timesteps between distributions (= lower_bound ( Update_Period / dt )). Values < 2*dt result in one distribution per time step, to get one distribution every two timesteps set 3*dt > Update_Period > 2*dt. Returns: ReadOnlyDict: ReferenceTrackingEventCoordinatorTrackingConfig EventCoordinator ready to be added to a campaign. """ifProperty_RestrictionsandProperty_Restrictions_Within_Node:raiseValueError("Cannot set both Property_Restrictions and Property_Restrictions_Within_Node")ifTarget_Demographic=="ExplicitAgeRanges"orTarget_Demographic=="ExplicitAgeRangesAndGender":ifTarget_Age_MinisNoneorTarget_Age_MaxisNone:raiseValueError("Target_Age_Min and Target_Age_Max need to be set when setting Target_Demographic == 'ExplicitAgeRanges' or 'ExplicitAgeRangesAndGender'")globalschema_pathschema_path=(camp.schema_pathifcampisnotNoneelseschema_path)event=s2c.get_class_with_defaults("CampaignEventByYear",schema_path)coordinator=s2c.get_class_with_defaults("ReferenceTrackingEventCoordinatorTrackingConfig",schema_path)event.Event_Coordinator_Config=coordinatorevent.Start_Year=float(Start_Year)# create two lists from TimeValueMap, one for keys and one for valuesk,v=[list(elem)foreleminzip(*Time_Value_Map.items())]coordinator.Time_Value_Map.Times,coordinator.Time_Value_Map.Values=[float(k)forkink],vcoordinator.Tracking_Config=Tracking_Configcoordinator.Targeting_Config=Targeting_Config# Intervention can be single or list. If list, we bundle into a M.I.D.iftype(Intervention_Config)islist:mid=comm.MultiInterventionDistributor(camp,Intervention_Config)Intervention_Config=midcoordinator.Intervention_Config=Intervention_ConfigifProperty_RestrictionsisnotNone:coordinator.Property_Restrictions=Property_RestrictionselifProperty_Restrictions_Within_NodeisnotNone:coordinator.Property_Restrictions_Within_Node=Property_Restrictions_Within_Nodeprs=utils._convert_prs(Property_Restrictions)iflen(prs)>0andtype(prs[0])isdict:coordinator.Property_Restrictions_Within_Node=prscoordinator.pop("Property_Restrictions")else:coordinator.Property_Restrictions=prscoordinator.pop("Property_Restrictions_Within_Node")coordinator.End_Year=End_Yearcoordinator.Node_Property_Restrictions=Node_Property_Restrictionscoordinator.Target_Age_Min=Target_Age_Min# if None, defaults from schema are usedcoordinator.Target_Age_Max=Target_Age_Maxcoordinator.Target_Gender=Target_Gendercoordinator.Target_Demographic=Target_Demographiccoordinator.Target_Residents_Only=Target_Residents_Onlycoordinator.Update_Period=Update_Periodevent.Nodeset_Config=utils.do_nodes(camp.schema_path,node_ids)returnevent