<jupyter_start><jupyter_text>Example 1Calculation of response spectrum.<jupyter_code>import os
import re

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

%matplotlib inline

plt.rcParams['figure.dpi'] = 120<jupyter_output><empty_output><jupyter_text>Create a function for loading AT2 formatted time series.<jupyter_code>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<jupyter_output><empty_output><jupyter_text>Load the a pair of rotated time series in the PEER AT2 format.<jupyter_code>time_step, accels = load_at2(os.path.join('data', 'RSN8883_14383980_13849360.AT2'))<jupyter_output><empty_output><jupyter_text>Compute the response spectrum.<jupyter_code>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<jupyter_output><empty_output><jupyter_text>Plot the response spectrum in log-log and log-linear space.<jupyter_code>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();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12276214833759591, 'fraction_numerical': 0.029411764705882353, 'mean_word_length': 5.1857707509881426, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '105905', 'license': 'MIT', 'n_tokens_mistral': 634, 'n_tokens_neox': 598, 'n_words': 121, 'path': 'examples/example-1.ipynb', 'repo_name': 'ROB-Seismology/pyrotd', 'size': '1564'}