|
3 | 3 | from dataclasses import dataclass
|
4 | 4 |
|
5 | 5 | import numpy as np
|
6 |
| -from scipy.stats import truncnorm |
| 6 | +import pandas as pd |
7 | 7 |
|
8 | 8 | from srf_generation.source_parameter_generation.uncertainties import mag_scaling
|
9 | 9 | from srf_generation.source_parameter_generation.uncertainties.distributions import (
|
10 | 10 | truncated_normal as sample_trunc_norm_dist,
|
11 | 11 | )
|
12 | 12 |
|
13 |
| - |
14 |
| -NHM_HEADER = f"""FAULT SOURCES - New Zealand National Seismic Hazard Model 2010 (created {datetime.datetime.now().strftime("%d-%b-%Y")}) |
| 13 | +NHM_HEADER = f"""FAULT SOURCES - (created {datetime.datetime.now().strftime("%d-%b-%Y")}) |
15 | 14 | Row 1: FaultName
|
16 | 15 | Row 2: TectonicType , FaultType
|
17 | 16 | Row 3: LengthMean , LengthSigma (km)
|
@@ -238,3 +237,55 @@ def str2floats(line):
|
238 | 237 | faults[nhm_fault.name] = nhm_fault
|
239 | 238 |
|
240 | 239 | return faults
|
| 240 | + |
| 241 | + |
| 242 | +def load_nhm_df(nhm_ffp, erf_name=None): |
| 243 | + """Creates a standardised pandas dataframe for the |
| 244 | + ruptures in the given erf file. |
| 245 | +
|
| 246 | + Parameters |
| 247 | + ---------- |
| 248 | + nhm_ffp : str |
| 249 | + Path to the ERF file |
| 250 | + erf_name : ERFFileType |
| 251 | + name to identify faults from an ERF |
| 252 | +
|
| 253 | + Returns |
| 254 | + ------- |
| 255 | + DataFrame |
| 256 | + """ |
| 257 | + nhm_infos = load_nhm(nhm_ffp) |
| 258 | + |
| 259 | + erf_suffix = "" |
| 260 | + if erf_name: |
| 261 | + erf_suffix = f"_{erf_name}" |
| 262 | + |
| 263 | + rupture_dict = { |
| 264 | + f"{info.name}{erf_suffix}": |
| 265 | + {"name": info.name, |
| 266 | + "tectonic_type": info.tectonic_type, |
| 267 | + "length": info.length, |
| 268 | + "length_sigma": info.length_sigma, |
| 269 | + "dip": info.dip, |
| 270 | + "dip_sigma": info.dip_sigma, |
| 271 | + "dip_dir": info.dip_dir, |
| 272 | + "rake": info.rake, |
| 273 | + "dbottom": info.dbottom, |
| 274 | + "dbottom_sigma": info.dbottom_sigma, |
| 275 | + "dtop": info.dtop, |
| 276 | + "dtop_min": info.dtop_min, |
| 277 | + "dtop_max": info.dtop_max, |
| 278 | + "slip_rate": info.slip_rate, |
| 279 | + "slip_rate_sigma": info.slip_rate_sigma, |
| 280 | + "coupling_coeff": info.coupling_coeff, |
| 281 | + "coupling_coeff_sigma": info.coupling_coeff_sigma, |
| 282 | + "mw": info.mw, |
| 283 | + "recur_int_median": info.recur_int_median if info.recur_int_median > 0 else float("nan"), |
| 284 | + "exceedance": 1 / info.recur_int_median if info.recur_int_median > 0 else float("nan"), |
| 285 | + } |
| 286 | + for key, info in nhm_infos.items() |
| 287 | + } |
| 288 | + |
| 289 | + return pd.DataFrame.from_dict( |
| 290 | + rupture_dict, orient="index" |
| 291 | + ).sort_index() |
0 commit comments