3
3
Peak factor models.
4
4
5
5
Published peak factor models, which compute the expected peak ground motion. A
6
- osc_freq = kwds.get("osc_freq", None)
7
- osc_damping = kwds.get("osc_damping", None)
8
- if (osc_freq and osc_damping) and self._use_nonstationarity_factor:
9
- peak_factor *= self.nonstationarity_factor(osc_damping, osc_freq, duration)
10
- specific model may include oscillator duration correction.
6
+ specific model may include non-stationarity adjustments such as a oscillator
7
+ duration correction.
11
8
"""
12
9
13
10
import ctypes
14
11
import itertools
15
12
import pathlib
16
13
from abc import ABC , abstractmethod
14
+ from typing import Any
17
15
18
16
import numba
19
17
import numpy as np
@@ -945,24 +943,22 @@ def _calc_duration_rms(
945
943
return duration
946
944
947
945
948
- def _make_bt_interpolator (region , ref ) :
946
+ def _make_bt_interpolator (region : str , ref : str ) -> LinearNDInterpolator :
949
947
"""Load data from the :cite:t:`boore12` and Boore & Thompson (2015) parameter files.
950
948
951
949
Parameters
952
950
----------
953
951
region : str
954
952
Region for which the parameters were developed. Valid options: 'wna' for Western
955
- North America (active tectonic), or 'cena' for Eastern North America (stable
956
- tectonic).
953
+ North America (active tectonic), or 'cena' for Central and Eastern North America
954
+ (stable tectonic).
957
955
ref : str
958
- Reference document. Either: bt12 or bt15 for Boore & Thompson (2012) or (2015),
959
- respectively.
956
+ Reference document. Either: 'bt12' or 'bt15'.
960
957
961
958
Returns
962
959
-------
963
- interpolator : :class:`scipy.interpolate. LinearNDInterpolator`
960
+ LinearNDInterpolator
964
961
Interpolator for the data.
965
-
966
962
"""
967
963
fpath = pathlib .Path (__file__ ).parent .joinpath (
968
964
"data" , f"{ region } _{ ref } _trms4osc.pars.gz"
@@ -1272,59 +1268,39 @@ def _calc_duration_rms(
1272
1268
1273
1269
1274
1270
class SeifriedEtAl2025 (Calculator ):
1275
- """Seifried et al. (2025) peak factor.
1276
-
1277
-
1278
- Attributes
1279
- ----------
1280
- NAME : str
1281
- Complete reference of the peak calculator
1271
+ """Seifried et al. (2025) peak factor calculator."""
1282
1272
1283
- ABBREV : str
1284
- Abbreviation of the reference
1285
-
1286
- _MIN_ZERO_CROSSINGS : float
1287
- Minimum number of zero crossings.
1288
- """
1273
+ def __init__ (self , use_nonstationarity_factor : bool = True , ** kwds : Any ) -> None :
1274
+ """Initialize SeifriedEtAl2025.
1289
1275
1290
- NAME : str = "Seifried et al. (2025)"
1291
- ABBREV : str = "Sea25"
1292
-
1293
- _MIN_ZERO_CROSSINGS = 0
1294
-
1295
- # Coefficients fit to NGA-W2 subset multiple dampings
1296
- _COEF_A = 0.525
1297
- _COEF_B = 1.686
1298
-
1299
- def __init__ (self , use_nonstationarity_factor : bool = True , ** kwds ):
1300
- """Initialize the class."""
1276
+ Parameters
1277
+ ----------
1278
+ use_nonstationarity_factor : bool, optional
1279
+ If True, the nonstationarity adjustment is applied, by default True.
1280
+ **kwds : Any
1281
+ Additional keyword arguments.
1282
+ """
1301
1283
super ().__init__ (** kwds )
1302
1284
self ._use_nonstationarity_factor = use_nonstationarity_factor
1303
1285
1304
1286
def _calc_peak_factor (
1305
- self , duration : float , sspectrum : SquaredSpectrum , ** kwds
1287
+ self , duration : float , sspectrum : SquaredSpectrum , ** kwds : Any
1306
1288
) -> float :
1307
- """Compute the peak factor.
1289
+ """Compute the peak factor for Seifried et al. (2025) .
1308
1290
1309
1291
Parameters
1310
1292
----------
1311
1293
duration : float
1312
- Duration of the stationary portion of the ground motion [sec].
1313
- Typically defined as the duration between the 5% and 75% normalized Arias
1314
- intensity [sec].
1294
+ Duration of the stationary portion of the ground motion [sec].
1315
1295
sspectrum : SquaredSpectrum
1316
- Instance of `SquaredSpectrum` that defines the frequency content of the
1317
- motion.
1318
- osc_freq : float
1319
- Frequency of the oscillator (Hz).
1320
- osc_damping : float
1321
- Fractional damping of the oscillator (dec). For example, 0.05 for a damping
1322
- ratio of 5%.
1296
+ Instance of `SquaredSpectrum` defining frequency content.
1297
+ **kwds : Any
1298
+ May contain 'osc_freq' and 'osc_damping' parameters if relevant.
1299
+
1323
1300
Returns
1324
1301
-------
1325
- peak_factor : float
1326
- associated peak factor.
1327
-
1302
+ float
1303
+ Computed peak factor.
1328
1304
"""
1329
1305
m0 , m2 = sspectrum .moments (0 , 2 )
1330
1306
@@ -1369,23 +1345,28 @@ def _calc_peak_factor(
1369
1345
return peak_factor
1370
1346
1371
1347
1372
- def get_peak_calculator (method , calc_kwds ) :
1348
+ def get_peak_calculator (method : str , calc_kwds : dict [ str , Any ] | None ) -> Calculator :
1373
1349
"""Select a peak calculator based on a XXDD string.
1374
1350
1375
1351
The format of the string is XX for author initials, and then DD for the last two
1376
- years of the date published.
1352
+ years of the date published (e.g., 'BJ84' for Boore & Joyner 1984) .
1377
1353
1378
1354
Parameters
1379
1355
----------
1380
1356
method : str
1381
- Name of the peak calculation method
1382
- calc_kwds : dict
1383
- Keywords passed to the calculator
1357
+ Name or abbreviation of the peak calculation method.
1358
+ calc_kwds : dict[str, Any] | None
1359
+ Additional keywords passed to the calculator constructor.
1360
+
1384
1361
Returns
1385
1362
-------
1386
- calc : calculator
1387
- :class:`.Calculator`
1363
+ Calculator
1364
+ A matching peak calculator instance.
1388
1365
1366
+ Raises
1367
+ ------
1368
+ NotImplementedError
1369
+ If no matching calculator is found.
1389
1370
"""
1390
1371
calc_kwds = calc_kwds or dict ()
1391
1372
@@ -1410,8 +1391,8 @@ def get_peak_calculator(method, calc_kwds):
1410
1391
raise NotImplementedError ("No calculator for: %s" , method )
1411
1392
1412
1393
1413
- def get_region (region ) :
1414
- """Return the region naming used in this package.
1394
+ def get_region (region : str ) -> str :
1395
+ """Return the internal region naming used in this package.
1415
1396
1416
1397
Parameters
1417
1398
----------
@@ -1420,9 +1401,13 @@ def get_region(region):
1420
1401
1421
1402
Returns
1422
1403
-------
1423
- region : str
1404
+ str
1424
1405
Region either 'cena' or 'wna'.
1425
1406
1407
+ Raises
1408
+ ------
1409
+ NotImplementedError
1410
+ If the region is unknown.
1426
1411
"""
1427
1412
region = region .lower ()
1428
1413
if region in ["cena" , "ena" , "ceus" , "eus" ]:
0 commit comments