Combining Direct Simulation and Surrogate Modelling for Simulation-Consistent Probabilistic Seismic Hazard Analysis
This repository contains the code for reproducing the results from the paper.
Note: It is advised to use a Linux machine. All instructions below assume a Linux OS. If you encounter any problems, please raise an issue on the GitHub repository.
The following libraries must be available:
- GMT version 6.6
-
Clone the repository:
git clone <repository-url>
-
Install the package:
pip install ./post_event_gm_gnn
Most data loading/saving is done relative to the wdata environment variable.
- Create a data directory for this project (e.g.,
base_data_dir) - Add the following to your
.bashrc(or equivalent):export wdata=/path/to/base_data_dir
Download the data file from here and unzip it.
This will create the following directory structure:
base_data_dir
|--- 20251222_CS200_DSSlab_rotd50_empdb.duckdb
|--- 20251222_CS200_DSSlab_rotd50_imdb.duckdb
|--- test_events.npy
├── cs200_hazard
├── other
│ ├── dupuis_moderate_mag
│ ├── dupuis_small_mag
│ └── lee_nz_validation_2022
├── results
├── 0613_1752_cv_baseV5p1_25Epochs_6E6Folds
│ ├── event_mera_site_term
│ └── mera_site_term
├── 0613_2113_full_baseV5p1_10Epochs
│ ├── ds_hazard
│ │ ├── ref_sites
│ │ └── uniform_grid
│ └── test_mera
├── 0613_2142_cv_baseV5p1_locAdjV4_25Epochs_6E6Folds
│ ├── event_mera_site_term
│ └── mera_site_term
├── 0614_0214_full_baseV5p1_locAdjV4_10Epochs
│ ├── ds_hazard
│ │ ├── ref_sites
│ │ └── uniform_grid
│ └── test_mera
├── emp_ds_hazard
│ ├── ref_sites
│ └── uniform_grid
└── loc_models
└── 0929_1130_optimized_siteCond_25Epochs
- 20251222_CS200_DSSlab_rotd50_imdb.duckdb: Primary data resource. Contains all rupture, source, and site information, in addition to the simulation IM values.
- 20251222_CS200_DSSlab_rotd50_empdb.duckdb: Contains IM distribution parameters for the empirical GM logic tree
The results folder contains the following
0613_1752_cv_baseV5p1_25Epochs_6E6Folds- Cross-validation (CV) results for the base surrogate model0613_2142_cv_baseV5p1_locAdjV4_25Epochs_6E6Folds- Cross-validation results for the location-specific surrogate model- Each of these contains:
- One directory per cross-validation run
- A
mera_site_termfolder, which contains the mixed-effects regression results - A
event_mera_site_termfolder, which contains the mixed-effects regression results at the event level - A
val_results.parquetfile, which is a dataframe of the combined validation results
- Each of these contains:
0613_2113_full_baseV5p1_10Epochs- Full base surrogate model0614_0214_full_baseV5p1_locAdjV4_10Epochs- Full location-specific surrogate model- Each of these contains:
test_merafolder, which contains the test dataset mixed-effects regression resultstest_results.parquetfile, which is a dataframe with test dataset resultsds_hazardfolder, which contains the distributed seismicity hazard resultsref_sitesdistributed seismicity hazard at a small set of reference sites (aligned with Cybershake NZ 200m paper)unfiorm_griddistributed seismicity hazard on the uniform grid
- Each of these contains:
emp_ds_hazard- Empirical GM logic tree distributed seismicity hazard resultsloc_models/0929_1130_optimized_siteCond_25Epochs- Pre-trained location-embedding model
The other folder contains the mixed-effects regression results for the Lee et al. (2022) and Dupuis et al. (2025) simulation validation studies.
The cs200_hazard folder contains the fault and distributed seismicity ERF for the 2010 NZ NHM.
Reading Data Files:
.picklefiles: Usepd.read_pickle()from pandas.parquetfiles: Usepd.read_parquet()from pandas.npyfiles: Usenp.load()from numpy.ptfiles: Usetorch.load(filepath, weights_only=False)from PyTorch
Use the ./train_models.sh script for training the models. Note, that the base CV & full models have to be trained first, as these are needed to subsequently train the location-specific models.
A GPU is highly recommended, it may be possible without, but not tested and most likely extremely slow. Modify the number of processes to suit the system used, more processes results in higher memory usage (both main and GPU).
Use the run_cv_post.sh script to compute mixed-effects regression results for the CV runs. For the full models, use run_full_post.sh to compute distributed seismicity hazard results. Both are slow and require large amounts of memory, run times were ~12 hours and ~12-24 hours, respectively, on a system with 16 CPU cores and 64 GB of memory. Number of processes is configured for this system, adjust as needed.
Use the gen_paper_figures.sh script to compute the paper figures.