rsqsim_api.catalogue.nshm_utilities
Utilities for reading and processing New Zealand NSHM inversion results.
Provides functions for computing overall rupture strike and resolved
length from multi-segment traces, and the NshmInversion class
for loading OpenSHA fault-system solution directories.
Classes
Reader for an OpenSHA fault-system inversion solution directory. |
Functions
|
Compute the length-weighted mean strike of a multi-segment rupture. |
Compute the resolved length of a rupture along its mean strike direction. |
Module Contents
- rsqsim_api.catalogue.nshm_utilities.overall_strike(rup)[source]
Compute the length-weighted mean strike of a multi-segment rupture.
- Parameters:
rup (shapely.geometry.MultiLineString) – Rupture trace composed of one or more line segments.
- Returns:
Weighted circular mean strike in degrees (0–180 convention as returned by
calculate_strike()).- Return type:
float
- rsqsim_api.catalogue.nshm_utilities.overall_strike_resolved_length(rup)[source]
Compute the resolved length of a rupture along its mean strike direction.
Projects all rupture vertices onto the overall strike vector and returns the range (max minus min) of those projections.
- Parameters:
rup (shapely.geometry.MultiLineString or LineString) – Rupture trace. A single
LineStringis automatically wrapped in aMultiLineString.- Returns:
Resolved rupture length in the same units as the input geometry (metres for NZTM).
- Return type:
float
- class rsqsim_api.catalogue.nshm_utilities.NshmInversion[source]
Reader for an OpenSHA fault-system inversion solution directory.
Loads fault sections, rupture rates, properties, connectivity indices, and average slips from an NSHM inversion output directory in the standard OpenSHA CSV/GeoJSON layout.
- fault_sections[source]
GeoDataFrame of fault-section geometries (EPSG:2193).
- Type:
geopandas.GeoDataFrame or None
- properties[source]
Rupture properties (area, length, magnitude) for non-zero-rate ruptures.
- Type:
pandas.DataFrame or None
- indices[source]
Mapping of rupture ID to array of participating fault-section indices.
- Type:
dict or None
- read_indices(indices_csv)[source]
Read the rupture–section connectivity index file.
Parses a CSV where each row lists a rupture ID, the number of sections, and the section indices. Populates
indicesandnum_sections.- Parameters:
indices_csv (str) – Path to
ruptures/indices.csvinside the solution directory.- Raises:
AssertionError – If
rupture_idshas not been set, or if the file does not exist.
- read_nshm_inversion(directory)[source]
Load an NSHM inversion solution from a directory.
Reads rates, fault sections, properties, connectivity indices, and average slips. Only ruptures with a positive annual rate are retained.
- Parameters:
directory (str) – Path to the inversion solution directory, which must contain:
solution/rates.csv,ruptures/fault_sections.geojson,ruptures/properties.csv,ruptures/indices.csv, andruptures/average_slips.csv.
- get_rupture_geometry(rupture_index)[source]
Return the unary union geometry of all sections for a rupture.
- Parameters:
rupture_index (int) – Rupture ID from
rupture_ids.- Returns:
Union of all fault-section geometries participating in the specified rupture.
- Return type:
shapely.geometry.base.BaseGeometry
- ruptures_to_gdf()[source]
Build a GeoDataFrame of all non-zero-rate ruptures.
For each rupture, computes the unary-union geometry of its sections, the resolved length along the mean strike, and assembles rate, area, length, magnitude, and average slip.
- Returns:
GeoDataFrame (EPSG:2193) with one row per rupture and columns
["rate", "area", "length", "mw", "average_slip", "geometry", "resolved_length"].resolved_lengthis in km.- Return type:
geopandas.GeoDataFrame