EventTracker#
- class EventTracker(sim, source_event, indus_rebuild_distribution=None, house_rebuild_distribution=None)[source]#
Bases:
object
Tracks the state and progression of an event within a simulation, including damages, recovery, and rebuilding demands.
- Parameters:
- simSimulation
The simulation object where the event is tracked.
- source_eventEvent
The source event to be tracked.
- indus_rebuild_distributionpd.DataFrame, None, or Literal[“equal”], optional
Specifies the distribution of rebuilding demand across industries, default is None.
- house_rebuild_distributionpd.DataFrame, None, or Literal[“equal”], optional
Specifies the distribution of rebuilding demand across households, default is None.
Attributes
sim
(Simulation) Reference to the simulation where the event takes place.
event
(Event) The event being tracked.
_status
({“pending”, “happening”, “recovering”, “rebuilding”, “finished”}) Current status of the event.
_prod_delta_from_arb_0
(pd.Series or None) Initial production delta for arbitrary production events.
_prod_delta_from_arb
(pd.Series or None) Current production delta for arbitrary production events.
_indus_dmg_0
(pd.Series or None) Initial industrial damages caused by the event.
_indus_dmg
(pd.Series or None) Current industrial damages from the event.
_rebuildable
(bool) Indicates if the event is eligible for rebuilding.
_rebuild_id
(int or None) Unique identifier for rebuilding actions.
_rebuild_shares
(pd.Series or None) Distribution shares for rebuilding demands.
_rebuild_demand_indus_0
(pd.DataFrame or None) Initial rebuilding demand for industries.
_rebuild_demand_house_0
(pd.DataFrame or None) Initial rebuilding demand for households.
_rebuild_demand_indus
(pd.DataFrame or None) Current rebuilding demand for industries.
_distributed_reb_dem_indus
(pd.DataFrame or None) Distributed demand for rebuilding industries.
_rebuild_demand_house
(pd.DataFrame or None) Current rebuilding demand for households.
_distributed_reb_dem_house
(pd.DataFrame or None) Distributed demand for rebuilding households.
_recovery_function
(Callable or None) Function to compute recovery over time.
_house_dmg_0
(pd.Series or None) Initial household damages from the event.
_house_dmg
(pd.Series or None) Current household damages.
Methods
__init__
(sim, source_event[, ...])receive_house_rebuilding
(reb_prod)Processes and updates the household rebuilding demand based on received production.
receive_indus_rebuilding
(reb_prod)Processes and updates the industry rebuilding demand based on received production.
recover
()Applies the recovery function to update the damages over time based on the recovery rate of the event.
Attributes
Gets the index of industries affected by the event.
Gets the index of regions affected by the event.
Gets the index of sectors affected by the event.
Gets the distributed rebuilding demand for households.
Gets the current rebuilding demand for households.
Gets the distributed rebuilding demand for industries.
Gets the current rebuilding demand for industries.
Gets the current household damage for the event.
Gets the initial household damage for the event.
Returns the impact vector of the event.
Gets the current production delta for arbitrary production loss events.
Gets the current productive capital damage.
Gets the initial productive capital damage from the event.
Gets the distribution for rebuilding household demand.
Gets the distribution for rebuilding industry demand.
Gets the current rebuilding demand for households.
Gets the current rebuilding demand for industries.
Gets the index of all rebuilding industries involved in the event.
Gets the index of rebuilding industries that were impacted by the event.
Gets the index of rebuilding industries not impacted by the event.
Gets the index of sectors involved in rebuilding for the event.
Gets the recovery function associated with the event.
Gets the current status of the event.
- property impact_vector#
Returns the impact vector of the event.
- Returns:
- pd.Series
The event impact, formatted as a series with all industries as index.
- property productive_capital_dmg_init#
Gets the initial productive capital damage from the event.
- Returns:
- pd.Series or None
Series of initial damages to productive capital; None if not available.
- property productive_capital_dmg#
Gets the current productive capital damage.
- Returns:
- pd.Series or None
Series of current damages to productive capital; None if not available.
- property households_damages_init#
Gets the initial household damage for the event.
- Returns:
- pd.Series or None
Series of initial damages to households; None if not available.
- property households_damages#
Gets the current household damage for the event.
- Returns:
- pd.Series or None
Series of initial damages to households; None if not available.
- property rebuild_demand_indus#
Gets the current rebuilding demand for industries.
- Returns:
- pd.DataFrame or None
DataFrame of rebuilding demands for industries; None if not applicable.
- property rebuild_demand_house#
Gets the current rebuilding demand for households.
- Returns:
- pd.DataFrame or None
DataFrame of rebuilding demands for households; None if not applicable.
- property prod_delta_arbitrary#
Gets the current production delta for arbitrary production loss events.
- Returns:
- pd.Series or None
Series representing production changes; None if not available.
- property status#
Gets the current status of the event.
- Returns:
- {“pending”, “happening”, “recovering”, “rebuilding”, “finished”}
The status indicating the stage of the event.
- property rebuild_dem_indus_distribution#
Gets the distribution for rebuilding industry demand.
- Returns:
- pd.DataFrame or None
Distribution DataFrame for rebuilding industry demand; None if not set.
- property distributed_reb_dem_indus_tau#
Gets the current rebuilding demand for industries.
- Returns:
- pd.DataFrame or None
DataFrame of rebuilding demands for industries; None if not applicable.
- property distributed_reb_dem_house_tau#
Gets the current rebuilding demand for households.
- Returns:
- pd.DataFrame or None
DataFrame of rebuilding demands for households; None if not applicable.
- property distributed_reb_dem_indus#
Gets the distributed rebuilding demand for industries.
- Returns:
- pd.DataFrame or None
Distributed DataFrame for rebuilding industry demand; None if not set.
- receive_indus_rebuilding(reb_prod)[source]#
Processes and updates the industry rebuilding demand based on received production.
- Parameters:
- reb_prodpd.DataFrame or npt.ArrayLike
Rebuilding production to apply to industry demands.
- Raises:
- ValueError
If reb_prod is None, or if rebuilding demand does not exist or event is not a rebuilding event.
- property rebuild_dem_house_distribution#
Gets the distribution for rebuilding household demand.
- Returns:
- pd.DataFrame or None
Distribution DataFrame for rebuilding household demand; None if not set.
- property distributed_reb_dem_house#
Gets the distributed rebuilding demand for households.
- Returns:
- pd.DataFrame or None
Distributed DataFrame for rebuilding household demand; None if not set.
- receive_house_rebuilding(reb_prod)[source]#
Processes and updates the household rebuilding demand based on received production.
- Parameters:
- reb_prodpd.DataFrame or npt.ArrayLike
Rebuilding production to apply to household demands.
- Raises:
- ValueError
If reb_prod is None, or if household rebuilding demand does not exist or event is not a rebuilding event.
- recover()[source]#
Applies the recovery function to update the damages over time based on the recovery rate of the event.
- Raises:
- ValueError
If the event is not a recoverable type (i.e., not a capital or production recovery event).
- property recovery_function#
Gets the recovery function associated with the event.
- Returns:
- Callable or None
Function to calculate recovery over time, if applicable.
- property affected_sectors_idx#
Gets the index of sectors affected by the event.
- Returns:
- npt.NDArray
Array of indices representing affected sectors.
- property affected_regions_idx#
Gets the index of regions affected by the event.
- Returns:
- npt.NDArray
Array of indices representing affected regions.
- Raises:
- ValueError
If some affected regions are not found in the model.
- property affected_industries_idx#
Gets the index of industries affected by the event.
- Returns:
- npt.NDArray
Array of indices representing affected industries.
- property rebuilding_sectors_idx#
Gets the index of sectors involved in rebuilding for the event.
- Returns:
- npt.NDArray
Array of indices representing rebuilding sectors.
- Raises:
- ValueError
If the event is not a rebuilding event or if some rebuilding sectors are not found in the model.
- property rebuilding_industries_idx_impacted#
Gets the index of rebuilding industries that were impacted by the event.
- Returns:
- npt.NDArray
Array of indices representing rebuilding industries impacted by the event.
- property rebuilding_industries_idx_not_impacted#
Gets the index of rebuilding industries not impacted by the event.
- Returns:
- npt.NDArray
Array of indices representing rebuilding industries not impacted by the event.
- property rebuilding_industries_idx_all#
Gets the index of all rebuilding industries involved in the event.
- Returns:
- npt.NDArray
Array of indices representing all rebuilding industries for the event.