EventKapitalRecover#
- class EventKapitalRecover(*, impact, recovery_time, recovery_function='linear', households_impact=None, name='Unnamed', occurrence=1, duration=1, event_monetary_factor=None)[source]#
Bases:
EventKapitalDestroyed
EventKapitalRecover holds a
EventKapitalDestroyed
event where the destroyed capital does not create a reconstruction demand.This subclass requires and enables new arguments to pass to the constructor:
A characteristic time for the recovery (
recovery_time
)Optionally a
recovery_function
(linear by default).
See also
Tutorial How to define Events
Methods
__init__
(*, impact, recovery_time[, ...])distribute_impact_by_gva
(impact_vec)Distribute a vector of impact by the GVA of affected industries.
distribute_impact_equally
(impact_vec)Distribute an impact equally between all affected regions.
from_dataframe
(impact, *[, occurrence, ...])Convenience function for DataFrames.
from_scalar_industries
(impact, *, industries)Creates an Event from a scalar and a list of industries affected.
from_scalar_regions_sectors
(impact, *, ...)Creates an Event from a scalar, a list of regions and a list of sectors affected.
from_series
(impact, *[, occurrence, ...])Create an event for an impact given as a pd.Series.
recovery
(current_temporal_unit)Attributes
Normalized final consumption matrix
Normalized intermediate consumption matrix
The industries affected by the event.
The array of regions affected by the event
The array of lexicographically ordered affected region indexes
The array of affected sectors by the event
The array of lexicographically ordered affected sectors indexes
The duration of the event.
GVA per (region,sector)
A pandas Series with all possible industries as index, holding the impact vector of the event.
The series specifying how damages are distributed among affected industries (regions,sectors)
The series specifying how damages are distributed among affected regions
Amount of unitary currency used in the MRIOT (e.g. 1000000 if in € millions).
MRIOT identification
The temporal unit of occurrence of the event.
List of final demand categories present in the MRIOT used by the model
List of regions present in the MRIOT used by the model
List of sectors present in the MRIOT used by the model
A boolean stating if an event can start recover
The recovery function used for recovery (Callable)
The (optional) array of productive_capital destroyed per industry (ie region x sector)
lexicographic region indexes
Fraction of total (regional) GVA for each sectors
lexicographic sector indexes
Maximum temporal unit simulated
Shape of the x (production) vector in the model
Shape of the Y (final demand) matrix in the model
Shape of the Z (intermediate consumption) matrix in the model
The monetary factor for the impact of the event (e.g. 10**6, 10**3, ...).
A pandas Series with all possible (regions, final_demand_cat) as index, holding the households impacts vector of the event.
An identifying name for the event (for convenience mostly)
States if the event happened
States if the event is over
Store relevant information about the event
- Y_distrib = array([], dtype=float64)#
Normalized final consumption matrix
- Z_distrib = array([], dtype=float64)#
Normalized intermediate consumption matrix
- property aff_industries#
The industries affected by the event.
- property aff_regions#
The array of regions affected by the event
- property aff_regions_idx#
The array of lexicographically ordered affected region indexes
- property aff_sectors#
The array of affected sectors by the event
- property aff_sectors_idx#
The array of lexicographically ordered affected sectors indexes
- classmethod distribute_impact_by_gva(impact_vec)#
Distribute a vector of impact by the GVA of affected industries.
Each values of the given impact are mutliplied by the share of the GVA the industry has over the GVA of all affected industries.
- Parameters:
- impact_vecpd.Series
The impact values to be reweigthed. Current use-case assumes all values are the total impact.
- Returns:
- pd.Series
The impact where each value was multiplied by the share of GVA of each affected industry (over total GVA affected).
- classmethod distribute_impact_equally(impact_vec)#
Distribute an impact equally between all affected regions.
Assume impact is given as a vector with all value being the total impact to distribute.
- Parameters:
- impact_vecpd.Series
The impact to distribute.
- Returns:
- pd.Series
The impact vector equally distributed among affected industries.
- property duration#
The duration of the event.
- classmethod from_dataframe(impact, *, occurrence=1, duration=1, name=None, **kwargs)#
Convenience function for DataFrames. See
from_series()
. This constructor only apply.squeeze()
to the given DataFrame.- Parameters:
- impactpd.DataFrame
A pd.DataFrame defining the impact per (region, sector)
- occurrenceint
The ordinal of occurrence of the event (requires to be > 0). Defaults to 1.
- durationint
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
- nameOptional[str]
A possible name for the event, for convenience. Defaults to None.
- **kwargs
Keyword arguments Other keyword arguments to pass to the instantiate method (depends on the type of event)
- Returns:
- Event
An Event object (or one of its subclass).
- Raises:
- ValueError
If impact cannot be squeezed to a Series
- classmethod from_scalar_industries(impact, *, industries, impact_industries_distrib=None, gva_distrib=False, occurrence=1, duration=1, name=None, **kwargs)#
Creates an Event from a scalar and a list of industries affected.
The scalar impact is distributed evenly by default. Otherwise it can be distributed proportionnaly to the GVA of affected industries, or to a custom distribution.
- Parameters:
- impactScalarImpact
The scalar impact.
- industriesIndustriesList
The list of industries affected by the impact.
- impact_industries_distribOptional[npt.ArrayLike]
A vector of equal size to the list of industries, stating the share of the impact each industry should receive. Defaults to None.
- gva_distribOptional[bool]
A boolean stating if the impact should be distributed proportionnaly to GVA. Defaults to False.
- occurrenceOptional[int]
The ordinal of occurrence of the event (requires to be > 0). Defaults to 1.
- durationOptional[int]
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
- nameOptional[str]
A possible name for the event, for convenience. Defaults to None.
- **kwargs
Keyword arguments Other keyword arguments to pass to the instantiate method (depends on the type of event)
- Returns:
- Event
An Event object or one of its subclass.
- Raises:
- ValueError
Raised if Impact is null, if len(industries) < 1 or if the sum of impact_industries_distrib differs from 1.0.
- classmethod from_scalar_regions_sectors(impact, *, regions, sectors, impact_regional_distrib=None, impact_sectoral_distrib=None, occurrence=1, duration=1, name=None, **kwargs)#
Creates an Event from a scalar, a list of regions and a list of sectors affected.
- Parameters:
- impactScalarImpact
The scalar impact.
- regionsRegionsList
The list of regions affected.
- sectorsSectorsList
The list of sectors affected in each region.
- impact_regional_distribOptional[npt.ArrayLike], optional
A vector of equal size to the list of regions affected, stating the share of the impact each industry should receive. Defaults to None.
- impact_sectoral_distribOptional[Union[str, npt.ArrayLike]], optional
Either:
"gdp"
, the impact is then distributed using the gross value added of each sector as a weight.A vector of equal size to the list of sectors affected, stating the share of the impact each industry should receive. Defaults to None.
- occurrenceint, optional
The ordinal of occurrence of the event (requires to be > 0). Defaults to 1.
- durationint, optional
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
- nameOptional[str], optional
A possible name for the event, for convenience. Defaults to None.
- **kwargs
Keyword arguments Other keyword arguments to pass to the instantiate method (depends on the type of event)
- Returns:
- Event
An Event object or one of its subclass.
- Raises:
- ValueError
Raise if Impact is null, if len(regions) or len(sectors) < 1,
- classmethod from_series(impact, *, occurrence=1, duration=1, name=None, **kwargs)#
Create an event for an impact given as a pd.Series.
- Parameters:
- impactpd.Series
A pd.Series defining the impact per (region, sector)
- occurrenceint
The ordinal of occurrence of the event (requires to be > 0). Defaults to 1.
- durationint
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
- nameOptional[str]
A possible name for the event, for convenience. Defaults to None.
- **kwargs
Keyword arguments keyword arguments to pass to the instantiating method
- (depends on the type of event).
- Returns:
- Event
An Event object or one of its subclass
- Raises:
- ValueError
Raised if impact is empty of contains negative values.
Examples
>>> import pandas as pd >>> import pymrio as pym >>> from boario.simulation import Simulation >>> from boario.extended_model import ARIOPsiModel >>> from boario.event import EventKapitalRecover >>> >>> mriot = pym.load_test() >>> mriot.calc_all() >>> >>> impact_series = pd.Series({('reg1', 'electricity'): 100000.0, ('reg1', 'mining'): 50000.0}) >>> model = ARIOPsiModel(mriot) >>> sim = Simulation(model) >>> event = EventKapitalRecover.from_series(impact_series, occurrence=5, duration=10, recovery_time=30, name="Event 1") >>> sim.add_event(event)
- gva_df = Series([], dtype: float64)#
GVA per (region,sector)
- property impact_df#
A pandas Series with all possible industries as index, holding the impact vector of the event. The impact is defined for each sectors in each region.
- property impact_industries_distrib#
The series specifying how damages are distributed among affected industries (regions,sectors)
- property impact_regional_distrib#
The series specifying how damages are distributed among affected regions
- model_monetary_factor = 1#
Amount of unitary currency used in the MRIOT (e.g. 1000000 if in € millions)
- mrio_name = ''#
MRIOT identification
- property occurrence#
The temporal unit of occurrence of the event.
- possible_final_demand_cat = Index([], dtype='object')#
List of final demand categories present in the MRIOT used by the model
- possible_regions = Index([], dtype='object')#
List of regions present in the MRIOT used by the model
- possible_sectors = Index([], dtype='object')#
List of sectors present in the MRIOT used by the model
- property regional_sectoral_productive_capital_destroyed#
The (optional) array of productive_capital destroyed per industry (ie region x sector)
- regions_idx = array([], dtype=float64)#
lexicographic region indexes
Fraction of total (regional) GVA for each sectors
- sectors_idx = array([], dtype=float64)#
lexicographic sector indexes
- temporal_unit_range = 0#
Maximum temporal unit simulated
- x_shape = (0, 0)#
Shape of the x (production) vector in the model
- y_shape = (0, 0)#
Shape of the Y (final demand) matrix in the model
- z_shape = (0, 0)#
Shape of the Z (intermediate consumption) matrix in the model
- households_impact_df#
A pandas Series with all possible (regions, final_demand_cat) as index, holding the households impacts vector of the event. The impact is defined for each region and each final demand category.
- name#
An identifying name for the event (for convenience mostly)
- happened#
States if the event happened
- over#
States if the event is over
- event_dict#
Store relevant information about the event
- event_monetary_factor#
The monetary factor for the impact of the event (e.g. 10**6, 10**3, …)
- property recoverable#
A boolean stating if an event can start recover
- property recovery_function#
The recovery function used for recovery (Callable)