Skip to content

groundmotion

ASB2014 ground motion, distances, rupture geometry and the scenario driver.

quakecascade.groundmotion

Ground motion: Akkar, Sandikkaya & Bommer (2014), distances and rupture geometry.

Examples:

>>> import numpy as np
>>> from quakecascade import groundmotion as gm
>>> out = gm.asb2014.predict("RJB", 7.0, 20.0, 750.0, "SS")
>>> round(float(out["pga_g"][0]), 4)
0.1461

quakecascade.groundmotion.scenario

Scenario ground motion at many sites from one fault rupture.

Joyner-Boore distance (to the rupture projection when a FaultGeometry is given, else to the trace) feeds Akkar, Sandikkaya & Bommer (2014) in its RJB form. For each epsilon the output carries exp(ln_median + epsilon * sigma_total), the per-site marginal quantile of the model's total aleatory variability; these are not one spatially consistent event (see quakecascade.montecarlo for correlated sampling).

Sites without Vs30 get NaN and status no_vs30; sites with non-finite coordinates get no_location; sites outside the published envelope keep their values with status outside_envelope and the flag codes beside them.

Z_P90 module-attribute

Z_P90 = 1.2815515655446004

Standard-normal quantile for the 10th/90th percentiles, Phi^-1(0.9).

DEFAULT_EPSILONS module-attribute

DEFAULT_EPSILONS = (-Z_P90, 0.0, Z_P90)

Epsilons giving the 10th, 50th and 90th percentiles.

SCENARIO_COLUMNS module-attribute

SCENARIO_COLUMNS = ...

Fixed columns of the scenario frame (percentile columns are added per epsilon).

percentile_label

percentile_label(epsilon)

Column suffix for an epsilon: "p10", "p50", "p90", "p2_5"...

The percentile is 100 * Phi(epsilon) rounded to 0.1.

scenario

scenario(
    site_xy_m,
    vs30,
    trace_xy_m,
    magnitude,
    mechanism,
    geometry=None,
    epsilons=DEFAULT_EPSILONS,
    periods=(),
    crs=None,
    index=None,
)

ASB2014 ground motion for a fault-rupture scenario at many sites.

Parameters:

Name Type Description Default
site_xy_m array_like (N, 2), Shapely points or GeoSeries/GeoDataFrame of points

Sites in metres of a projected CRS.

required
vs30 array_like(N) or float

Vs30 in m/s; NaN means unknown (status no_vs30).

required
trace_xy_m array_like (M, 2), list of polylines, Shapely or GeoPandas lines

Fault trace in the same metric CRS.

required
magnitude float

Moment magnitude Mw (no default: the scenario defines it).

required
mechanism ('SS', 'NS', 'RS')

Style of faulting.

"SS"
geometry FaultGeometry

Dip and depths with their source. None measures RJB to the trace (exact only for a vertical rupture).

None
epsilons sequence of float

Total-sigma shifts; each gives one percentile column per measure.

(-1.2816, 0, 1.2816)
periods sequence of float

Published spectral periods (s) to add as sa_<T>_g_<pXX> columns.

()
crs optional

CRS of the coordinates; must be metric when given.

None
index optional

Index for the returned frame (default: the GeoDataFrame index, else a RangeIndex).

None

Returns:

Type Description
DataFrame

vs30_m_s, rjb_km, gm_status, gm_envelope_flags, vs30_capped, pga_g_<pXX> and pgv_cms_<pXX> for each epsilon (pga_g_p10, pga_g_p50, pga_g_p90, pgv_cms_p50 ... with the defaults) and sa_<T>_g_<pXX> for requested periods. Run metadata (model, DOI, distance method, sigmas, envelope notes) is in frame.attrs["groundmotion"].

quakecascade.groundmotion.asb2014

Ground-motion prediction after Akkar, Sandikkaya & Bommer (2014).

