Example 1ΒΆ

Calculation of response spectrum.

[1]:
import os
import re

import matplotlib.pyplot as plt
import numpy as np
import pyrotd

%matplotlib inline

plt.rcParams['figure.dpi'] = 120

Create a function for loading AT2 formatted time series.

[2]:
def load_at2(fpath):
    with open(fpath) as fp:
        for _ in range(3):
            next(fp)
        line = next(fp)
        time_step = float(line[17:25])
        accels = np.array([p for l in fp for p in l.split()]).astype(float)
    return time_step, accels

Load the a pair of rotated time series in the PEER AT2 format.

[3]:
time_step, accels = load_at2(os.path.join('data', 'RSN8883_14383980_13849360.AT2'))

Compute the response spectrum.

[4]:
osc_damping = 0.05
osc_freqs = np.logspace(-1, 2, 91)

osc_resps = pyrotd.calc_spec_accels(
        time_step, accels, osc_freqs, osc_damping
)
osc_resps
[4]:
rec.array([(  0.1       , 0.0009345 ), (  0.10797752, 0.00108484),
           (  0.11659144, 0.00126233), (  0.12589254, 0.00146964),
           (  0.13593564, 0.00171637), (  0.14677993, 0.00201082),
           (  0.15848932, 0.00236372), (  0.17113283, 0.00279168),
           (  0.18478498, 0.00331696), (  0.19952623, 0.00396652),
           (  0.21544347, 0.00476789), (  0.23263051, 0.00575908),
           (  0.25118864, 0.00697773), (  0.27122726, 0.008462  ),
           (  0.29286446, 0.01025697), (  0.31622777, 0.01237759),
           (  0.34145489, 0.01481373), (  0.36869451, 0.01754949),
           (  0.39810717, 0.02050147), (  0.42986623, 0.02560459),
           (  0.46415888, 0.03140112), (  0.50118723, 0.03731899),
           (  0.54116953, 0.04454655), (  0.58434141, 0.05528976),
           (  0.63095734, 0.06380522), (  0.68129207, 0.07407264),
           (  0.73564225, 0.08885869), (  0.79432823, 0.10246906),
           (  0.8576959 , 0.111473  ), (  0.92611873, 0.12389606),
           (  1.        , 0.13029917), (  1.07977516, 0.13425335),
           (  1.1659144 , 0.1489063 ), (  1.25892541, 0.16922334),
           (  1.35935639, 0.18366743), (  1.46779927, 0.18223303),
           (  1.58489319, 0.17718011), (  1.7113283 , 0.20293084),
           (  1.8478498 , 0.22946906), (  1.99526231, 0.25840457),
           (  2.15443469, 0.28041289), (  2.32630507, 0.28744955),
           (  2.51188643, 0.28161458), (  2.71227258, 0.37499008),
           (  2.92864456, 0.47013053), (  3.16227766, 0.50369823),
           (  3.41454887, 0.51334063), (  3.68694506, 0.44439571),
           (  3.98107171, 0.35442258), (  4.29866235, 0.34306065),
           (  4.64158883, 0.39361207), (  5.01187234, 0.43577303),
           (  5.41169527, 0.50623004), (  5.84341413, 0.52815695),
           (  6.30957344, 0.51351521), (  6.81292069, 0.53447835),
           (  7.35642254, 0.58632442), (  7.94328235, 0.51347977),
           (  8.57695899, 0.38217872), (  9.26118728, 0.36277937),
           ( 10.        , 0.33936343), ( 10.79775162, 0.26055472),
           ( 11.65914401, 0.27987174), ( 12.58925412, 0.24911399),
           ( 13.59356391, 0.26093515), ( 14.67799268, 0.2515135 ),
           ( 15.84893192, 0.23061294), ( 17.11328304, 0.20650933),
           ( 18.47849797, 0.19705398), ( 19.95262315, 0.19810946),
           ( 21.5443469 , 0.19366632), ( 23.26305067, 0.18641327),
           ( 25.11886432, 0.19661305), ( 27.12272579, 0.19982706),
           ( 29.28644565, 0.19252452), ( 31.6227766 , 0.17116262),
           ( 34.14548874, 0.16631156), ( 36.86945065, 0.16513254),
           ( 39.81071706, 0.16454988), ( 42.98662347, 0.16194019),
           ( 46.41588834, 0.16047794), ( 50.11872336, 0.16303693),
           ( 54.11695265, 0.16333006), ( 58.43414134, 0.16299025),
           ( 63.09573445, 0.16287202), ( 68.12920691, 0.16236735),
           ( 73.56422545, 0.16074798), ( 79.43282347, 0.16041571),
           ( 85.76958986, 0.16080144), ( 92.61187281, 0.16072895),
           (100.        , 0.16052204)],
          dtype=[('osc_freq', '<f8'), ('spec_accel', '<f8')])

Plot the response spectrum in log-log and log-linear space.

[5]:
fig, axes = plt.subplots(
    ncols=2, figsize=(8, 4), subplot_kw={'xscale': 'log'},
    sharey=False, sharex=True
)

for ax, yscale in zip(axes, ['log', 'linear']):
    ax.plot(osc_resps.osc_freq, osc_resps.spec_accel)
    ax.set_yscale(yscale)
    ax.grid()

axes[0].set_ylabel('5%-Damped Spectral Accel.')
plt.setp(axes, xlabel='Frequency (Hz)')

fig.tight_layout();
../_images/examples_example-1_9_0.png