Rupture surfaces

Package openquake.hazardlib.geo.surface contains base and specific implementations of earthquake rupture surfaces.

Base surface

Module openquake.hazardlib.geo.surface.base implements BaseSurface and BaseQuadrilateralSurface.

class openquake.hazardlib.geo.surface.base.BaseQuadrilateralSurface[source]

Base class for a quadrilateral surface in 3D-space.

Subclasses must implement _create_mesh(), and superclass methods get_strike(), get_dip() and get_width(), and can override any others just for the sake of performance

_create_mesh()[source]

Create and return the mesh of points covering the surface.

Returns:An instance of openquake.hazardlib.geo.mesh.RectangularMesh.
_get_top_edge_centroid()[source]

Return Point representing the surface’s top edge centroid.

get_area()[source]

Compute area as the sum of the mesh cells area values.

get_bounding_box()[source]

Compute surface bounding box from surface mesh representation. That is extract longitudes and latitudes of mesh points and calls: openquake.hazardlib.geo.utils.get_spherical_bounding_box()

Returns:A tuple of four items. These items represent western, eastern, northern and southern borders of the bounding box respectively. Values are floats in decimal degrees.
get_closest_points(mesh)[source]

See superclass method for spec of input and result values.

Base class implementation calls the corresponding method of the surface’s mesh.

get_hypo_location(mesh_spacing, hypo_loc=None)[source]

The method determines the location of the hypocentre within the rupture

Parameters:
  • meshMesh of points
  • 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.
  • hypo_loc – Hypocentre location as fraction of rupture plane, as a tuple of (Along Strike, Down Dip), e.g. a hypocentre located in the centroid of the rupture would be input as (0.5, 0.5), whereas a hypocentre located in a position 3/4 along the length, and 1/4 of the way down dip of the rupture plane would be entered as (0.75, 0.25).
Returns:

Hypocentre location as instance of Point

get_joyner_boore_distance(mesh)[source]

See superclass method for spec of input and result values.

Base class calls surface mesh’s method get_joyner_boore_distance().

get_mesh()[source]

Return surface’s mesh.

Uses _create_mesh() for creating the mesh for the first time. All subsequent calls to get_mesh() return the same mesh object.

Warning

It is required that the mesh is constructed “top-to-bottom”. That is, the first row of points should be the shallowest.

get_middle_point()[source]

Compute middle point from surface mesh representation. Calls openquake.hazardlib.geo.mesh.RectangularMesh.get_middle_point()

get_min_distance(mesh)[source]

See superclass method for spec of input and result values.

Base class implementation calls the corresponding method of the surface’s mesh.

Subclasses may override this method in order to make use of knowledge of a specific surface shape and thus perform better.

get_resampled_top_edge(angle_var=0.1)[source]

This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle.

Parameters:angle_var (float) – Number representing the maximum deviation (in degrees) admitted without the creation of a new segment
Returns:A Line representing the rupture surface’s top edge.
get_rx_distance(mesh)[source]

See superclass method for spec of input and result values.

The method extracts the top edge of the surface. For each point in mesh it computes the Rx distance to each segment the top edge is made of. The calculation is done by calling the function openquake.hazardlib.geo.geodetic.distance_to_arc(). The final Rx distance matrix is then constructed by taking, for each point in mesh, the minimum Rx distance value computed.

get_ry0_distance(mesh)[source]
Parameters:meshMesh of points to calculate Ry0-distance to.
Returns:Numpy array of distances in km.

See also superclass method for spec of input and result values.

This method uses an average strike direction to compute ry0.

get_top_edge_depth()[source]

Return minimum depth of surface’s top edge.

Returns:Float value, the vertical distance between the earth surface and the shallowest point in surface’s top edge in km.
class openquake.hazardlib.geo.surface.base.BaseSurface[source]

Base class for a surface in 3D-space.

get_area()[source]

Compute surface’s area in squared km.

Returns:Float value, the surface area
get_bounding_box()[source]

Compute surface geographical bounding box.

