emodpy.campaign.event module#
- class emodpy.campaign.event.BaseEvent(coordinator: BaseEventCoordinator, event_class_name: str, event_name: str, node_ids: List[int] | None = None)[source]#
Bases:
object
Base class for CampaignEvent and CampaignEventByYear. The “Events” array in the campaign.json file is a list of these objects. They define the “when” and “where” an intervention is to be distributed.
- Parameters:
coordinator (BaseEventCoordinator, required) –
An EventCoordinator object that determines “who”, “what”, and “why” an intervention is distributed.
It specifies which Event Coordinator class will handle the event, and then configures the coordinator.
event_class_name (str, required) –
The event class name, i.e. CampaignEvent or CampaignEventByYear
event_name (str, optional) –
The name of the event.
Defaults to “Campaign_Event”.
node_ids (Optional[List[int]], optional) –
A list of node IDs where the EventCoordinator will consider distributing the intervention in.
If None, then all nodes will be considered
Defaults to None.
- Returns:
None
- to_schema_dict(campaign: <module 'emod_api.campaign' from '/home/docs/checkouts/readthedocs.org/user_builds/institute-for-disease-modeling-emodpy/envs/latest/lib/python3.9/site-packages/emod_api/campaign.py'>) ReadOnlyDict [source]#
Return a CampaignEvent or CampaignEventByYear event with the specified parameters.
- Parameters:
campaign (api_campaign, required) –
The campaign object to which the event will be added. This should be an instance of the emod_api.campaign class.
- Returns:
The CampaignEvent or CampaignEventByYear event.
- Return type:
s2c.ReadOnlyDict
- class emodpy.campaign.event.CampaignEventByYear(coordinator: BaseEventCoordinator, start_year: float, event_name: str | None = None, node_ids: List[int] | None = None)[source]#
Bases:
BaseEvent
The CampaignEventByYear event class determines when to distribute the intervention based on the calendar year.
- Parameters:
coordinator (BaseEventCoordinator, required) –
An EventCoordinator object that determines “who”, “what”, and “why” an intervention is distributed.
It specifies which Event Coordinator class will handle the event, and then configures the coordinator.
start_year (float, required) –
The absolute year of the simulation to activate the event’s event coordinator.
To have the intervention applied other than at the beginning of the year, you must enter a decimal value after the year. For example, 2010.5 would have the intervention applied halfway through the year 2010.
Maximum value is 2200
Minimum value is 1900
event_name (str, optional) –
The name of the event.
Defaults to None.
node_ids (Optional[List[int]], optional) –
A list of node IDs where the EventCoordinator will consider distributing the intervention in.
If None, then all nodes will be considered
Defaults to None.
- to_schema_dict(campaign: <module 'emod_api.campaign' from '/home/docs/checkouts/readthedocs.org/user_builds/institute-for-disease-modeling-emodpy/envs/latest/lib/python3.9/site-packages/emod_api/campaign.py'>) ReadOnlyDict [source]#
Return a CampaignEventByYear event with the specified parameters.
- Parameters:
campaign (api_campaign, required) –
The campaign object to which the event will be added. This should be an instance of the emod_api.campaign class.
- Returns:
The CampaignEvent or CampaignEventByYear event.
- Return type:
s2c.ReadOnlyDict
- is_year_supported(campaign: <module 'emod_api.campaign' from '/home/docs/checkouts/readthedocs.org/user_builds/institute-for-disease-modeling-emodpy/envs/latest/lib/python3.9/site-packages/emod_api/campaign.py'>) bool [source]#
Check if the year is supported by the campaign.
- Parameters:
campaign (api_campaign, required) –
The campaign object to which the event will be added. This should be an instance of the emod_api.campaign class.
- Returns:
True if the year is supported, otherwise False.
- Return type:
- class emodpy.campaign.event.CampaignEvent(coordinator: BaseEventCoordinator, start_day: float, event_name: str | None = None, node_ids: List[int] | None = None)[source]#
Bases:
BaseEvent
The CampaignEvent event class determines when to distribute the intervention based on the day of the simulation.
- Parameters:
coordinator (BaseEventCoordinator, required) –
An EventCoordinator object that determines “who”, “what”, and “why” an intervention is distributed.
It specifies which Event Coordinator class will handle the event, and then configures the coordinator.
start_day (float, required) –
The absolute day of the simulation to activate the event’s event coordinator.
Maximum value is 3.40282e+38
Minimum value is 0
event_name (str, optional) –
The name of the event.
Defaults to None.
node_ids (Optional[List[int]], optional) –
A list of node IDs where the EventCoordinator will consider distributing the intervention in.
If None, then all nodes will be considered
Defaults to None.
- to_schema_dict(campaign: <module 'emod_api.campaign' from '/home/docs/checkouts/readthedocs.org/user_builds/institute-for-disease-modeling-emodpy/envs/latest/lib/python3.9/site-packages/emod_api/campaign.py'>) ReadOnlyDict [source]#
Return a CampaignEvent event with the specified parameters.
- Parameters:
campaign (api_campaign, required) –
The campaign object to which the event will be added. This should be an instance of the emod_api.campaign class.
- Returns:
The CampaignEvent or CampaignEventByYear event.
- Return type:
s2c.ReadOnlyDict
- emodpy.campaign.event.create_campaign_event(campaign: <module 'emod_api.campaign' from '/home/docs/checkouts/readthedocs.org/user_builds/institute-for-disease-modeling-emodpy/envs/latest/lib/python3.9/site-packages/emod_api/campaign.py'>, coordinator: ~emodpy.campaign.event_coordinator.BaseEventCoordinator, event_name: str | None = None, node_ids: ~typing.List[int] | None = None, start_day: float | None = None, start_year: float | None = None) BaseEvent [source]#
Create a CampaignEvent or CampaignEventByYear event with the specified parameters and return it.