shakelib.rupture.quad_rupture¶
-
class
shakelib.rupture.quad_rupture.
QuadRupture
(d, origin)[source]¶ Bases:
shakelib.rupture.base.Rupture
Rupture class that represents the rupture surface as a combination of quadrilaterals. Each quadrilateral must have horizontal top and bottom edges and must be coplanar. These restrictions make the computation of rupture distances more efficient. The number of points in the top edges must match the number of points in the bottom edge.
Create a QuadRupture instance from a GeoJSON dictionary and an Origin.
Parameters: - d (dict) – Rupture GeoJSON dictionary.
- origin (Origin) – Reference to a ShakeMap Origin object.
Returns: QuadRupture instance.
-
getLength
()[source]¶ Compute length of rupture based on top edge in km.
Returns: Length of rupture (km). Return type: float
-
getWidth
()[source]¶ Compute average rupture width (km) for all quadrilaterals defined for the rupture.
Returns: Average width in km of all rupture quadrilaterals. Return type: float
-
classmethod
fromTrace
(xp0, yp0, xp1, yp1, zp, widths, dips, origin, strike=None, group_index=None, reference='')[source]¶ Create a QuadRupture instance from a set of vertices that define the top of the rupture, and an array of widths/dips.
Each rupture quadrilaterial is defined by specifying the latitude, longitude, and depth of the two vertices on the top edges, which must have the dame depths. The other verticies are then constructed from the top edges and the width and dip of the quadrilateral.
Parameters: - xp0 (array) – Array or list of longitudes (floats) of p0.
- yp0 (array) – Array or list of latitudes (floats) of p0.
- xp1 (array) – Array or list of longitudes (floats) of p1.
- yp1 (array) – Array or list of latitudes (floats) of p1.
- zp (array) – Array or list of depths for each of the top of rupture rectangles (km).
- widths (array) – Array of widths for each of rectangle (km).
- dips (array) – Array of dips for each of rectangle (degrees).
- origin (Origin) – Reference to a ShakeMap origin object.
- strike (array) – If None then strike is computed from verticies of top edge of each quadrilateral. If a scalar, then all quadrilaterals are constructed assuming this strike direction. If an array with the same length as the trace coordinates then it specifies the strike for each quadrilateral.
- group_index (list) – List of integers to indicate group index. If None then each quadrilateral is assumed to be in a different group since there is no guarantee that any of them are continuous.
- reference (str) – String explaining where the rupture definition came from (publication style reference, etc.).
Returns: QuadRupture instance.
-
writeTextFile
(rupturefile)[source]¶ Write rupture data to rupture file format as defined in ShakeMap Software Guide.
Note that this currently treats each quadrilateral as a separate polygon. This needs to be udpated.
Parameters: rupturefile (str) – Filename of output data file OR file-like object.
-
classmethod
fromVertices
(xp0, yp0, zp0, xp1, yp1, zp1, xp2, yp2, zp2, xp3, yp3, zp3, origin, group_index=None, reference=None)[source]¶ Create a QuadDrupture instance from the vector of vertices that fully define the quadrilaterals. The points p0, …, p3 are labeled below for a trapezoid:
p0--------p1 / | / | p3-----------p2
All of the following vector arguments must have the same length.
Parameters: - xp0 (array) – Array or list of longitudes (floats) of p0.
- yp0 (array) – Array or list of latitudes (floats) of p0.
- zp0 (array) – Array or list of depths (floats) of p0.
- xp1 (array) – Array or list of longitudes (floats) of p1.
- yp1 (array) – Array or list of latitudes (floats) of p1.
- zp1 (array) – Array or list of depths (floats) of p1.
- xp2 (array) – Array or list of longitudes (floats) of p2.
- yp2 (array) – Array or list of latitudes (floats) of p2.
- zp2 (array) – Array or list of depths (floats) of p2.
- xp3 (array) – Array or list of longitudes (floats) of p3.
- yp3 (array) – Array or list of latitudes (floats) of p3.
- zp3 (array) – Array or list of depths (floats) of p3.
- origin (Origin) – Reference to a ShakeMap Origin object.
- group_index (list) – List of integers to indicate group index. If None then each quadrilateral is assumed to be in a different group since there is no guarantee that any of them are continuous.
- reference (str) – String explaining where the rupture definition came from (publication style reference, etc.)
Returns: - QuadRupture object, where the rupture is modeled as a series of
trapezoids.
-
getQuadrilaterals
()[source]¶ Return a list of quadrilaterals.
Returns: - List of quadrilaterals where each quad is a tuple of four
- Point objects.
Return type: list
-
getStrike
()[source]¶ Return strike angle. If rupture consists of multiple quadrilaterals, the average strike angle, weighted by quad length, is returned. Note: for ruptures with quads where the strike angle changes by 180 deg due to reverses in dip direction are problematic and not handeled well by this algorithm.
Returns: Strike angle in degrees. Return type: float
-
getDepthToTop
()[source]¶ Determine shallowest vertex of entire rupture.
Returns: Shallowest depth of all vertices (float).
-
getDip
()[source]¶ Return average dip of all quadrilaterals in the rupture.
Returns: Average dip in degrees. Return type: float
-
getIndividualWidths
()[source]¶ Return an array of rupture widths (km), one for each quadrilateral defined for the rupture.
Returns: Array of quad widths in km of all rupture quadrilaterals.
-
getIndividualTopLengths
()[source]¶ Return an array of rupture lengths along top edge (km), one for each quadrilateral defined for the rupture.
Returns: Array of lengths in km of top edge of quadrilaterals.
-
lats
¶ Return an array of latitudes for the rupture verticies arranged for plotting purposes; will give an outline of each group connected segments.
Returns: - Numpy array of closed-loop latitude values; disconnected
- segments are separated by nans.
Return type: array
-
lons
¶ Return an array of longitudes for the rupture verticies arranged for plotting purposes; will give an outline of each group connected segments.
Returns: - Numpy array of closed-loop longitude values; disconnected
- segments are separated by nans.
Return type: array
-
depths
¶ Return an array of depths for the rupture verticies arranged for plotting purposes; will give an outline of each group connected segments.
Returns: - Numpy array of closed-loop depths; disconnected
- segments are separated by nans.
Return type: array
-
getDeps
()[source]¶ Return a copy of the array of depths for the rupture verticies.
Returns: Numpy array of latitude values. Return type: array
-
getNumGroups
()[source]¶ Return a count of the number of rupture groups.
Returns: Rnumber of rupture groups. Return type: int
-
getNumQuads
()[source]¶ Return a count of the number of rupture quadrilaterals.
Returns: Number of rupture quadrilaterals. Return type: int
-
getRuptureAsArrays
()[source]¶ Return a 3-tuple of numpy arrays indicating X, Y, Z (lon,lat,depth) coordinates. Rupture groups are separated by numpy.NaN values.
Returns: - 3-tuple of numpy arrays indicating X,Y,Z (lon,lat,depth)
- coordinates.
Return type: tuple
-
getRuptureAsMesh
()[source]¶ Return rupture segments as a OQ-Hazardlib Mesh object.
Returns: //github.com/gem/oq-hazardlib/blob/master/openquake/hazardlib/geo/mesh.py) Return type: Mesh (https
-
computeRjb
(lon, lat, depth)[source]¶ Method for computing Joyner-Boore distance.
Parameters: - lon (array) – Numpy array of longitudes.
- lat (array) – Numpy array of latitudes.
- depth (array) – Numpy array of depths (km; positive down).
Returns: Joyner-Boore distance (km).
Return type: array
-
computeRrup
(lon, lat, depth)[source]¶ Method for computing rupture distance.
Parameters: - lon (array) – Numpy array of longitudes.
- lat (array) – Numpy array of latitudes.
- depth (array) – Numpy array of depths (km; positive down).
Returns: Rupture distance (km).
Return type: array
-
computeGC2
(lon, lat, depth)[source]¶ Method for computing version 2 of the Generalized Coordinate system (GC2) by Spudich and Chiou OFR 2015-1028.
Parameters: - lon (array) – Numpy array of longitudes.
- lat (array) – Numpy array of latitudes.
- depth (array) – Numpy array of depths (km; positive down).
Returns: - Dictionary with keys for each of the GC2-related distances,
which include ‘rx’, ‘ry’, ‘ry0’, ‘U’, ‘T’.
Return type: dict