Akkar, S., Sandikkaya, M. A. & Bommer, J. J. (2014). Empirical ground-motion models for point- and extended-source crustal earthquake scenarios in Europe and the Middle East. Bulletin of Earthquake Engineering 12(1), 359-387. https://doi.org/10.1007/s10518-013-9461-4

Ported from the PlanX QGIS plugin (engine/gmpe.py, same author) with the arithmetic unchanged; the coefficients are in _asb2014_data and are reproduced from the table the authors supplied to pyGMM (MIT licence).

Three properties of this model are load-bearing:

  1. The site term is nonlinear and conditioned on the rock PGA at the same site, so rock motion is computed first and the site term applied second.
  2. The site term is not monotone in Vs30 at short periods. At Mw 7, R = 20 km, PGA peaks near Vs30 = 400 m/s and falls on both sides, because the nonlinear term suppresses short-period motion on soft soil. A test asserts this so a later change cannot flatten it.
  3. Vs30 above 1000 m/s is capped by the model itself (v_con), so 1000 and 1200 m/s give identical numbers; predict reports vs30_capped.

The paper publishes three coefficient sets - Joyner-Boore (RJB), epicentral (Repi) and hypocentral (Rhypo) - and no Rrup model, so an extended rupture is handled through RJB.

SCENARIOS module-attribute

SCENARIOS = ('point', 'fault')

Scenario kinds the distance helpers understand.

DISTANCE_METRICS module-attribute

DISTANCE_METRICS = ('RJB', 'Repi', 'Rhypo')

The three distance metrics the paper publishes coefficients for.

METRIC_LABELS module-attribute

METRIC_LABELS = ...

Plain-language names of DISTANCE_METRICS.

METRICS_BY_SCENARIO module-attribute

METRICS_BY_SCENARIO = {
    "point": ("RJB", "Repi", "Rhypo"),
    "fault": ("RJB",),
}

Metrics defined for each scenario kind. An extended rupture has no single epicentre or hypocentre, so only RJB is offered for it.

MECHANISMS module-attribute

MECHANISMS = ('SS', 'NS', 'RS')

Style-of-faulting codes of the paper (strike-slip is the reference).

MECHANISM_LABELS module-attribute

MECHANISM_LABELS = {
    "SS": "Strike-slip",
    "NS": "Normal",
    "RS": "Reverse",
}

Plain-language names of MECHANISMS.

APPLICABILITY module-attribute

APPLICABILITY = {
    "magnitude": (4.0, 8.0),
    "distance_km": (0.0, 200.0),
    "vs30": (150.0, 1200.0),
}

Validity ranges declared by Akkar et al. (2014). Outside them a result is flagged, never silently extrapolated.

SHALLOW_DEPTH_KM module-attribute

SHALLOW_DEPTH_KM = 30.0

Shallow-crustal reporting convention, not a model range: the paper has no depth term. Exceeding it raises the depth_above flag only.

V_REF module-attribute

V_REF = float(gmpe_data.CONSTANTS['v_ref'])

Constants of Akkar et al. (2014): the reference rock Vs30 (750 m/s), the Vs30 above which the site term stops growing (v_con, 1000 m/s) and the hinge magnitude c_1 (6.75).

SITE_VS30_CAP module-attribute

SITE_VS30_CAP = float(gmpe_data.CONSTANTS['v_con'])

Constants of Akkar et al. (2014): the reference rock Vs30 (750 m/s), the Vs30 above which the site term stops growing (v_con, 1000 m/s) and the hinge magnitude c_1 (6.75).

M_REF module-attribute

M_REF = float(gmpe_data.CONSTANTS['c_1'])

Constants of Akkar et al. (2014): the reference rock Vs30 (750 m/s), the Vs30 above which the site term stops growing (v_con, 1000 m/s) and the hinge magnitude c_1 (6.75).

PERIODS module-attribute

PERIODS = gmpe_data.PERIODS

Layout of the coefficient tables: the spectral periods in seconds (0.01 to 4 s), the row indices of PGA and PGV, and the number of rows (PGA, PGV and the 62 periods).

