Risk Calculators

General

Hazard Getters

Hazard input management for Risk calculators.

exception openquake.engine.calculators.risk.hazard_getters.AssetSiteAssociationError[source]

Bases: exceptions.Exception

class openquake.engine.calculators.risk.hazard_getters.GroundMotionGetter(imt, taxonomy, hazard_outputs, assets)[source]

Bases: openquake.engine.calculators.risk.hazard_getters.HazardGetter

get_epsilons()[source]

Expand the underlying epsilons

class openquake.engine.calculators.risk.hazard_getters.Hazard(hazard_output, data, imt)[source]

Bases: object

Hazard objects have attributes .hazard_output, .data and .imt. Moreover you can extract the .hid (hazard_output.id) and the .weight associated to the underlying realization. The hazard .data is a numpy array of shape (N, R) where N is the number of assets and R the number of seismic events (ruptures) or the resolution of the hazard curve, depending on the calculator.

hid

Return the id of the given hazard output

weight

Return the realization weight of the hazard output

class openquake.engine.calculators.risk.hazard_getters.HazardCurveGetter(imt, taxonomy, hazard_outputs, assets)[source]

Bases: openquake.engine.calculators.risk.hazard_getters.HazardGetter

class openquake.engine.calculators.risk.hazard_getters.HazardGetter(imt, taxonomy, hazard_outputs, assets)[source]

Bases: object

A HazardGetter instance stores a chunk of assets and their associated hazard data. In the case of scenario and event based calculators it also stores the ruptures and the epsilons. The HazardGetter must be pickable such that it should be possible to use different strategies (e.g. distributed or not, using postgis or not).

attr assets:The assets for which we want to extract the hazard
Attr site_ids:The ids of the sites associated to the hazards
get_data()[source]

Shortcut returning the hazard data when there is a single realization

get_hazards()[source]

Return a list of Hazard instances for the given IMT.

hid

Return the id of the hazard output, when there is a single realization

class openquake.engine.calculators.risk.hazard_getters.RiskInitializer(taxonomy, rc)[source]

Bases: object

A facility providing the brigde between the hazard (sites and outputs) and the risk (assets and risk models). When .init_assocs is called, populates the asset_site table with the associations between the assets in the current exposure model and the sites in the previous hazard calculation.

Parameters:

Warning: instantiating a RiskInitializer may perform a potentially expensive geospatial query.

calc_nbytes(epsilon_sampling=None)[source]
Parameters:epsilon_sampling – flag saying if the epsilon_sampling feature is enabled
Returns:the number of bytes to be allocated (a guess)

If the hazard_outputs come from an event based or scenario computation, populate the .epsilons_shape dictionary.

init_assocs()[source]

Stores the associations asset <-> site into the database

init_epsilons(epsilon_sampling=None)[source]
Parameters:epsilon_sampling – flag saying if the epsilon_sampling feature is enabled

Populate the .epsilons_shape and the ._rupture_ids dictionaries. For the calculators event_based_risk and scenario_risk also stores the epsilons in the database for each asset_site association.

openquake.engine.calculators.risk.hazard_getters.expand(array, N)[source]

Given a non-empty array with n elements, expands it to a larger array with N elements.

>>> expand([1], 3)
array([1, 1, 1])
>>> expand([1, 2, 3], 10)
array([1, 2, 3, 1, 2, 3, 1, 2, 3, 1])
>>> expand(numpy.zeros((2, 10)), 5).shape
(5, 10)
openquake.engine.calculators.risk.hazard_getters.haz_out_to_ses_coll(ho)[source]
openquake.engine.calculators.risk.hazard_getters.make_epsilons(asset_count, num_samples, seed, correlation)[source]
Parameters:
  • asset_count (int) – the number of assets
  • num_ruptures (int) – the number of ruptures
  • seed (int) – a random seed
  • correlation (float) – the correlation coefficient

Classical PSHA Calculator

Classical PSHA BCR Calculator

Event-Based PSHA Calculator

Event-Based PSHA BCR Calculator

Scenario Calculator

Scenario Damage Calculator