pyrvt.tools¶
Tools for reading/writing of files and performing operations.
- pyrvt.tools.get_fpaths(pat)[source]
Iterate over file paths.
- pyrvt.tools.read_events(fpath, response_type)[source]
Read data from the file an Excel work book.
- Parameters:
fpath (str or Path) – Filename of the input file.
response_type (str) – Type of response. Valid options are: ‘psa’ for psuedo-spectral acceleration, or ‘fa’ for Fourier amplitude.
- Returns:
ext (str) – Extension of input file
reference (
numpy.ndarray) – Reference of the response. This is either period (sec) for response_type ‘psa’ or frequency (Hz) for response_type ‘fa’events (List[dict]) – List of events read from the file. See
Noteincalc_compatible_spectra()for more information on structure of the dictionaries.
- Return type:
- pyrvt.tools.write_events(fname, reference, reference_label, response_type, response_label, events)[source]
Write the events to a file.
- Parameters:
fname (str) – Save the events to this file. The directory is created if needed.
reference (array_like) – Periods of the oscillator response shared across all events.
reference_label (str) – Label of the reference (e.g., ‘Frequency (Hz)’).
response_type (str) – Type of response. Valid options: psa for pseudo-spectral accleration, or fa for Fourier amplitude.
response_label (str) – Label of the response type (e.g., ‘Fourier Ampl. (g/sec)’)
events (List[dict]) – Events to write to file. See
Noteincalc_compatible_spectra()for more information.
- Raises:
NotImplementedError: – If extension is not supported
- pyrvt.tools.calc_compatible_spectra(method, periods, events, damping=0.05)[source]
Compute the response spectrum compatible motions.
- Parameters:
method (str) – RVT peak factor method, see
get_peak_calculator().periods (array_like) – Periods of the oscillator response shared across all events.
events (List[dict]) – All events to consider. See
Note.damping (float, optional) – Fractional damping of the oscillator (decimal). Default value of 0.05 for a damping ratio of 5%.
- Returns:
numpy.ndarray– Frequency of the computed Fourier amplitude spectra.dicts – Modified events
- Return type:
Note
Each event dictionary should have the following keys:
psa :
numpy.ndarray– pseudo-spectral accelerations. This is the target for theCompatibleRvtMotion.duration : float, optional – duration of the ground motion
magnitude : float, optional – earthquake magnitude
distance : float, optional – earthquake distance (km)
region : str, optional – earthquake source region, see
get_region()If no duration is provided one is estimated from the magnitude, distance, and region.
The events dictionary is modified by this function and adds the following keys:
duration : float – duration of the ground motion if one was not specified
fa :
numpy.ndarray– Fourier amplitude spectra in units of g*secpsa_calc :
numpy.ndarray– Pseudo-spectral acceleration calculated from fa. This will differ slightly from psa_target.
- pyrvt.tools.operation_psa2fa(src, dst, damping, method='LP99', fixed_spacing=True, verbose=True)[source]
Compute the acceleration response spectrum from a Fourier amplitude spectrum.
- Parameters:
src (str) – Source for the pseudo-spectral accelerations (PSA). This can be a filename or pattern used in
glob.glob().dst (str) – Destination directory for the output PSA. The directory is created if it does not exist.
damping (float) – Fractional damping of the oscillator ( decimal).
method (str) – RVT peak factor method, see
get_peak_calculator().fixed_spacing (bool, optional) – If True, then the periods are interpolated to 301 points equally space in log-space from 0.01 to 10.
verbose (bool, optional) – Print status of calculation.
- pyrvt.tools.operation_fa2psa(src, dst, damping, method='LP99', fixed_spacing=True, verbose=True)[source]
Compute the Fourier amplitude spectrum from a accel. response spectrum.
- Parameters:
src (str) – Source for the Fourier amplitudes. This can be a filename or pattern used in
glob.glob().dst (str) – Destination directory for the output PSA. The directory is created if it does not exist.
damping (float) – Fractional damping of the oscillator (decimal).
method (str) – RVT peak factor method, see
get_peak_calculator().fixed_spacing (bool, optional) – If True, then the periods are interpolated to 301 points equally space in log-space from 0.01 to 10.
verbose (bool)