openquake.hazardlib.source package¶
Seismic sources and ruptures¶
area¶
Module openquake.hazardlib.source.area
defines AreaSource
.

class
openquake.hazardlib.source.area.
AreaSource
(source_id, name, tectonic_region_type, mfd, rupture_mesh_spacing, magnitude_scaling_relationship, rupture_aspect_ratio, temporal_occurrence_model, upper_seismogenic_depth, lower_seismogenic_depth, nodal_plane_distribution, hypocenter_distribution, polygon, area_discretization)[source]¶ Bases:
openquake.hazardlib.source.base.ParametricSeismicSource
Area source represents uniform seismicity occurring over a geographical region.
 Parameters
polygon – An instance of
openquake.hazardlib.geo.polygon.Polygon
that defines source’s area.area_discretization – Float number, polygon area discretization spacing in kilometers. See
openquake.hazardlib.source.area.AreaSource.iter_ruptures()
.
Other parameters (except
location
) are the same as forPointSource
.
MODIFICATIONS
= {}¶

RUPTURE_WEIGHT
= 0.1¶

assert_equal
(other, ignore=())¶

code
= 'A'¶

count_ruptures
()[source]¶ See
openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures()
for description of parameters and return value.

iter_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.iter_ruptures for description of parameters and return value.
Area sources are treated as a collection of point sources (see
openquake.hazardlib.source.point
) with uniform parameters. Ruptures of area source are just a union of ruptures of those point sources. The actual positions of the implied point sources form a uniformly spaced mesh on the polygon. Polygon’s method :meth: ~openquake.hazardlib.geo.polygon.Polygon.discretize is used for creating a mesh of points on the source’s area. Constructor’s parameterarea_discretization
is used as polygon’s discretization spacing (not to be confused with rupture surface’s mesh spacing which is as well provided to the constructor).The ruptures’ occurrence rates are rescaled with respect to number of points the polygon discretizes to.
base¶
Module openquake.hazardlib.source.base
defines a base class for
seismic sources.

class
openquake.hazardlib.source.base.
BaseSeismicSource
(source_id, name, tectonic_region_type)[source]¶ Bases:
object
Base class representing a seismic source, that is a structure generating earthquake ruptures.
 Parameters
source_id – Some (numeric or literal) source identifier. Supposed to be unique within the source model.
name – String, a humanreadable name of the source.
tectonic_region_type – Source’s tectonic regime. See
openquake.hazardlib.const.TRT
.

MODIFICATIONS
¶

RUPTURE_WEIGHT
= 1.0¶

assert_equal
(other, ignore=())¶

get_min_max_mag
()[source]¶ Return minimum and maximum magnitudes of the ruptures generated by the source.

iter_ruptures
()[source]¶ Get a generator object that yields probabilistic ruptures the source consists of.
 Returns
Generator of instances of sublclass of :class: ~openquake.hazardlib.source.rupture.BaseProbabilisticRupture.

min_mag
= 0¶

modify
(modification, parameters)[source]¶ Apply a single modificaton to the source parameters Reflects the modification method and calls it passing
parameters
as keyword arguments.Modifications can be applied one on top of another. The logic of stacking modifications is up to a specific source implementation.
 Parameters
modification – String name representing the type of modification.
parameters – Dictionary of parameters needed for modification.
 Raises
ValueError – If
modification
is missing from the attribute MODIFICATIONS.

ngsims
= 1¶

nsites
¶  Returns
the number of sites affected by this source

sample_ruptures
(eff_num_ses)[source]¶  Parameters
eff_num_ses – number of stochastic event sets * number of samples
 Yields
pairs (rupture, num_occurrences[num_samples])

sample_ruptures_poissonian
(serials, eff_num_ses)[source]¶  Parameters
eff_num_ses – number of stochastic event sets * number of samples
 Yields
pairs (rupture, num_occurrences[num_samples])

splittable
= True¶

src_group_ids
¶  Returns
a list of source group IDs (usually of 1 element)

weight
¶ Determine the source weight from the number of ruptures, by multiplying with the scale factor RUPTURE_WEIGHT

class
openquake.hazardlib.source.base.
ParametricSeismicSource
(source_id, name, tectonic_region_type, mfd, rupture_mesh_spacing, magnitude_scaling_relationship, rupture_aspect_ratio, temporal_occurrence_model)[source]¶ Bases:
openquake.hazardlib.source.base.BaseSeismicSource
Parametric Seismic Source generates earthquake ruptures from source parameters, and associated probabilities of occurrence are defined through a magnitude frequency distribution and a temporal occurrence model.
 Parameters
mfd – MagnitudeFrequency distribution for the source. See
openquake.hazardlib.mfd
.rupture_mesh_spacing – The desired distance between two adjacent points in source’s ruptures’ mesh, in km. Mainly this parameter allows to balance the tradeoff between time needed to compute the
distance
between the rupture surface and a site and the precision of that computation.magnitude_scaling_relationship – Instance of subclass of
openquake.hazardlib.scalerel.base.BaseMSR
to describe how does the area of the rupture depend on magnitude and rake.rupture_aspect_ratio – Float number representing how much source’s ruptures are more wide than tall. Aspect ratio of 1 means ruptures have square shape, value below 1 means ruptures stretch vertically more than horizontally and vice versa.
temporal_occurrence_model – Instance of
openquake.hazardlib.tom.PoissonTOM
defining temporal occurrence model for calculating rupture occurrence probabilities
 Raises
ValueError – If either rupture aspect ratio or rupture mesh spacing is not positive (if not None).

assert_equal
(other, ignore=())¶

get_annual_occurrence_rates
(min_rate=0)[source]¶ Get a list of pairs “magnitude – annual occurrence rate”.
The list is taken from assigned MFD object (see
openquake.hazardlib.mfd.base.BaseMFD.get_annual_occurrence_rates()
) with simple filtering by rate applied. Parameters
min_rate – A nonnegative value to filter magnitudes by minimum annual occurrence rate. Only magnitudes with rates greater than that are included in the result list.
 Returns
A list of twoitem tuples – magnitudes and occurrence rates.
characteristic¶
Module openquake.hazardlib.source.characteristic
defines
CharacteristicFaultSource
.

class
openquake.hazardlib.source.characteristic.
CharacteristicFaultSource
(source_id, name, tectonic_region_type, mfd, temporal_occurrence_model, surface, rake, surface_node=None)[source]¶ Bases:
openquake.hazardlib.source.base.ParametricSeismicSource
Characteristic source typology represents seismicity occuring on a generic fault surface with seismic events rupturing the entire fault surface independently of their magnitude values.
Characteristic source typology can be used to model individual faults or fault segments that tend to produce essentialy same size earthquakes (see for instance: Schwartz, D. P., K. J. Coppersmith, Fault behavior and characteristic earthquakes: Examples from the Wasatch and San Andreas fault zones, J. Geophys. Res., 89, 56815698, 1984)
 Parameters
surface – Fault surface, see
openquake.hazardlib.geo.surface
.rake – Angle describing rupture propagation direction in decimal degrees.
See also
openquake.hazardlib.source.base.ParametricSeismicSource
for description of other parameters.Note that a
CharacteristicFaultSource
does not need any mesh spacing, magnitude scaling relationship, and aspect ratio, therefore the constructor sets these parameters toNone
.NB: if you want to convert a characteristic source into XML, you must set its attribute surface_node to an explicit representation of the surface as a LiteralNode object.

MODIFICATIONS
= {'set_geometry'}¶

assert_equal
(other, ignore=())¶

code
= b'X'¶

count_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

get_bounding_box
(maxdist)[source]¶ Bounding box containing all points, enlarged by the maximum distance

iter_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.iter_ruptures.
For each magnitude value in the given MFD, return an earthquake rupture with a surface always equal to the given surface.

modify_set_geometry
(surface, surface_node=None)[source]¶ Modifies the current fault geometry
 Parameters
surface – Fault surface, see
openquake.hazardlib.geo.surface
.surface_node – If needed for export, provide the surface as a LiteralNode object

polygon
¶ The underlying polygon, as a convex hull
complex_fault¶
Module openquake.hazardlib.source.complex_fault
defines ComplexFaultSource
.

class
openquake.hazardlib.source.complex_fault.
ComplexFaultSource
(source_id, name, tectonic_region_type, mfd, rupture_mesh_spacing, magnitude_scaling_relationship, rupture_aspect_ratio, temporal_occurrence_model, edges, rake)[source]¶ Bases:
openquake.hazardlib.source.base.ParametricSeismicSource
Complex fault source typology represents seismicity occurring on a fault surface with an arbitrarily complex geometry.
 Parameters
edges – A list of
Line
objects, representing fault source geometry. Seeopenquake.hazardlib.geo.surface.complex_fault.ComplexFaultSurface.from_fault_data()
.rake – Angle describing rupture propagation direction in decimal degrees.
See also
openquake.hazardlib.source.base.ParametricSeismicSource
for description of other parameters. Raises
ValueError – If
check_fault_data()
fails or if rake value is invalid.

MODIFICATIONS
= {'set_geometry'}¶

RUPTURE_WEIGHT
= 4.0¶

assert_equal
(other, ignore=())¶

code
= b'C'¶

count_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

iter_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.iter_ruptures.
Uses
_float_ruptures()
for finding possible rupture locations on the whole fault surface.

polygon
¶ The underlying polygon `
non_parametric¶
Module openquake.hazardlib.source.non_parametric
defines
NonParametricSeismicSource

class
openquake.hazardlib.source.non_parametric.
NonParametricSeismicSource
(source_id, name, tectonic_region_type, data)[source]¶ Bases:
openquake.hazardlib.source.base.BaseSeismicSource
Non Parametric Seismic Source explicitly defines earthquake ruptures in the constructor. That is earthquake ruptures are not generated algorithmically from a set of source parameters.
Ruptures’ rectonic region types are overwritten by source tectonic region type.
 Parameters
data – List of tuples. Each tuple must contain two items. The first item must be an instance of
openquake.hazardlib.source.rupture.Rupture
. The second item must be an instance ofopenquake.hazardlib.pmf.PMF
describing the probability of the rupture to occur N times (the PMF must be defined from a minimum number of occurrences equal to 0)

MODIFICATIONS
= {}¶

assert_equal
(other, ignore=())¶

code
= b'N'¶

count_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

get_bounding_box
(maxdist)[source]¶ Bounding box containing all surfaces, enlarged by the maximum distance
point¶
Module openquake.hazardlib.source.point
defines PointSource
.

class
openquake.hazardlib.source.point.
PointSource
(source_id, name, tectonic_region_type, mfd, rupture_mesh_spacing, magnitude_scaling_relationship, rupture_aspect_ratio, temporal_occurrence_model, upper_seismogenic_depth, lower_seismogenic_depth, location, nodal_plane_distribution, hypocenter_distribution)[source]¶ Bases:
openquake.hazardlib.source.base.ParametricSeismicSource
Point source typology represents seismicity on a single geographical location.
 Parameters
upper_seismogenic_depth – Minimum depth an earthquake rupture can reach, in km.
lower_seismogenic_depth – Maximum depth an earthquake rupture can reach, in km.
location –
Point
object representing the location of the seismic source.nodal_plane_distribution –
PMF
object with values that are instances ofopenquake.hazardlib.geo.nodalplane.NodalPlane
. Shows the distribution of probability for rupture to have the certain nodal plane.hypocenter_distribution –
PMF
with values being float numbers in km representing the depth of the hypocenter. Latitude and longitude of the hypocenter is always set to ones oflocation
.
See also
openquake.hazardlib.source.base.ParametricSeismicSource
for description of other parameters. Raises
ValueError – If upper seismogenic depth is below lower seismogenic depth, if one or more of hypocenter depth values is shallower than upper seismogenic depth or deeper than lower seismogenic depth.

MODIFICATIONS
= {}¶

RUPTURE_WEIGHT
= 0.1¶

assert_equal
(other, ignore=())¶

code
= b'P'¶

count_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

iter_ruptures
(hcdist=True, npdist=True)[source]¶ Generate one rupture for each combination of magnitude, nodal plane and hypocenter depth.

polygon
¶ Polygon corresponding to the max_rupture_projection_radius
rupture¶
Module openquake.hazardlib.source.rupture
defines classes
BaseRupture
and its subclasses
NonParametricProbabilisticRupture
and
ParametricProbabilisticRupture

class
openquake.hazardlib.source.rupture.
BaseRupture
(mag, rake, tectonic_region_type, hypocenter, surface, rupture_slip_direction=None, weight=None)[source]¶ Bases:
object
Rupture object represents a single earthquake rupture.
 Parameters
mag – Magnitude of the rupture.
rake – Rake value of the rupture. See
NodalPlane
.tectonic_region_type – Rupture’s tectonic regime. One of constants in
openquake.hazardlib.const.TRT
.hypocenter – A
Point
, rupture’s hypocenter.surface – An instance of subclass of
BaseSurface
. Object representing the rupture surface geometry.rupture_slip_direction – Angle describing rupture propagation direction in decimal degrees.
 Raises
ValueError – If magnitude value is not positive, or tectonic region type is unknown.
NB: if you want to convert the rupture into XML, you should set the attribute surface_nodes to an appropriate value.

assert_equal
(other, ignore=())¶

code
¶ Returns the code (integer in the range 0 .. 255) of the rupture

get_probability_no_exceedance
(poes)¶ Compute and return the probability that in the time span for which the rupture is defined, the rupture itself never generates a ground motion value higher than a given level at a given site.
Such calculation is performed starting from the conditional probability that an occurrence of the current rupture is producing a ground motion value higher than the level of interest at the site of interest. The actual formula used for such calculation depends on the temporal occurrence model the rupture is associated with. The calculation can be performed for multiple intensity measure levels and multiple sites in a vectorized fashion.
 Parameters
poes – 2D numpy array containing conditional probabilities the the a rupture occurrence causes a ground shaking value exceeding a ground motion level at a site. First dimension represent sites, second dimension intensity measure levels.
poes
can be obtained calling the :meth:`method <openquake.hazardlib.gsim.base.GroundShakingIntensityModel.get_poes>

classmethod
init
()[source]¶ Initialize the class dictionaries ._code and .`types` encoding the bidirectional correspondence between an integer in the range 0..255 (the code) and a pair of classes (rupture_class, surface_class). This is useful when serializing the rupture to and from HDF5.

sample_number_of_occurrences
(n=1)[source]¶ Randomly sample number of occurrences from temporal occurrence model probability distribution.
Note
This method is using random numbers. In order to reproduce the same results numpy random numbers generator needs to be seeded, see http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.seed.html
 Returns
numpy array of size n with number of rupture occurrences

serial
= 0¶

types
= {}¶

class
openquake.hazardlib.source.rupture.
EBRupture
(rupture, srcidx, grp_id, n_occ, samples=1)[source]¶ Bases:
object
An event based rupture. It is a wrapper over a hazardlib rupture object, containing an array of site indices affected by the rupture, as well as the IDs of the corresponding seismic events.

export
(mesh, rlzs_by_gsim, num_ses)[source]¶ Yield
Rupture
objects, with all the attributes set, suitable for export in XML format.

get_eids
(num_rlzs)[source]¶  Parameters
num_rlzs – the number of realizations for the given group
 Returns
an array of event IDs

get_eids_by_rlz
(rlzs_by_gsim)[source]¶  Parameters
n_occ – number of occurrences
samples – number of samples in current source group
 Params rlzs_by_gsim
a dictionary gsims > rlzs array
 Returns
a dictionary rlz index > eids array

serial
¶ Serial number of the rupture


class
openquake.hazardlib.source.rupture.
ExportedRupture
(rupid, events_by_ses, indices=None)[source]¶ Bases:
object
Simplified Rupture class with attributes rupid, events_by_ses, indices and others, used in export.
 Parameters
rupid – rupture serial ID
events_by_ses – dictionary ses_idx > event records
indices – site indices

