Package openquake.hazardlib.source deals with various types of seismic sources.
Module openquake.hazardlib.source.rupture defines classes Rupture, BaseProbabilisticRupture and its subclasses NonParametricProbabilisticRupture and ParametricProbabilisticRupture
Base class for a probabilistic rupture, that is a Rupture associated with a temporal occurrence model defining probability of rupture occurrence in a certain time span.
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 method. 

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:  int, Number of rupture occurrences 

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([(Decimal('0.8'), 0), (Decimal('0.15'), 1),
Decimal('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 
See superclass method for spec of input and result values.
Uses the formula
∑ p(kT) * p(X<xrup)^k
where p(kT) is the probability that the rupture occurs k times in the time span T, p(X<xrup) is the probability that a rupture occurrence does not cause a ground motion exceedance, and the summation ∑ is done over the number of occurrences k.
p(kT) is given by the constructor’s parameter pmf, and p(X<xrup) is computed as 1  poes.
See superclass method for spec of input and result values.
Uses ‘Inverse Transform Sampling’ method.
Rupture associated with an occurrence rate and a temporal occurrence model.
Parameters: 


Raises ValueError:  
If occurrence rate is not positive. 
Get the directivity prediction value, centred 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: 


Returns:  A float value presents the centreed directivity predication value which used in Chioud and Young(2014) GMPE for directivity term 
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). 
See superclass method for spec of input and result values.
Return the probability of this rupture to occur exactly one time.
Uses :meth: ~openquake.hazardlib.tom.PoissonTOM.get_probability_one_occurrence of an assigned temporal occurrence model.
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.
Rupture object represents a single earthquake rupture.
Parameters: 


Raises ValueError:  
If magnitude value is not positive, hypocenter is above the earth surface 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.
Module openquake.hazardlib.source.point defines PointSource.
Point source typology represents seismicity on a single geographical location.
Parameters: 


See also openquake.hazardlib.source.base.ParametricSeismicSource for description of other parameters.
Raises ValueError:  

If upper seismogenic depth is negative or below lower seismogenic depth, if one or more of hypocenter depth values is shallower than upper seismogenic depth or deeper than lower seismogenic depth. 
Find a maximum radius of a circle on Earth surface enveloping a rupture produced by this source.
Returns:  Half of maximum rupture’s diagonal surface projection. 

Calculate and return the rupture length and width for given magnitude mag and nodal plane.
Parameters:  nodal_plane – Instance of openquake.hazardlib.geo.nodalplane.NodalPlane. 

Returns:  Tuple of two items: rupture length in width in km. 
The rupture area is calculated using method get_median_area() of source’s magnitudescaling 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.
Create and return rupture surface object with given properties.
Parameters: 


Returns:  Instance of PlanarSurface. 
The common part of :meth: openquake.hazardlib.source.point.Point.iter_ruptures shared between point source and AreaSource.
Parameters: 


See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.
Filter sites that are closer than maximum rupture projection radius plus integration distance along the great circle arc from source’s epicenter location. Overrides base class' method in order to avoid using polygon.
Returns a circleshaped polygon with radius equal to dilation plus _get_max_rupture_projection_radius().
See superclass method for parameter and return value definition.
Module openquake.hazardlib.source.area defines AreaSource.
Area source represents uniform seismicity occurring over a geographical region.
Parameters: 


Other parameters (except location) are the same as for PointSource.
See openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures() for description of parameters and return value.
Overrides implementation of the point source class just to call the base class one.
Extends the area source polygon by dilation plus _get_max_rupture_projection_radius().
See superclass method for parameter and return value definition.
See 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.
Module openquake.hazardlib.source.simple_fault defines SimpleFaultSource.
Simple fault source typology represents seismicity occurring on a fault surface with simple geometry.
Parameters: 


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. 
See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.
Uses openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface.surface_projection_from_fault_data() for getting the fault’s surface projection and then calls its dilate() method passing in dilation parameter.
See superclass method for parameter and return value definition.
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.
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) 

Module openquake.hazardlib.source.complex_fault defines ComplexFaultSource.
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. 
See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.
Uses openquake.hazardlib.geo.surface.complex_fault.ComplexFaultSurface.surface_projection_from_fault_data() for getting the fault’s surface projection and then calls its dilate() method passing in dilation parameter.
See superclass method for parameter and return value definition.
See :meth: openquake.hazardlib.source.base.BaseSeismicSource.iter_ruptures.
Uses _float_ruptures() for finding possible rupture locations on the whole fault surface.
Get all possible unique rupture placements on the fault surface.
Parameters: 


Returns:  A list of slice objects. Number of items in the list is equal to number of possible locations of the requested rupture on the fault surface. Each slice can be used to get a portion of the whole fault surface mesh that would represent the location of the rupture. 
Module openquake.hazardlib.source.characteristic defines CharacteristicFaultSource.
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: 


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.
See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.
Uses :meth: openquake.hazardlib.geo.surface.base.BaseSurface.get_bounding_box() and from bounding box coordinates create openquake.hazardlib.geo.mesh.RectangularMesh and then calls openquake.hazardlib.geo.mesh.Mesh.get_convex_hull() to get a polygon representation of the bounding box. Note that this is needed to cope with the situation of a vertical rupture for which the bounding box collapses to a line. In this case the method get_convex_hull() returns a valid polygon obtained by expanding the line by a small distance. Finally, a polygon is returned by calling dilate() passing in the dilation parameter.
See superclass method for parameter and return value definition.
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.
Modifies the current fault geometry
Parameters: 


Module openquake.hazardlib.source.non_parametric defines NonParametricSeismicSource
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) 

