NSHM Database Generation
This repository contains a script, schema, and Python package for building and querying a SQLite database of fault geometry and rupture scenario data from the GNS National Seismic Hazard Model (NSHM) 2022.
Domain model
The database describes rupture scenarios: possible earthquakes formed by one or more faults rupturing together. The core hierarchy is
graph TD
R["Rupture scenario"] --> F1["Fault A"]
R --> F2["Fault B"]
F1 --> P1["Fault plane"]
F1 --> P2["Fault plane"]
F2 --> P3["Fault plane"]
-
Rupture scenario — a single possible earthquake from the NSHM logic tree. It has a magnitude, area,length, and (usually) an annual rate of occurrence, and involves one or more faults.
-
Fault — a fault (crustal) or a subdivision of a larger fault surface (subduction interface), belonging to a fault system (
Crustal,Hikurangi, orPuysegur).Faults are grouped under a parent fault: for crustal fault systems, a parent fault is a named fault such as "Wellington: Wairarapa" that is made up of several along-strike segments (each a
faultrow); for the subduction interfaces (Hikurangi, Puysegur), everyfaultrow is a section of the (single) subduction surface and currently maps one-to-one with its ownparent_faultentry, distinguished by NSHM id rather than by name. -
Fault plane — one planar rectangular patch of a fault's surface, defined by the lat/lon of its four corners plus a top and bottom depth. A fault is represented by one or more of these planes (e.g. a bent or multi-segment fault trace), and a rupture's overall geometry is the union of the planes of every fault it involves.
A rupture typically involves many faults, and each fault can participate in many ruptures (a many-to-many relationship), so a fault's geometry is stored once and shared across every rupture scenario that includes it.
Database schema
The hierarchy above is implemented with the following tables (see
nshmdb/schema/schema.sql):
| Table | Represents | Key columns |
|---|---|---|
rupture |
A rupture scenario | rupture_id (PK), fault_system, nshm_id, magnitude, area, len, rate |
rupture_faults |
Join table linking ruptures to the faults they involve | rupture_id (FK → rupture), fault_id (FK → fault) |
fault |
A fault / fault section belonging to a parent fault | fault_id (PK), parent_id (FK → parent_fault), fault_system, nshm_id, rake, tect_type |
fault_plane |
One rectangular patch of a fault's geometry | plane_id (PK), fault_id (FK → fault), corner lat/lons, top_depth, bottom_depth |
parent_fault |
A named fault | parent_id (PK), name |
magnitude_frequency_distribution |
Per-fault magnitude/rate pairs (MFD), used to estimate a fault's activity rate at a given magnitude | fault_id (FK → fault), magnitude, rate |
Relationships:
erDiagram
parent_fault ||--o{ fault : "grouped into"
fault ||--o{ fault_plane : "made up of"
fault ||--o{ magnitude_frequency_distribution : "has"
fault ||--o{ rupture_faults : "appears in"
rupture ||--o{ rupture_faults : "involves"
parent_fault {
int parent_id PK
text name
}
fault {
int fault_id PK
int parent_id FK
int fault_system
int nshm_id
real rake
int tect_type
}
fault_plane {
int plane_id PK
int fault_id FK
real top_left_lat
real top_left_lon
real top_right_lat
real top_right_lon
real bottom_right_lat
real bottom_right_lon
real bottom_left_lat
real bottom_left_lon
real top_depth
real bottom_depth
}
rupture {
int rupture_id PK
int fault_system
int nshm_id
real magnitude
real area
real len
real rate
}
rupture_faults {
int rupture_fault_id PK
int rupture_id FK
int fault_id FK
}
magnitude_frequency_distribution {
int entry_id PK
int fault_id FK
real magnitude
real rate
}
parent_fault → faultis one-to-many: a named fault is made of one or more fault sections.fault → fault_planeis one-to-many: a fault section's surface is triangulated/paneled into one or more rectangular planes.fault ↔ ruptureis many-to-many, resolved throughrupture_faults: a rupture involves multiple faults, and a fault can be part of multiple ruptures.fault → magnitude_frequency_distributionis one-to-many: each fault has its own MFD used (viaNSHMDB.most_likely_fault) to estimate which of its constituent faults a rupture most likely nucleated on.
fault_system, nshm_id, and (for ruptures/faults) their pairing under
UNIQUE(fault_system, nshm_id) tie every row back to the original NSHM
identifiers, so the database can be cross-referenced against the source NSHM
solution.
Obtain the database
You likely don't need to obtain your own database, as they are published on Dropbox at /QuakeCoRE/Public/NSHM with every version release. Simply download that file and use it with the package:
from nshmdb.nshmdb import NSHMDB
db = NSHMDB('nshmdb_v2026.06.1.db') # or whatever the latest version is.
Generate your own database
After installing this package you simply run
nshmdb 1.0.4 nshmdb.db --api-key API_KEY_HERE
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nshmdb-2026.8.3.tar.gz.
File metadata
- Download URL: nshmdb-2026.8.3.tar.gz
- Upload date:
- Size: 200.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fb515ba8c6c8410084a14632faa9339a90082f90d60c6cecd7dfb33adf582f9
|
|
| MD5 |
6da10d1deff52adc1189ce2b284ce3e0
|
|
| BLAKE2b-256 |
300cdbcac49e61d6a4e8f0dd460d3dab376c3978a79f003294e7b47d8b153c11
|
Provenance
The following attestation bundles were made for nshmdb-2026.8.3.tar.gz:
Publisher:
publish-PyPI.yml on ucgmsim/NSHM2022DB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nshmdb-2026.8.3.tar.gz -
Subject digest:
0fb515ba8c6c8410084a14632faa9339a90082f90d60c6cecd7dfb33adf582f9 - Sigstore transparency entry: 2526131414
- Sigstore integration time:
-
Permalink:
ucgmsim/NSHM2022DB@6095d2e27ac8864192864305c533d4621517d51e -
Branch / Tag:
refs/tags/v2026.08.3 - Owner: https://github.com/ucgmsim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-PyPI.yml@6095d2e27ac8864192864305c533d4621517d51e -
Trigger Event:
release
-
Statement type:
File details
Details for the file nshmdb-2026.8.3-py3-none-any.whl.
File metadata
- Download URL: nshmdb-2026.8.3-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f919ecffe74de270534e3c42455de2ce89f8826f48bf27c3dd33ca91821d8a8d
|
|
| MD5 |
138758bafdfbb1eca07aabc6b005315d
|
|
| BLAKE2b-256 |
a6190636161438be7f33ef107f475470981831d303fae2ecd33a20101cffbd7b
|
Provenance
The following attestation bundles were made for nshmdb-2026.8.3-py3-none-any.whl:
Publisher:
publish-PyPI.yml on ucgmsim/NSHM2022DB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nshmdb-2026.8.3-py3-none-any.whl -
Subject digest:
f919ecffe74de270534e3c42455de2ce89f8826f48bf27c3dd33ca91821d8a8d - Sigstore transparency entry: 2526131514
- Sigstore integration time:
-
Permalink:
ucgmsim/NSHM2022DB@6095d2e27ac8864192864305c533d4621517d51e -
Branch / Tag:
refs/tags/v2026.08.3 - Owner: https://github.com/ucgmsim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-PyPI.yml@6095d2e27ac8864192864305c533d4621517d51e -
Trigger Event:
release
-
Statement type: