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: ParametricSeismicSource

Area source represents uniform seismicity occurring over a geographical region.

Parameters:

Other parameters (except location) are the same as for PointSource.

MODIFICATIONS = {}#
code = b'A'#
count_ruptures()[source]#

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

iter_ruptures(**kwargs)[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 parameter area_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.

wkt()[source]#
Returns:

the geometry as a WKT string

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 human-readable name of the source.

  • tectonic_region_type – Source’s tectonic regime. See openquake.hazardlib.const.TRT.

abstract property MODIFICATIONS#
checksum = 0#
abstract count_ruptures()[source]#

Return the number of ruptures that will be generated by the source.

esites = 0#
get_mags()[source]#
Returns:

the magnitudes of the ruptures contained in the source

get_magstrs()[source]#
Returns:

the magnitudes of the ruptures contained as strings

abstract get_min_max_mag()[source]#

Return minimum and maximum magnitudes of the ruptures generated by the source.

id = -1#
is_gridded()[source]#
Returns:

True if the source contains only gridded ruptures

iter_meshes()[source]#

Yields the meshes underlying the ruptures

abstract iter_ruptures(**kwargs)[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.

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.

nsites = 1#
offset = 0#
sample_ruptures(eff_num_ses, ses_seed)[source]#
Parameters:

eff_num_ses – number of stochastic event sets * number of samples

Yields:

triples (rupture, trt_smr, num_occurrences)

serial(ses_seed)[source]#
Returns:

a random seed derived from source_id and ses_seed

splittable = True#
to_xml()[source]#

Convert the source into an XML string, very useful for debugging

trt_smr = 0#
property trt_smrs#
Returns:

a list of integers (usually of 1 element)

weight = 0.001#
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: 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 – Magnitude-Frequency 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 trade-off 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).

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 :meth: openquake.hazardlib.mfd.base.BaseMFD.get_annual_occurrence_rates) with simple filtering by rate applied.

Parameters:

min_rate – A non-negative 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 two-item tuples – magnitudes and occurrence rates.

get_min_max_mag()[source]#

Get the minimum and maximum magnitudes of the ruptures generated by the source from the underlying MFD.

modify_adjust_mfd_from_slip(slip_rate: float, rigidity: float, constant_term: float = 9.1, recompute_mmax: float = None)[source]#
Parameters:
  • slip_rate – A float defining slip rate [in mm]

  • rigidity – A float defining material rigidity [in GPa]

  • constant_term – Constant term of the equation used to compute log M0 from magnitude

modify_recompute_mmax(epsilon: float = 0)[source]#

Updates the value of mmax using the msr and the area of the fault

Parameters:

epsilon – Number of standard deviations to be added or substracted

modify_set_mmax_truncatedGR(mmax: float)[source]#

Updates the mmax assigned. This works on for parametric MFDs.s

Parameters:

mmax – The value of the new maximum magnitude

modify_set_msr(new_msr)[source]#

Updates the MSR originally assigned to the source

Parameters:

new_msr – An instance of the openquake.hazardlib.scalerel.BaseMSR

modify_set_slip_rate(slip_rate: float)[source]#

Updates the slip rate assigned to the source

Parameters:

slip_rate – The value of slip rate [mm/yr]

openquake.hazardlib.source.base.get_code2cls()[source]#
Returns:

a dictionary source code -> source class

openquake.hazardlib.source.base.is_poissonian(src)[source]#
Returns:

True if the underlying source is poissonian, false otherwise

openquake.hazardlib.source.base.poisson_sample(src, eff_num_ses, seed)[source]#
Parameters:
  • src – a poissonian source

  • eff_num_ses – number of stochastic event sets * number of samples

  • seed – stochastic seed

Yields:

triples (rupture, rup_id, num_occurrences)

openquake.hazardlib.source.base.timedep_sample(src, eff_num_ses, seed)[source]#
Parameters:
  • src – a time-dependent source

  • eff_num_ses – number of stochastic event sets * number of samples

  • seed – stochastic seed

Yields:

triples (rupture, rup_id, num_occurrences)

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: 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, 5681-5698, 1984)

Parameters:

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

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 = {'adjust_mfd_from_slip', 'set_geometry'}#
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

get_fault_surface_area()[source]#

Computes the area covered by the surface of the fault.

Returns:

A float defining the area of the surface of the fault [km^2]