See :meth: openquake.hazardlib.source.base.BaseSeismicSource.count_ruptures.
Return the minimum and maximum magnitudes of the ruptures generated by the source
Create instance of openquake.hazardlib.geo.surface.multi.MultiSurface from all ruptures’ surfaces and compute its bounding box. Calculate convex hull of bounding box, and return it dilated by dilation.
Parameters:  dilation – A buffer distance in km to extend the polygon borders to. 

Returns:  Instance of openquake.hazardlib.geo.polygon.Polygon. 
Module openquake.hazardlib.source.base defines a base class for seismic sources.
Base class representing a seismic source, that is a structure generating earthquake ruptures.
Parameters: 


Filter out sites from the collection that are further from the source than some arbitrary threshold.
Parameters: 


Returns:  Filtered SiteCollection. 
Method can be overridden by subclasses in order to achieve higher performance for a specific typology. Base class method calls get_rupture_enclosing_polygon() with integration_distance as a dilation value and then filters site collection by checking :meth: containment <openquake.hazardlib.geo.polygon.Polygon.intersects> of site locations.
The main criteria for this method to decide whether a site should be filtered out or not is the minimum distance between the site and all the ruptures produced by the source. If at least one rupture is closer (in terms of great circle distance between surface projections) than integration distance to a site, it should not be filtered out. However, it is important not to make this method too computationally intensive. If shortcircuits are taken, false positives are generally better than false negatives (it’s better not to filter a site out if there is some uncertainty about its distance).
Return minimum and maximum magnitudes of the ruptures generated by the source.
Get a polygon which encloses all the ruptures generated by the source.
The rupture enclosing polygon is meant to be used in all hazard calculators to filter out sources whose ruptures the user wants to be neglected because they are too far from the locations of interest.
For performance reasons, the get_rupture_enclosing_polygon() should compute the polygon, without creating all the ruptures. The rupture enclosing polygon may not be necessarily the minimum enclosing polygon, but must guarantee that all ruptures are within the polygon.
This method must be implemented by subclasses.
Parameters:  dilation – A buffer distance in km to extend the polygon borders to. 

Returns:  Instance of openquake.hazardlib.geo.polygon.Polygon. 
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. 

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: 


Raises ValueError:  
If modification is missing from the attribute MODIFICATIONS. 
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: 


Raises ValueError:  
If either rupture aspect ratio or rupture mesh spacing is not positive (if not None). 
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. 