shakelib.rupture.utils

shakelib.rupture.utils.is_quad(q)[source]

Checks that an individual quad is coplanar.

Parameters:q (list) – A quadrilateral; list of four OQ Points.
Returns:
Bool for whether or not the points are planar within tolerance;
and also the corrected quad where p2 is adjusted to be on the same plane as the other points.
Return type:tuple
shakelib.rupture.utils.get_quad_width(q)[source]

Return width of an individual planar trapezoid, where the p0-p1 distance represents the long side.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:Width of planar trapezoid.
Return type:float
shakelib.rupture.utils.get_quad_mesh(q, dx)[source]

Create a mesh from a quadrilateal.

Parameters:
  • q (list) – A quadrilateral; list of four points.
  • dx (float) – Target dx in km; used to get nx and ny of mesh, but mesh snaps to edges of rupture so actual dx/dy will not actually equal this value in general.
Returns:

Mesh dictionary, which includes numpy arrays:

  • llx: lower left x coordinate in ECEF coords.
  • lly: lower left y coordinate in ECEF coords.
  • llz: lower left z coordinate in ECEF coords.
  • ulx: upper left x coordinate in ECEF coords.
  • etc.

Return type:

dict

shakelib.rupture.utils.get_local_unit_slip_vector(strike, dip, rake)[source]

Compute the components of a unit slip vector.

Parameters:
  • strike (float) – Clockwise angle (deg) from north of the line at the intersection of the rupture plane and the horizontal plane.
  • dip (float) – Angle (deg) between rupture plane and the horizontal plane normal to the strike (0-90 using right hand rule).
  • rake (float) – Direction of motion of the hanging wall relative to the foot wall, as measured by the angle (deg) from the strike vector.
Returns:

Unit slip vector in ‘local’ N-S, E-W, U-D coordinates.

Return type:

Vector

shakelib.rupture.utils.get_local_unit_slip_vector_DS(strike, dip, rake)[source]

Compute the DIP SLIP components of a unit slip vector.

Parameters:
  • strike (float) – Clockwise angle (deg) from north of the line at the intersection of the rupture plane and the horizontal plane.
  • dip (float) – Angle (degrees) between rupture plane and the horizontal plane normal to the strike (0-90 using right hand rule).
  • rake (float) – Direction of motion of the hanging wall relative to the foot wall, as measured by the angle (deg) from the strike vector.
Returns:

Unit slip vector in ‘local’ N-S, E-W, U-D coordinates.

Return type:

Vector

shakelib.rupture.utils.get_local_unit_slip_vector_SS(strike, dip, rake)[source]

Compute the STRIKE SLIP components of a unit slip vector.

Parameters:
  • strike (float) – Clockwise angle (deg) from north of the line at the intersection of the rupture plane and the horizontal plane.
  • dip (float) – Angle (degrees) between rupture plane and the horizontal plane normal to the strike (0-90 using right hand rule).
  • rake (float) – Direction of motion of the hanging wall relative to the foot wall, as measured by the angle (deg) from the strike vector.
Returns:

Unit slip vector in ‘local’ N-S, E-W, U-D coordinates.

Return type:

Vector

shakelib.rupture.utils.reverse_quad(q)[source]

Reverse the verticies of a quad in the sense that the strike direction is flipped.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:Reversed quadrilateral.
Return type:list
shakelib.rupture.utils.get_quad_slip(q, rake)[source]

Compute the unit slip vector in ECEF space for a quad and rake angle.

Parameters:
  • q (list) – A quadrilateral; list of four points.
  • rake (float) – Direction of motion of the hanging wall relative to
  • foot wall, as measured by the angle (the) –
Returns:

Unit slip vector in ECEF space.

Return type:

Vector

shakelib.rupture.utils.get_quad_length(q)[source]

Length of top eduge of a quadrilateral.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:Length of quadrilateral in km.
Return type:float
shakelib.rupture.utils.get_quad_dip(q)[source]

Dip of a quadrilateral.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:Dip in degrees.
Return type:float
shakelib.rupture.utils.get_quad_normal(q)[source]

Compute the unit normal vector for a quadrilateral in ECEF coordinates.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:Normalized normal vector for the quadrilateral in ECEF coords.
Return type:Vector
shakelib.rupture.utils.get_quad_strike_vector(q)[source]

Compute the unit vector pointing in the direction of strike for a quadrilateral in ECEF coordinates. Top edge assumed to be horizontal.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:The unit vector pointing in strike direction in ECEF coords.
Return type:Vector
shakelib.rupture.utils.get_quad_down_dip_vector(q)[source]

Compute the unit vector pointing down dip for a quadrilateral in ECEF coordinates.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:The unit vector pointing down dip in ECEF coords.
Return type:Vector
shakelib.rupture.utils.get_vertical_vector(q)[source]

Compute the vertical unit vector for a quadrilateral in ECEF coordinates.

Parameters:q (list) – A quadrilateral; list of four points.
Returns:
Normalized vertical vector for the quadrilateral in ECEF
coords.
Return type:Vector
shakelib.rupture.utils.get_distance_to_plane(planepoints, otherpoint)[source]

Calculate a point’s distance to a plane. Used to figure out if a quadrilateral points are all co-planar.

Parameters:
  • planepoints (list) – List of three points (from Vector class) defining a plane.
  • otherpoint (Vector) – 4th Vector to compare to points defining the plane.
Returns:

Distance (in meters) from otherpoint to plane.

Return type:

float

shakelib.rupture.utils.rake_to_mech(rake)[source]

Convert rake to mechanism.

Parameters:rake (float) – Rake angle in degrees.
Returns:Mechanism.
Return type:str