INDEX_PGA module-attribute

INDEX_PGA = gmpe_data.INDEX_PGA

Layout of the coefficient tables: the spectral periods in seconds (0.01 to 4 s), the row indices of PGA and PGV, and the number of rows (PGA, PGV and the 62 periods).

INDEX_PGV module-attribute

INDEX_PGV = gmpe_data.INDEX_PGV

Layout of the coefficient tables: the spectral periods in seconds (0.01 to 4 s), the row indices of PGA and PGV, and the number of rows (PGA, PGV and the 62 periods).

N_ROWS module-attribute

N_ROWS = gmpe_data.N_ROWS

Layout of the coefficient tables: the spectral periods in seconds (0.01 to 4 s), the row indices of PGA and PGV, and the number of rows (PGA, PGV and the 62 periods).

FLAG_CODES module-attribute

FLAG_CODES = (
    "mag_below",
    "mag_above",
    "dist_above",
    "vs30_below",
    "vs30_above",
    "depth_above",
)

Codes for the ways a site can leave the published envelope.

FLAG_LABELS module-attribute

FLAG_LABELS = ...

Plain-language descriptions of FLAG_CODES.

distances

distances(scenario, site_xy, units_per_km, **kwargs)

Distance in kilometres for every published metric, for this scenario.

scenario="point" needs epicentre_xy and depth_km; scenario="fault" needs polylines.

point_distances

point_distances(
    site_xy, epicentre_xy, units_per_km, depth_km
)

RJB, Repi and Rhypo for a point source, in kilometres.

A point source has no rupture surface, so its Joyner-Boore and epicentral distances are the same horizontal distance; the hypocentral distance adds the focal depth in quadrature.

Parameters:

Name Type Description Default
site_xy (array_like, shape(N, 2))

Site coordinates in a projected CRS.

required
epicentre_xy (array_like, shape(2))

Epicentre in the same CRS.

required
units_per_km float

Linear units of the CRS per kilometre (1000.0 for metres). No default, on purpose.

required
depth_km float

Focal depth in kilometres. No default: the scenario defines it.

required

Returns:

Type Description
dict

{"RJB": ..., "Repi": ..., "Rhypo": ...} arrays of shape (N,).

trace_distances

trace_distances(site_xy, polylines, units_per_km)

RJB for an extended rupture, as the horizontal distance to its trace, in km.

For a vertical rupture the surface projection is the trace, so the distance to the trace is the Joyner-Boore distance. For a dipping rupture the projection extends down-dip of the trace and this overstates RJB on the hanging wall; use quakecascade.groundmotion.rupture.rjb_km with a FaultGeometry there.

Parameters:

Name Type Description Default
site_xy (array_like, shape(N, 2))

Site coordinates in a projected CRS.

required
polylines sequence of array_like, each shape (M, 2)

Trace polylines in the same CRS.

required
units_per_km float

Linear units of the CRS per kilometre. No default.

required

Returns:

Type Description
dict

{"RJB": ndarray (N,)}.

table

table(metric)

Coefficient table of a distance metric as float64 arrays of length 64.

Rows: 0 = PGA, 1 = PGV, 2..63 = Sa at PERIODS. Source: Akkar et al. (2014), coefficient tables as supplied to pyGMM (2016-03-17).

check_metric

check_metric(metric, scenario)

A complaint if metric is not defined for scenario, else None.

period_index

period_index(period)

Row index of a published spectral period, or None.

The model is tabulated at fixed periods and is not interpolated: an interpolated value would be one no source supports.

nearest_periods

nearest_periods(period, count=3)

The published periods closest to period, for an error message.

parse_periods

parse_periods(text)

Published spectral periods named in a comma-separated string, ascending.

Empty text means "none". A period the model does not tabulate is refused with the nearest published values named.

predict

predict(
    metric,
    magnitude,
    distance_km,
    vs30,
    mechanism,
    epsilon=0.0,
)

Intensity measures at each site after Akkar et al. (2014).

Inputs of length 1 broadcast against length N.

Parameters:

Name Type Description Default
metric ('RJB', 'Repi', 'Rhypo')

Distance metric; selects the coefficient set.

"RJB"
magnitude float or array_like

Moment magnitude Mw.

required
distance_km float or array_like

Distance in km in the chosen metric.

required
vs30 float or array_like

Time-averaged shear-wave velocity to 30 m, m/s. NaN propagates to NaN.

required
mechanism str or array_like of str

"SS", "NS" or "RS".

required
epsilon float

Number of total standard deviations (ln units) added to every row; 0 returns the median.

0.0

Returns:

Type Description
dict

ln_median (N, 64), im (N, 64) = exp(ln_median + epsilon * sigma_total), pga_g (N,), pgv_cms (N,), sa_g (N, 62), periods, sigma_within, sigma_between, sigma_total (64,), rock_pga_g (N,) and vs30_capped (N,) bool.

sigma_invariant_worst

sigma_invariant_worst(metric)

Worst |sigma_total - sqrt(between^2 + within^2)| in a table.

The published components satisfy the identity to the four-decimal rounding of the table, so this is a transcription check.

envelope_flags

envelope_flags(magnitude, distance_km, vs30, depth_km=None)

Per-site codes for every published range the scenario leaves.

Returns one list of FLAG_CODES per site; an empty list means the site is inside the envelope. Length-1 inputs broadcast. NaN inputs raise no flag (a missing value is a status, not an envelope violation).

envelope_report

envelope_report(
    magnitude, distance_km, vs30, depth_km=None
)

Every way the scenario leaves the published ranges, as sentences.

Built from envelope_flags, so the two cannot disagree. An empty list means the run is inside the envelope.

quakecascade.groundmotion.distance

Source-to-site distances for the ASB2014 model, in kilometres.

Ported from the PlanX QGIS plugin (engine/gmpe.py, same author) with the arithmetic unchanged, plus input coercion helpers that accept NumPy arrays, Shapely geometries and GeoPandas objects.

The distance kernels take a units_per_km argument with no default: a distance silently off by a factor of 1000 still returns a number, still renders, and is wrong everywhere, so the caller states the unit. The higher-level quakecascade.groundmotion.scenario works in metres and passes 1000.0 itself.

SCENARIOS module-attribute

SCENARIOS = ('point', 'fault')

Scenario kinds the distance helpers understand.

point_distances

point_distances(
    site_xy, epicentre_xy, units_per_km, depth_km
)

RJB, Repi and Rhypo for a point source, in kilometres.

A point source has no rupture surface, so its Joyner-Boore and epicentral distances are the same horizontal distance; the hypocentral distance adds the focal depth in quadrature.

Parameters:

Name Type Description Default
site_xy (array_like, shape(N, 2))

Site coordinates in a projected CRS.

required
epicentre_xy (array_like, shape(2))

Epicentre in the same CRS.

required
units_per_km float

Linear units of the CRS per kilometre (1000.0 for metres). No default, on purpose.

required
depth_km float

Focal depth in kilometres. No default: the scenario defines it.

required

Returns:

Type Description
dict

{"RJB": ..., "Repi": ..., "Rhypo": ...} arrays of shape (N,).

trace_distances

trace_distances(site_xy, polylines, units_per_km)

RJB for an extended rupture, as the horizontal distance to its trace, in km.

For a vertical rupture the surface projection is the trace, so the distance to the trace is the Joyner-Boore distance. For a dipping rupture the projection extends down-dip of the trace and this overstates RJB on the hanging wall; use quakecascade.groundmotion.rupture.rjb_km with a FaultGeometry there.

Parameters:

Name Type Description Default
site_xy (array_like, shape(N, 2))

Site coordinates in a projected CRS.

required
polylines sequence of array_like, each shape (M, 2)

Trace polylines in the same CRS.

required
units_per_km float