Returns:A tuple of four items. These items represent western, eastern, northern and southern borders of the bounding box respectively. Values are floats in decimal degrees.
get_closest_points(mesh)[source]

For each point from mesh find a closest point belonging to surface.

Parameters:meshMesh of points to find closest points to.
Returns:Mesh of the same shape as mesh with closest surface’s points on respective indices.
get_dip()[source]

Compute surface’s dip as decimal degrees in a range (0, 90].

The actual definition of the dip might depend on surface geometry.

Returns:Float value, the inclination (in degrees) of the surface with respect to the Earth surface
get_joyner_boore_distance(mesh)[source]

Compute and return Joyner-Boore (also known as Rjb) distance to each point of mesh.

Parameters:meshMesh of points to calculate Joyner-Boore distance to.
Returns:Numpy array of closest distances between the projections of surface and each point of the mesh to the earth surface.
get_middle_point()[source]

Compute coordinates of surface middle point.

The actual definition of middle point depends on the type of surface geometry.

Returns:instance of openquake.hazardlib.geo.point.Point representing surface middle point.
get_min_distance(mesh)[source]

Compute and return the minimum distance from the surface to each point of mesh. This distance is sometimes called Rrup.

Parameters:meshMesh of points to calculate minimum distance to.
Returns:A numpy array of distances in km.
get_rx_distance(mesh)[source]

Compute distance between each point of mesh and surface’s great circle arc.

Distance is measured perpendicular to the rupture strike, from the surface projection of the updip edge of the rupture, with the down dip direction being positive (this distance is usually called Rx).

In other words, is the horizontal distance to top edge of rupture measured perpendicular to the strike. Values on the hanging wall are positive, values on the footwall are negative.

Parameters:meshMesh of points to calculate Rx-distance to.
Returns:Numpy array of distances in km.
get_ry0_distance(mesh)[source]

Compute the minimum distance between each point of a mesh and the great circle arcs perpendicular to the average strike direction of the fault trace and passing through the end-points of the trace.

Parameters:meshMesh of points to calculate Ry0-distance to.
Returns:Numpy array of distances in km.
get_strike()[source]

Compute surface’s strike as decimal degrees in a range [0, 360).

The actual definition of the strike might depend on surface geometry.

Returns:Float value, the azimuth (in degrees) of the surface top edge
get_top_edge_depth()[source]

Compute minimum depth of surface’s top edge.

Returns:Float value, the vertical distance between the earth surface and the shallowest point in surface’s top edge in km.
get_width()[source]

Compute surface’s width (that is surface extension along the dip direction) in km.

The actual definition depends on the type of surface geometry.

Returns:Float value, the surface width

Planar surface

Module openquake.hazardlib.geo.surface.planar contains PlanarSurface.

class openquake.hazardlib.geo.surface.planar.PlanarSurface(mesh_spacing, strike, dip, top_left, top_right, bottom_right, bottom_left)[source]

Planar rectangular surface with two sides parallel to the Earth surface.

Parameters:
  • mesh_spacing – The desired distance between two adjacent points in the surface mesh in both horizontal and vertical directions, in km.
  • strike – Strike of the surface is the azimuth from top_left to top_right points.
  • dip – Dip is the angle between the surface itself and the earth surface.

Other parameters are points (instances of Point) defining the surface corners in clockwise direction starting from top left corner. Top and bottom edges of the polygon must be parallel to earth surface and to each other.

See NodalPlane for more detailed definition of strike and dip. Note that these parameters are supposed to match the factual surface geometry (defined by corner points), but this is not enforced or even checked.

Raises:ValueError – If either top or bottom points differ in depth or if top edge is not parallel to the bottom edge, if top edge differs in length from the bottom one, or if mesh spacing is not positive.
IMPERFECT_RECTANGLE_TOLERANCE = 0.0008

Maximum difference in surface’s rectangle side lengths, maximum offset of a bottom right corner from a plane that contains other corners, as well as maximum offset of a bottom left corner from a line drawn downdip perpendicular to top edge from top left corner, expressed as a fraction of the surface’s area.

_create_mesh()[source]