iter_ruptures(**kwargs)[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:
property polygon#

The underlying polygon, as a convex hull

wkt()[source]#
Returns:

the geometry as a WKT string

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: ParametricSeismicSource

Complex fault source typology represents seismicity occurring on a fault surface with an arbitrarily complex geometry.

Parameters:

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 = {'adjust_mfd_from_slip', 'set_geometry'}#
code = b'C'#
count_ruptures()[source]#

See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

get_fault_surface_area()[source]#

Computes the area covered by the surface of the fault.

Returns:

A float defining the area of the surface of the fault [km^2]

iter_ruptures(**kwargs)[source]#

See :meth: openquake.hazardlib.source.base.BaseSeismicSource.iter_ruptures.

Uses _float_ruptures() for finding possible rupture locations on the whole fault surface.

modify_set_geometry(edges, spacing)[source]#

Modifies the complex fault geometry

property polygon#

The underlying polygon `

wkt()[source]#
Returns:

the geometry as a WKT string

non_parametric#

Module openquake.hazardlib.source.non_parametric defines NonParametricSeismicSource

class openquake.hazardlib.source.non_parametric.NonParametricSeismicSource(source_id, name, tectonic_region_type, data, weights=None)[source]#

Bases: 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 of openquake.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 = {}#
code = b'N'#
count_ruptures()[source]#

See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

fromdict(dic, weights=None)[source]#

Populate a GriddedSource with ruptures

get_bounding_box(maxdist)[source]#

Bounding box containing the surfaces, enlarged by the maximum distance

get_min_max_mag()[source]#

Return the minimum and maximum magnitudes of the ruptures generated by the source

is_gridded()[source]#
Returns:

True if containing only GriddedRuptures, False otherwise

iter_ruptures(**kwargs)[source]#

Get a generator object that yields probabilistic ruptures the source consists of.

Returns:

Generator of instances of openquake.hazardlib.source. rupture.NonParametricProbabilisticRupture.

mesh_size()[source]#
Returns:

the number of points in the underlying meshes

property polygon#

The convex hull of a few subsurfaces

property rup_weights#
todict()[source]#

Convert a GriddedSource into a dictionary of arrays

wkt()[source]#
Returns:

the geometry as a WKT string

point#

Module openquake.hazardlib.source.point defines PointSource.

class openquake.hazardlib.source.point.CollapsedPointSource(source_id, pointsources)[source]#

Bases: PointSource

Source typology representing a cluster of point sources around a specific location. The underlying sources must all have the same tectonic region type, magnitude_scaling_relationship and temporal_occurrence_model.

MODIFICATIONS = {}#
code = b'p'#
count_nphc()[source]#
Returns:

the total number of nodal planes and hypocenters

count_ruptures()[source]#
Returns:

the total number of underlying ruptures

get_annual_occurrence_rates()[source]#
Returns:

a list of pairs [(mag, mag_occur_rate), …]

iruptures()[source]#
Yields:

the underlying ruptures with mean nodal plane and hypocenter

iter_ruptures(**kwargs)[source]#
Returns:

an iterator over the underlying ruptures

property pointsources#
Returns:

the underlying point sources

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

  • locationPoint object representing the location of the seismic source.

  • nodal_plane_distributionPMF object with values that are instances of openquake.hazardlib.geo.nodalplane.NodalPlane. Shows the distribution of probability for rupture to have the certain nodal plane.

  • hypocenter_distributionPMF with values being float numbers in km representing the depth of the hypocenter. Latitude and longitude of the hypocenter is always set to ones of location.

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 = {}#
code = b'P'#
count_nphc()[source]#
Returns:

the number of nodal planes times the number of hypocenters

count_ruptures()[source]#

See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

get_bounding_box(maxdist)[source]#

Bounding box of the point, enlarged by the maximum distance

get_planar(shift_hypo=False, iruptures=False)[source]#
Returns:

a dictionary mag -> list of arrays of shape (U, 3)

get_planin(magd, npd)[source]#
Returns:

array of dtype planin_dt of shape (#mags, #planes, #depths)

get_psdist(m, mag, psdist, magdist)[source]#
Returns:

the effective pointsource distance for the given magnitude

iruptures()[source]#

Generate one rupture for each magnitude, called only if nphc > 1

iter_ruptures(**kwargs)[source]#

Generate one rupture for each combination of magnitude, nodal plane and hypocenter depth.

max_radius(maxdist)[source]#
Returns:

max radius + ps_grid_spacing * sqrt(2)/2

property polygon#

Polygon corresponding to the max_rupture_projection_radius

ps_grid_spacing = 0#
restrict(nodalplane, depth)[source]#
Returns:

source restricted to a single nodal plane and depth

wkt()[source]#
Returns:

the geometry as a WKT string

openquake.hazardlib.source.point.calc_average(pointsources)[source]#
Returns:

a dict with average strike, dip, rake, lon, lat, dep, upper_seismogenic_depth, lower_seismogenic_depth

openquake.hazardlib.source.point.get_rup_maxlen(src)[source]#
Returns:

the maximum rupture length for point sources and area sources

openquake.hazardlib.source.point.get_rupdims(areas, dip, width, rar)[source]#

Calculate and return the rupture length and width for given magnitude surface parameters.

Returns:

array of shape (M, 3) with rupture lengths, widths and heights

The rupture area is calculated using method get_median_area() of source’s magnitude-scaling relationship. In any case the returned dimensions multiplication is equal to that value. Than the area is decomposed to length and width with respect to source’s rupture aspect ratio.

If calculated rupture width being inclined by nodal plane’s dip angle would not fit in between upper and lower seismogenic depth, the rupture width is shrunken to a maximum possible and rupture length is extended to preserve the same area.

openquake.hazardlib.source.point.grid_point_sources(sources, ps_grid_spacing, monitor=<Monitor [runner]>)[source]#
Parameters:
  • sources – a list of sources with the same grp_id (point sources and not)

  • ps_grid_spacing – value of the point source grid spacing in km; if None, do nothing

Returns:

a dict grp_id -> list of non-point sources and collapsed point sources

openquake.hazardlib.source.point.msr_name(src)[source]#
Returns:

string representation of the MSR or “Undefined” if not applicable

openquake.hazardlib.source.point.pdata_to_psources(pdata)[source]#

Generate point sources from a pdata dictionary

openquake.hazardlib.source.point.psources_to_pdata(pointsources, name)[source]#

Build a pdata dictionary from a list of homogeneous point sources with the same tom, trt, msr.

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.

property code#

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

property hypo_depth#

Returns the hypocentral depth

classmethod init()[source]#

Initialize the class dictionary ._code by 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. :returns: {code: pair of classes}

sample_number_of_occurrences(n, rng)[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

size()[source]#

Dummy method for compatibility with the RuptureContext.

Returns:

1

str2code = {'BaseRupture ComplexFaultSurface': 59, 'BaseRupture GriddedSurface': 26, 'BaseRupture KiteSurface': 244, 'BaseRupture MultiSurface': 114, 'BaseRupture PlanarSurface': 197, 'BaseRupture SimpleFaultSurface': 205, 'NonParametricProbabilisticRupture ComplexFaultSurface': 58, 'NonParametricProbabilisticRupture GriddedSurface': 25, 'NonParametricProbabilisticRupture KiteSurface': 243, 'NonParametricProbabilisticRupture MultiSurface': 113, 'NonParametricProbabilisticRupture PlanarSurface': 196, 'NonParametricProbabilisticRupture SimpleFaultSurface': 204, 'ParametricProbabilisticRupture ComplexFaultSurface': 15, 'ParametricProbabilisticRupture GriddedSurface': 238, 'ParametricProbabilisticRupture KiteSurface': 200, 'ParametricProbabilisticRupture MultiSurface': 70, 'ParametricProbabilisticRupture PlanarSurface': 153, 'ParametricProbabilisticRupture SimpleFaultSurface': 161, 'PointRupture ComplexFaultSurface': 202, 'PointRupture GriddedSurface': 169, 'PointRupture KiteSurface': 131, 'PointRupture MultiSurface': 1, 'PointRupture PlanarSurface': 84, 'PointRupture SimpleFaultSurface': 92}#
class openquake.hazardlib.source.rupture.EBRupture(rupture, source_id, trt_smr, n_occ=1, id=None, e0=0)[source]#

Bases: object

An event based rupture. It is a wrapper over a hazardlib rupture object.

Parameters:
  • rupture – the underlying rupture

  • source_id (str) – ID of the source that generated the rupture

  • trt_smr (int) – an integer describing TRT and source model realization

  • n_occ (int) – number of occurrences of the rupture

  • e0 (int) – initial event ID (default 0)

  • scenario (bool) – True for scenario ruptures, default False

get_eids()[source]#
Returns:

an array of event IDs

seed = 'NA'#
property tectonic_region_type#
class openquake.hazardlib.source.rupture.ExportedRupture(rupid, n_occ, 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.seed 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: 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 probability 0.8 to not occurr, 0.15 to occur once, and 0.05 to occur twice, the pmf can be defined as

pmf = 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, rng)[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: 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.

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 near-fault 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:

sitePoint object representing the location of the target site

Returns:

A float number, directivity prediction value (DPP).

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.

sample_number_of_occurrences(n, rng)[source]#

Draw a random sample from the distribution and return a number of events to occur as an array of integers of size n.

Uses :meth: openquake.hazardlib.tom.PoissonTOM.sample_number_of_occurrences of an assigned temporal occurrence model.

class openquake.hazardlib.source.rupture.PointRupture(mag, rake, tectonic_region_type, hypocenter, strike, dip, occurrence_rate, temporal_occurrence_model, zbot)[source]#

Bases: ParametricProbabilisticRupture

A rupture coming from a far away PointSource, so that the finite size effects can be neglected.

class openquake.hazardlib.source.rupture.PointSurface(hypocenter, strike, dip)[source]#

Bases: object

A fake surface used in PointRuptures. The parameters hypocenter and strike are determined by collapsing the corresponding parameters in the original PointSource.

get_closest_points(mesh)[source]#
Returns:

N times the hypocenter if N is the number of points

get_dip()[source]#
get_min_distance(mesh)[source]#
Returns:

the distance from the hypocenter to the mesh

get_strike()[source]#
get_top_edge_depth()[source]#
get_width()[source]#
class openquake.hazardlib.source.rupture.RuptureProxy(rec)[source]#

Bases: object

A proxy for a rupture record.

Parameters:

rec – a record with the rupture parameters

to_ebr(trt)[source]#
Returns:

EBRupture instance associated to the underlying rupture

openquake.hazardlib.source.rupture.build_planar(hypocenter, mag, rake, strike=0.0, dip=90.0, trt='*')[source]#

Build a rupture with a PlanarSurface suitable for scenario calculations

openquake.hazardlib.source.rupture.fix_vertices_order(array43)[source]#

Make sure the point inside array43 are in the form top_left, top_right, bottom_left, bottom_right The convention used in the USGS format has the last two points inverted with respect to what is expected by OQ

openquake.hazardlib.source.rupture.float5(x)[source]#
openquake.hazardlib.source.rupture.get_ebr(rec, geom, trt)[source]#

Convert a rupture record plus geometry into an EBRupture instance

openquake.hazardlib.source.rupture.get_eid_rlz(rec, rlzs, scenario)[source]#
Parameters:
  • rlzs – an array of realization indices

  • scenario – if true distribute the rlzs evenly else randomly

Returns:

two arrays (eid, rlz)

openquake.hazardlib.source.rupture.get_events(recs, rlzs, scenario)[source]#

Build the associations event_id -> rlz_id for each rup_id.

Returns:

a structured array with fields (‘id’, ‘rup_id’, ‘rlz_id’)

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 multi-planar-surface 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

openquake.hazardlib.source.rupture.get_multiplanar(multipolygon_coords, mag, rake, trt)[source]#
Parameters:

multipolygon_coords – an array or list of shape (P, 5, 3) coming from geojson

Returns:

a BaseRupture with a PlanarSurface or a multiPlanarSurface

openquake.hazardlib.source.rupture.get_planar(site, msr, mag, aratio, strike, dip, rake, trt, ztor=None)[source]#
Returns:

a BaseRupture with a PlanarSurface built around the site

openquake.hazardlib.source.rupture.get_ruptures(fname_csv)[source]#

Read ruptures in CSV format and return an ArrayWrapper.

Parameters:

fname_csv – path to the CSV file

openquake.hazardlib.source.rupture.to_arrays(geom)[source]#
Parameters:

geom – an array [num_surfaces, shape_y, shape_z …, coords]

Returns:

a list of num_surfaces arrays with shape (3, shape_y, shape_z)

openquake.hazardlib.source.rupture.to_checksum8(cls1, cls2)[source]#

Convert a pair of classes into a numeric code (uint8)

openquake.hazardlib.source.rupture.to_csv_array(ebruptures)[source]#
Parameters:

ebruptures – a list of EBRuptures

Returns:

an array suitable for serialization in CSV

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: 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', 'adjust_mfd_from_slip', 'recompute_mmax', 'set_bGR', 'set_dip', 'set_geometry', 'set_lower_seismogenic_depth', 'set_mmax_truncatedGR', 'set_msr', 'set_slip_rate'}#
code = b'S'#
count_ruptures()[source]#

See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.

get_fault_surface_area()[source]#

Computes the area covered by the surface of the fault.

Returns:

A float defining the area of the surface of the fault [km^2]

iter_ruptures(**kwargs)[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

modify_set_lower_seismogenic_depth(lsd)[source]#

Modifies the lower seismogenic depth

Parameters:

lsd (float) – New value of the lsd [km]

property polygon#

The underlying polygon `

wkt()[source]#
Returns:

the geometry as a WKT string