Linear units of the CRS per kilometre. No default.

required

Returns:

Type Description
dict

{"RJB": ndarray (N,)}.

distances

distances(scenario, site_xy, units_per_km, **kwargs)

Distance in kilometres for every published metric, for this scenario.

scenario="point" needs epicentre_xy and depth_km; scenario="fault" needs polylines.

resolve_crs

resolve_crs(crs, *objs)

crs if given, else the first CRS carried by one of objs (or None).

Every input is then checked against the result by as_site_xy and as_polylines, so sites and a trace in different CRSs raise instead of being measured against each other.

as_site_xy

as_site_xy(sites, crs=None)

Site coordinates as a float array of shape (N, 2).

Accepts an (N, 2) array or sequence, a sequence of Shapely points, or a GeoSeries/GeoDataFrame of points (its CRS must be metric). Non-point geometries are refused: pass gdf.centroid or representative_point() explicitly so the choice of point is the caller's.

as_polylines

as_polylines(trace, crs=None)

Fault trace as a list of (M, 2) float arrays.

Accepts one (M, 2) array, a sequence of such arrays, a Shapely LineString/MultiLineString, a sequence of those, or a GeoSeries/ GeoDataFrame of lines (its CRS must be metric).

quakecascade.groundmotion.rupture

Planar rupture geometry and the Joyner-Boore distance.

A rupture is described by its surface trace plus a FaultGeometry (dip, dip direction, upper and lower seismogenic depth) whose values must come from a cited source - there are no default dips. The rupture plane is swept down-dip from each trace segment and projected to the surface; the Joyner-Boore distance RJB is the horizontal distance to that projection, so it is zero for every site above the rupture (the hanging wall).

Rupture-dimension scaling follows Wells, D. L. & Coppersmith, K. J. (1994). New empirical relationships among magnitude, rupture length, rupture width, rupture area, and surface displacement. Bulletin of the Seismological Society of America 84(4), 974-1002. https://doi.org/10.1785/BSSA0840040974

All coordinates are in metres of a projected CRS; when a CRS is passed it is checked with quakecascade.crs.require_metric.

MAX_DIP_AZIMUTH_OFFSET_DEG module-attribute

MAX_DIP_AZIMUTH_OFFSET_DEG = 45.0

Largest angle between the dip azimuth and the normal to the trace's mean strike that is read as a rounded dip direction (an 8-point compass is off by at most 22.5 degrees); beyond it the inputs contradict each other.

WC1994_RUPTURE_WIDTH module-attribute

WC1994_RUPTURE_WIDTH = ...

Wells & Coppersmith (1994), Table 2A, down-dip rupture width: log10(RW [km]) = a + b * M; s is the standard deviation of log10(RW) and magnitude_range the range of the regression data. Keys are the ASB2014 style-of-faulting codes (SS strike-slip, RS reverse, NS normal) plus "ALL" for the all-mechanism regression.

WC1994_SURFACE_RUPTURE_LENGTH module-attribute

WC1994_SURFACE_RUPTURE_LENGTH = ...

Wells & Coppersmith (1994), Table 2A, magnitude from surface rupture length: M = a + b * log10(SRL [km]); s is the standard deviation of M and length_range_km the SRL range of the regression data.

FaultGeometry dataclass

FaultGeometry(
    dip_deg,
    dip_azimuth_deg,
    upper_depth_km,
    lower_depth_km,
    source,
)

Planar rupture parameters for a Joyner-Boore distance.

Parameters:

Name Type Description Default
dip_deg float

Dip of the plane, degrees in (0, 90].

required
dip_azimuth_deg float

Direction the plane dips toward, degrees clockwise from grid north.

required
upper_depth_km float

Depth of the top and bottom of rupture, km, 0 <= upper < lower.

required
lower_depth_km float

Depth of the top and bottom of rupture, km, 0 <= upper < lower.

required
source str

Mandatory, non-empty citation for the four numbers (e.g. a fault database record). There are no defaults.