class
openquake.hazardlib.source.rupture.
NonParametricProbabilisticRupture
(mag, rake, tectonic_region_type, hypocenter, surface, pmf, rupture_slip_direction=None, weight=None)[source]¶ Bases:
openquake.hazardlib.source.rupture.BaseRupture
Probabilistic rupture for which the probability distribution for rupture occurrence is described through a generic probability mass function.
 Parameters
pmf –
Instance of
openquake.hazardlib.pmf.PMF
. Values in the abscissae represent number of rupture occurrences (in increasing order, staring from 0) and values in the ordinates represent associated probabilities. Example: if, for a given time span, a rupture has probability0.8
to not occurr,0.15
to occur once, and0.05
to occur twice, thepmf
can be defined aspmf = PMF([(0.8, 0), (0.15, 1), 0.05, 2)])
 Raises
ValueError – If number of ruptures in
pmf
do not start from 0, are not defined in increasing order, and if they are not defined with unit step

sample_number_of_occurrences
(n=1)[source]¶ See
superclass method
for spec of input and result values.Uses ‘Inverse Transform Sampling’ method.

class
openquake.hazardlib.source.rupture.
ParametricProbabilisticRupture
(mag, rake, tectonic_region_type, hypocenter, surface, occurrence_rate, temporal_occurrence_model, rupture_slip_direction=None)[source]¶ Bases:
openquake.hazardlib.source.rupture.BaseRupture
Rupture
associated with an occurrence rate and a temporal occurrence model. Parameters
occurrence_rate – Number of times rupture happens per year.
temporal_occurrence_model – Temporal occurrence model assigned for this rupture. Should be an instance of
openquake.hazardlib.tom.PoissonTOM
.
 Raises
ValueError – If occurrence rate is not positive.

assert_equal
(other, ignore=())¶

get_cdppvalue
(target, buf=1.0, delta=0.01, space=2.0)[source]¶ Get the directivity prediction value, centered DPP(cdpp) at a given site as described in Spudich et al. (2013), and this cdpp is used in Chiou and Young (2014) GMPE for nearfault directivity term prediction.
 Parameters
target_site – A mesh object representing the location of the target sites.
buf – A buffer distance in km to extend the mesh borders
delta – The distance between two adjacent points in the mesh
space – The tolerance for the distance of the sites (default 2 km)
 Returns
The centered directivity prediction value of Chiou and Young

get_dppvalue
(site)[source]¶ Get the directivity prediction value, DPP at a given site as described in Spudich et al. (2013).
 Parameters
site –
Point
object representing the location of the target site Returns
A float number, directivity prediction value (DPP).

get_probability_no_exceedance
(poes)[source]¶ See
superclass method
for spec of input and result values.Uses
openquake.hazardlib.tom.PoissonTOM.get_probability_no_exceedance()

get_probability_one_occurrence
()[source]¶ Return the probability of this rupture to occur exactly one time.
Uses :meth: openquake.hazardlib.tom.PoissonTOM.get_probability_n_occurrences of an assigned temporal occurrence model.

get_probability_one_or_more_occurrences
()[source]¶ Return the probability of this rupture to occur one or more times.
Uses
get_probability_one_or_more_occurrences()
of an assigned temporal occurrence model.

openquake.hazardlib.source.rupture.
get_eids
(rup_array, samples_by_grp, num_rlzs_by_grp)[source]¶  Parameters
rup_array – a composite array with fields serial, n_occ and grp_id
samples_by_grp – a dictionary grp_id > samples
num_rlzs_by_grp – a dictionary grp_id > num_rlzs

openquake.hazardlib.source.rupture.
get_geom
(surface, is_from_fault_source, is_multi_surface, is_gridded_surface)[source]¶ The following fields can be interpreted different ways, depending on the value of is_from_fault_source. If is_from_fault_source is True, each of these fields should contain a 2D numpy array (all of the same shape). Each triple of (lon, lat, depth) for a given index represents the node of a rectangular mesh. If is_from_fault_source is False, each of these fields should contain a sequence (tuple, list, or numpy array, for example) of 4 values. In order, the triples of (lon, lat, depth) represent top left, top right, bottom left, and bottom right corners of the the rupture’s planar surface. Update: There is now a third case. If the rupture originated from a characteristic fault source with a multiplanarsurface geometry, lons, lats, and depths will contain one or more sets of 4 points, similar to how planar surface geometry is stored (see above).
 Parameters
