EventKapitalDestroyed#

class EventKapitalDestroyed(*, impact, households_impact=None, name='Unnamed', occurrence=1, duration=1, event_monetary_factor=None)[source]#

Bases: Event, ABC

EventKapitalDestroyed is an abstract class to hold events with where some capital (from industries or households) is destroyed. See EventKapitalRecover and EventKapitalRebuild for its instantiable classes.

Note

For this type of event, the impact value represent the amount of capital destroyed in monetary terms.

Note

We distinguish between impacts on household and industrial (productive) capital. We assume destruction of the former not to reduce production capacity contrary to the latter (but possibly induce reconstruction demand). Impacts on household capital is null by default, but can be set via the households_impacts argument in the constructor. The amount of production capacity lost is computed as the share of capital lost over total capital of the industry.

Note

The user can specify a monetary factor via the event_monetary_factor argument for the event if it differs from the monetary factor of the MRIOT used. By default the constructor assumes the two factors to be the same (i.e., if the MRIOT is in €M, the so is the impact).

See also

Tutorial How to define Events

Methods

__init__(*, impact[, households_impact, ...])

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.

Attributes

Y_distrib

Normalized final consumption matrix

Z_distrib

Normalized intermediate consumption matrix

aff_industries

The industries affected by the event.

aff_regions

The array of regions affected by the event

aff_regions_idx

The array of lexicographically ordered affected region indexes

aff_sectors

The array of affected sectors by the event

aff_sectors_idx

The array of lexicographically ordered affected sectors indexes

duration

The duration of the event.

gva_df

GVA per (region,sector)

impact_df

A pandas Series with all possible industries as index, holding the impact vector of the event.

impact_industries_distrib

The series specifying how damages are distributed among affected industries (regions,sectors)

impact_regional_distrib

The series specifying how damages are distributed among affected regions

model_monetary_factor

Amount of unitary currency used in the MRIOT (e.g. 1000000 if in € millions).

mrio_name

MRIOT identification

occurrence

The temporal unit of occurrence of the event.

possible_final_demand_cat

List of final demand categories present in the MRIOT used by the model

possible_regions

List of regions present in the MRIOT used by the model

possible_sectors

List of sectors present in the MRIOT used by the model

regional_sectoral_productive_capital_destroyed

The (optional) array of productive_capital destroyed per industry (ie region x sector)

regions_idx

lexicographic region indexes

sectors_gva_shares

Fraction of total (regional) GVA for each sectors

sectors_idx

lexicographic sector indexes

temporal_unit_range

Maximum temporal unit simulated

x_shape

Shape of the x (production) vector in the model

y_shape

Shape of the Y (final demand) matrix in the model

z_shape

Shape of the Z (intermediate consumption) matrix in the model

event_monetary_factor

The monetary factor for the impact of the event (e.g. 10**6, 10**3, ...).

households_impact_df

A pandas Series with all possible (regions, final_demand_cat) as index, holding the households impacts vector of the event.

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

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_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

regions_idx = array([], dtype=float64)#

lexicographic region indexes

sectors_gva_shares = array([], dtype=float64)#

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

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 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.

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.

property regional_sectoral_productive_capital_destroyed#

The (optional) array of productive_capital destroyed per industry (ie region x sector)