See openquake.hazardlib.geo.surface.base.BaseQuadrilateralSurface._create_mesh().

_get_top_edge_centroid()[source]

Overrides superclass' method in order to avoid creating a mesh.

_init_plane()[source]

Prepare everything needed for projecting arbitrary points on a plane containing the surface.

_project(lons, lats, depths)[source]

Project points to a surface’s plane.

Parameters are lists or numpy arrays of coordinates of points to project.

Returns:A tuple of three items: distances between original points and surface’s plane in km, “x” and “y” coordinates of points’ projections to the plane (in a surface’s coordinate space).
_project_back(dists, xx, yy)[source]

Convert coordinates in plane’s Cartesian space back to spherical coordinates.

Parameters are numpy arrays, as returned from _project(), which this method does the opposite to.

Returns:Tuple of longitudes, latitudes and depths numpy arrays.
classmethod from_corner_points(mesh_spacing, top_left, top_right, bottom_right, bottom_left)[source]

Create and return a planar surface from four corner points.

The azimuth of the line connecting the top left and the top right corners define the surface strike, while the angle between the line connecting the top left and bottom left corners and a line parallel to the earth surface defines the surface dip.

Parameters:
Returns:

An instance of PlanarSurface.

get_area()[source]

Return surface’s area value (in squared km) obtained as the product of surface lenght and width.

get_bounding_box()[source]

Compute surface bounding box from plane’s corners coordinates. Calls openquake.hazardlib.geo.utils.get_spherical_bounding_box()

Returns:A tuple of four items. These items represent western, eastern, northern and southern borders of the bounding box respectively. Values are floats in decimal degrees.
get_closest_points(mesh)[source]

See superclass' method.

This is an optimized version specific to planar surface that doesn’t make use of the mesh.

get_dip()[source]

Return dip value that was provided to the constructor.

get_joyner_boore_distance(mesh)[source]

See superclass' method.

This is an optimized version specific to planar surface that doesn’t make use of the mesh.

get_middle_point()[source]

Compute middle point from surface’s corners coordinates. Calls openquake.hazardlib.geo.utils.get_middle_point()

get_min_distance(mesh)[source]

See superclass' method.

This is an optimized version specific to planar surface that doesn’t make use of the mesh.

get_rx_distance(mesh)[source]

See superclass method for spec of input and result values.

This is an optimized version specific to planar surface that doesn’t make use of the mesh.

get_strike()[source]

Return strike value that was provided to the constructor.

get_top_edge_depth()[source]

Overrides superclass' method in order to avoid creating a mesh.

get_width()[source]

Return surface’s width value (in km) as computed in the constructor (that is mean value of left and right surface sides).

translate(p1, p2)[source]

Translate the surface for a specific distance along a specific azimuth direction.

Parameters are two points (instances of openquake.hazardlib.geo.point.Point) representing the direction and an azimuth for translation. The resulting surface corner points will be that far along that azimuth from respective corner points of this surface as p2 is located with respect to p1.

Returns:A new PlanarSurface object with the same mesh spacing, dip, strike, width, length and depth but with corners longitudes and latitudes translated.

Simple fault surface

Module openquake.hazardlib.geo.surface.simple_fault defines SimpleFaultSurface.

class openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface(mesh)[source]

Represent a fault surface as regular (uniformly spaced) 3D mesh of points.

Parameters:mesh – Instance of RectangularMesh representing surface geometry.

Another way to construct the surface object is to call from_fault_data().

_create_mesh()[source]

Return a mesh provided to object’s constructor.

classmethod check_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, mesh_spacing)[source]

Verify the fault data and raise ValueError if anything is wrong.

This method doesn’t have to be called by hands before creating the surface object, because it is called from from_fault_data().

classmethod from_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, mesh_spacing)[source]

Create and return a fault surface using fault source data.

Parameters:
  • fault_trace (openquake.hazardlib.geo.line.Line) – Geographical line representing the intersection between the fault surface and the earth surface.
  • upper_seismo_depth – Minimum depth ruptures can reach, in km (i.e. depth to fault’s top edge).
  • lower_seismo_depth – Maximum depth ruptures can reach, in km (i.e. depth to fault’s bottom edge).
  • dip – Dip angle (i.e. angle between fault surface and earth surface), in degrees.
  • mesh_spacing – Distance between two subsequent points in a mesh, in km.