surface – a Surface instance
is_from_fault_source – a boolean
is_multi_surface – a boolean
simple_fault¶
Module openquake.hazardlib.source.simple_fault
defines
SimpleFaultSource
.

class
openquake.hazardlib.source.simple_fault.
SimpleFaultSource
(source_id, name, tectonic_region_type, mfd, rupture_mesh_spacing, magnitude_scaling_relationship, rupture_aspect_ratio, temporal_occurrence_model, upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip, rake, hypo_list=(), slip_list=())[source]¶ Bases:
openquake.hazardlib.source.base.ParametricSeismicSource
Simple fault source typology represents seismicity occurring on a fault surface with simple geometry.
 Parameters
upper_seismogenic_depth – Minimum depth an earthquake rupture can reach, in km.
lower_seismogenic_depth – Maximum depth an earthquake rupture can reach, in km.
fault_trace – A
Line
representing the line of intersection between the fault plane and the Earth’s surface.dip – Angle between earth surface and fault plane in decimal degrees.
rake – the direction of hanging wall relative to the foot wall.
rupture_slip_direction – Angle describing rupture propagation direction in decimal degrees.
hypo_list – Array describing the relative position of the hypocentre on the rupture surface. Each line represents a hypocentral position defined in terms of the relative distance along strike and dip (from the upper, left corner of the fault surface i.e. the corner which results from the projection at depth of the first vertex of the fault trace) and the corresponding weight. Example 1: one single hypocentral position at the center of the rupture will be described by the following array[(0.5, 0.5, 1.0)]. Example 2: two possible hypocenters are admitted for a rupture. One hypocentre is located along the strike at 1/4 of the fault length and at 1/4 of the fault width along the dip and occurs with a weight of 0.3, the other one is at 3/4 of fault length along strike and at 3/4 of fault width along strike with a weight of 0.7. The numpy array would be entered as numpy.array([[0.25, 0.25, 0.3], [0.75, 0.75, 0.7]]).
slip_list – Array describing the rupture slip direction, which desribes the rupture propagation direction on the rupture surface. Each line represents a rupture slip direction and the corresponding weight. Example 1: one single rupture slip direction with angle 90 degree will be described by the following array[(90, 1.0)]. Example 2: two possible rupture slip directions are admitted for a rupture. One slip direction is at 90 degree with a weight of 0.7, the other one is at 135 degree with a weight of 0.3. The numpy array would be entered as numpy.array( [[90, 0.7], [135, 0.3]]).
See also
openquake.hazardlib.source.base.ParametricSeismicSource
for description of other parameters. Raises
ValueError – If
check_fault_data()
fails, if rake value is invalid and if rupture mesh spacing is too high for the lowest magnitude value.

MODIFICATIONS
= {'adjust_dip', 'set_dip', 'set_geometry'}¶

assert_equal
(other, ignore=())¶

code
= b'S'¶

count_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

iter_ruptures
()[source]¶ See :meth: openquake.hazardlib.source.base.BaseSeismicSource.iter_ruptures.
Generates a ruptures using the “floating” algorithm: for all the magnitude values of assigned MFD calculates the rupture size with respect to MSR and aspect ratio and then places ruptures of that size on the surface of the whole fault source. The occurrence rate of each of those ruptures is the magnitude occurrence rate divided by the number of ruptures that can be placed in a fault.

modify_adjust_dip
(increment)[source]¶ Modifies the dip by an incremental value
 Parameters
increment (float) – Value by which to increase or decrease the dip (the resulting dip must still be within 0.0 to 90.0 degrees)

modify_set_dip
(dip)[source]¶ Modifies the dip to the specified value
 Parameters
dip (float) – New value of dip (must still be within 0.0 to 90.0 degrees)

modify_set_geometry
(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, spacing)[source]¶ Modifies the current source geometry including trace, seismogenic depths and dip

polygon
¶ The underlying polygon `