required

down_dip_width_km property

down_dip_width_km

Down-dip width (lower - upper) / sin(dip), km.

from_wells_coppersmith classmethod

from_wells_coppersmith(
    dip_deg,
    dip_azimuth_deg,
    magnitude,
    mechanism,
    source,
    upper_depth_km=0.0,
)

Geometry whose bottom depth follows the Wells & Coppersmith (1994) width.

lower_depth_km = upper_depth_km + RW(M) * sin(dip). source must cite the dip and dip direction; the width citation is appended. upper_depth_km = 0 (rupture reaching the mapped surface trace) is the geometric default, not a calibrated coefficient.

wells_coppersmith_width_km

wells_coppersmith_width_km(
    magnitude, mechanism, strict=True
)

Down-dip rupture width from moment magnitude, Wells & Coppersmith (1994).

RW = 10 ** (a + b * M) km with the Table 2A coefficients in WC1994_RUPTURE_WIDTH.

Parameters:

Name Type Description Default
magnitude float

Moment magnitude.

required
mechanism ('SS', 'NS', 'RS', 'ALL')

Style of faulting.

"SS"
strict bool

Raise ValueError outside the magnitude range of the regression data; with False the value is returned anyway (extrapolation).

True

wells_coppersmith_magnitude_from_length

wells_coppersmith_magnitude_from_length(
    length_km, mechanism, strict=True
)

Moment magnitude from surface rupture length, Wells & Coppersmith (1994).

M = a + b * log10(SRL) with the Table 2A coefficients in WC1994_SURFACE_RUPTURE_LENGTH.

Parameters:

Name Type Description Default
length_km float

Surface rupture length, km (> 0).

required
mechanism ('SS', 'NS', 'RS', 'ALL')

Style of faulting.

"SS"
strict bool

Raise ValueError outside the SRL range of the regression data.

True

rupture_projection

rupture_projection(trace, geometry, crs=None)

Surface projection of a planar rupture hanging off the trace.

dip_deg is the true dip, measured perpendicular to strike. The whole trace is translated by one vector, perpendicular to its mean strike (the direction from the first to the last vertex of each part, oriented along the longest part and summed) on the side of dip_azimuth_deg, by upper_depth / tan(dip) and lower_depth / tan(dip) (km converted to metres). The parallelogram each segment sweeps is the projection of that piece of the plane; one shared translation leaves no gaps at bends, and the union is returned. A dip azimuth more than MAX_DIP_AZIMUTH_OFFSET_DEG from the mean-strike normal contradicts the trace and raises ValueError.

Parameters:

Name Type Description Default
trace array_like, sequence of arrays, Shapely or GeoPandas lines

Fault trace in metres.

required
geometry FaultGeometry

Plane parameters with their source.

required
crs optional

CRS of trace; must be metric when given.

None

Returns:

Type Description
Geometry or None

Polygon/MultiPolygon (a line for a segment parallel to the dip direction); None for a vertical plane, whose projection is the trace itself.

rjb_km

rjb_km(site_xy_m, trace, geometry=None, crs=None)

Joyner-Boore distance, km, from each site to the rupture projection.

With a FaultGeometry the distance is to the surface projection of the dipping plane (zero on the hanging wall above the rupture). With geometry=None - or a vertical plane - it is the horizontal distance to the trace, which equals RJB only for a vertical rupture.

Parameters:

Name Type Description Default
site_xy_m array_like (N, 2), Shapely points or GeoSeries of points

Sites in metres.

required
trace array_like, sequence of arrays, Shapely or GeoPandas lines

Fault trace in the same metric CRS.

required
geometry FaultGeometry

Plane parameters; None measures to the trace.

None
crs optional

CRS of the coordinates; must be metric when given.

None

Returns:

Type Description
(ndarray, shape(N))

RJB in km; NaN for a site with non-finite coordinates.

describe_distance

describe_distance(geometry)

One sentence saying how rjb_km measured the distance.