Returns:

An instance of SimpleFaultSurface created using that data.

Uses check_fault_data() for checking parameters.

get_dip()[source]

Return the fault dip as the average dip over the fault surface mesh.

The average dip is defined as the weighted mean inclination of top row of mesh cells. See openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth()

Returns:The average dip, in decimal degrees.
classmethod get_fault_patch_vertices(rupture_top_edge, upper_seismogenic_depth, lower_seismogenic_depth, dip, index_patch=1)[source]

Get surface main vertices. Parameters are the same as for from_fault_data(), excluding fault_trace, and mesh spacing.

Parameters:
  • rupture_top_edge – A instances of openquake.hazardlib.geo.line.Line representing the rupture surface’s top edge.
  • index_patch – Indicate the patch of the fault in order to output the vertices. The fault patch numbering follows the same logic of the right-hand rule i.e. patch with index 1 is the first patch along the trace.
Returns:

Four :class:~openquake.hazardlib.geo.point.Point objects representing the four vertices of the target patch.

get_strike()[source]

Return the fault strike as the average strike along the fault trace.

The average strike is defined as the weighted mean azimuth of top row of mesh cells. See openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth()

Returns:The average strike, in decimal degrees.
classmethod get_surface_vertexes(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip)[source]

Get surface main vertexes.

Parameters are the same as for from_fault_data(), excluding mesh spacing.

Returns:Instance of Polygon describing the surface projection of the simple fault with specified parameters.
get_width()[source]

Return surface’s width (that is surface extension along the dip direction) in km.

The width is computed as the average width along the surface. See openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_width()

classmethod hypocentre_patch_index(hypocentre, rupture_top_edge, upper_seismogenic_depth, lower_seismogenic_depth, dip)[source]

This methods finds the index of the fault patch including the hypocentre.

Parameters:
  • hypocentrePoint object representing the location of hypocentre.
  • rupture_top_edge – A instances of openquake.hazardlib.geo.line.Line representing the rupture surface’s top edge.
  • upper_seismo_depth – Minimum depth ruptures can reach, in km (i.e. depth to fault’s top edge).
  • lower_seismo_depth – Maximum depth ruptures can reach, in km (i.e. depth to fault’s bottom edge).
  • dip – Dip angle (i.e. angle between fault surface and earth surface), in degrees.
Returns:

An integer corresponding to the index of the fault patch which contains the hypocentre.

classmethod surface_projection_from_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip)[source]

Get a surface projection of the simple fault surface.

Parameters are the same as for from_fault_data(), excluding mesh spacing.

Returns:Instance of Polygon describing the surface projection of the simple fault with specified parameters.

Complex fault surface

Module openquake.hazardlib.geo.surface.complex_fault defines ComplexFaultSurface.

class openquake.hazardlib.geo.surface.complex_fault.ComplexFaultSurface(mesh)[source]

Represent a complex fault surface as 3D mesh of points (not necessarily uniformly spaced across the surface area).

Parameters:mesh – Instance of RectangularMesh representing surface geometry.

Another way to construct the surface object is to call from_fault_data().

_create_mesh()[source]

Return a mesh provided to object’s constructor.

classmethod check_aki_richards_convention(edges)[source]

Verify that surface (as defined by corner points) conforms with Aki and Richard convention (i.e. surface dips right of surface strike)

This method doesn’t have to be called by hands before creating the surface object, because it is called from from_fault_data().

classmethod check_fault_data(edges, mesh_spacing)[source]

Verify the fault data and raise ValueError if anything is wrong.

This method doesn’t have to be called by hands before creating the surface object, because it is called from from_fault_data().

classmethod check_surface_validity(edges)[source]

Check validity of the surface.

Project edge points to vertical plane anchored to surface upper left edge and with strike equal to top edge strike. Check that resulting polygon is valid.

