shakelib.distance

class shakelib.distance.Distance(gmpe, lon, lat, dep, rupture=None)[source]

Bases: object

Class for distance calculations. Primary method is ‘get_distance’. To handle multiple segment ruptures, many of the distances are based on the Spudich and Chiou (2015) GC2 coordinate system.

References

Spudich, Paul and Chiou, Brian, 2015, Strike-parallel and strike-normal coordinate system around geometrically complicated rupture traces—Use by NGA-West2 and further improvements: U.S. Geological Survey Open-File Report 2015-1028, 20 p., http://dx.doi.org/10.3133/ofr20151028.

Constructor for Distance class.

Parameters:
  • gmpe (GMPE) – Concrete subclass of GMPE [link]; can be individual instance or list of instances.
  • lon (array) – A numpy array of site longitudes.
  • lat (array) – A numpy array of site latitudes.
  • dep (array) – A numpy array of site depths (km); down is positive.
  • rupture (Rupture) – A Shakemap Rupture instance.
Returns:

Distance object.

classmethod fromSites(gmpe, sites, rup)[source]

Convenience class method to construct a Distance object from a sites object.

Parameters:
  • gmpe (GMPE) – Concrete subclass of GMPE [link]; can be individual instance or list of instances.
  • sites (Sites) – A Shakemap Sites object.
  • rup (Rupture) – A Shakemap Rupture object.
Returns:

Distance object.

getDistanceContext()[source]
Returns:Openquake distance context [link].
shakelib.distance.get_distance_measures()[source]

Returns a list of strings specifying the distance measure types (e.g. “repi”, “rhypo”) available for the “methods” argument to get_diistance().

Returns:A list of strings.
shakelib.distance.get_distance(methods, lat, lon, dep, rupture, dx=0.5)[source]

Calculate distance using any one of a number of distance measures. One of quadlist OR hypo must be specified. The following table gives the allowed distance strings and a description of each.

String Description
repi Distance to epicenter.
rhypo Distance to hypocenter.
rjb Joyner-Boore distance; this is closest distance to the surface projection of the rupture plane.
rrup Rupture distance; closest distance to the rupture plane.
rx Strike-normal distance; same as GC2 coordiante T.
ry Strike-parallel distance; same as GC2 coordiante U, but with a shift in origin definition. See Spudich and Chiou (2015) http://dx.doi.org/10.3133/ofr20151028.
ry0 Horizontal distance off the end of the rupture measured parallel to strike. Can only be zero or positive. We compute this as a function of GC2 coordinate U.
U GC2 coordinate U.
T GC2 coordinate T.
Parameters:
  • methods (list) – List of strings (or just a string) of distances to compute.
  • lat (array) – A numpy array of latitudes.
  • lon (array) – A numpy array of longidues.
  • dep (array) – A numpy array of depths (km).
  • rupture (Rupture) – A ShakeMap Rupture instance.
  • dx (float) – Mesh spacing for rupture; only used if rupture is an EdgeRupture subclass.
Returns:

dictionary of numpy arrays of distances, size of lon.shape.

Return type:

dict