pyrvt icon indicating copy to clipboard operation
pyrvt copied to clipboard

Inconsistent keys used in BooreThompson class (pyrvt version 0.7.2)

Open ahnielsen opened this issue 3 years ago • 0 comments

The event keys expected by function pyrvt.tools._calc_fa are 'magnitude', 'distance' and 'region' (from tools.py, line 141):

event_keys = ['magnitude', 'distance', 'region']

These keys become parameters when the BooreThompson class is initialized (peak_calculators.py, line 1040). However, the parameters expected by the BooreThompson class (and its two subclasses) are 'mag', 'dist' and 'region'. This inconsistency seems to generate the following error:

  File "C:\ProgramData\Anaconda3\lib\site-packages\pyrvt\tools.py", line 201, in calc_compatible_spectra
    results = pool.map(

  File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()

  File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 771, in get
    raise self._value

TypeError: __init__() missing 2 required positional arguments: 'mag' and 'dist'

The following script should replicate the error:

import pyrvt
import numpy as np

if __name__ == '__main__':
	e = {}
	# Dummy spectral accelerations
	e['psa'] = np.array([0.1, 0.5, 0.7, 1.0, 0.8, 0.6, 0.6])
	# Dummy periods
	T = np.array([100, 2, 0.67, 0.2, 0.125, 0.1, 0.01])
	e['magnitude'] = 6
	e['distance'] = 30
	e['region'] = 'cena'
	e['duration'] = 10
	freqs = pyrvt.tools.calc_compatible_spectra('BT15', T, [e], damping=0.05)

ahnielsen avatar Jul 23 '21 10:07 ahnielsen