This method doesn’t have to be called by hands before creating the surface object, because it is called from from_fault_data().

classmethod from_fault_data(edges, mesh_spacing)[source]

Create and return a fault surface using fault source data.

Parameters:
  • edges – A list of at least two horizontal edges of the surface as instances of openquake.hazardlib.geo.line.Line. The list should be in top-to-bottom order (the shallowest edge first).
  • mesh_spacing – Distance between two subsequent points in a mesh, in km.
Returns:

An instance of ComplexFaultSurface created using that data.

Raises:

ValueError – If requested mesh spacing is too big for the surface geometry (doesn’t allow to put a single mesh cell along length and/or width).

Uses check_fault_data() for checking parameters.

get_dip()[source]

Return the fault dip as the average dip over the mesh.

The average dip is defined as the weighted mean inclination of all the mesh cells. See openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth()

Returns:The average dip, in decimal degrees.
get_strike()[source]

Return the fault strike as the average strike over the mesh.

The average strike is defined as the weighted mean azimuth of all the mesh cells. See openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth()

Returns:The average strike, in decimal degrees.
get_width()[source]

Return surface’s width (that is surface extension along the dip direction) in km.

The width is computed as the average width along the surface. See openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_width()

classmethod surface_projection_from_fault_data(edges)[source]

Get a surface projection of the complex fault surface.

Parameters:edges – A list of horizontal edges of the surface as instances of openquake.hazardlib.geo.line.Line.
Returns:Instance of Polygon describing the surface projection of the complex fault.

Multi surface

Module openquake.hazardlib.geo.surface.multi defines MultiSurface.

class openquake.hazardlib.geo.surface.multi.MultiSurface(surfaces)[source]

Represent a surface as a collection of independent surface elements.

Parameters:surfaces – List of instances of subclasses of BaseSurface each representing a surface geometry element.
_get_areas()[source]

Return surface elements area values in a numpy array.

get_area()[source]

Return sum of surface elements areas (in squared km).

get_bounding_box()[source]

Compute bounding box for each surface element, and then return the bounding box of all surface elements’ bounding boxes.

Returns:A tuple of four items. These items represent western, eastern, northern and southern borders of the bounding box respectively. Values are floats in decimal degrees.
get_closest_points(mesh)[source]

For each point in mesh find the closest surface element, and return the corresponding closest point.

See superclass method for spec of input and result values.

get_dip()[source]

Compute dip of each surface element and return area-weighted average value (in range (0, 90]).

Given that dip values are constrained in the range (0, 90], the simple formula for weighted mean is used.

get_joyner_boore_distance(mesh)[source]

For each point in mesh compute the Joyner-Boore distance to all the surface elements and return the smallest value.

See superclass method for spec of input and result values.

get_middle_point()[source]

If MultiSurface is defined by a single surface, simply returns surface’s middle point, otherwise find surface element closest to the surface’s bounding box centroid and return corresponding middle point.

Note that the concept of middle point for a multi surface is ambiguous and alternative definitions may be possible. However, this method is mostly used to define the hypocenter location for ruptures described by a multi surface (see openquake.hazardlib.source.characteristic.CharacteristicFaultSource.iter_ruptures()). This is needed because when creating fault based sources, the rupture’s hypocenter locations are not explicitly defined, and therefore an automated way to define them is required.

get_min_distance(mesh)[source]

For each point in mesh compute the minimum distance to each surface element and return the smallest value.

See superclass method for spec of input and result values.

get_rx_distance(mesh)[source]

For each point in mesh find the closest surface element, and return the corresponding rx distance.

See superclass method for spec of input and result values.

get_strike()[source]

Compute strike of each surface element and return area-weighted average value (in range [0, 360]) using formula from: http://en.wikipedia.org/wiki/Mean_of_circular_quantities

Note that the original formula has been adapted to compute a weighted rather than arithmetic mean.

get_top_edge_depth()[source]

Compute top edge depth of each surface element and return area-weighted average value (in km).

get_width()[source]

Compute width of each surface element, and return area-weighted average value (in km).