arkottke / pyrotd Goto Github PK
View Code? Open in Web Editor NEWPython scripts to compute the rotated response spectrum.
License: MIT License
Python scripts to compute the rotated response spectrum.
License: MIT License
Hello everyone,
I found that the (pseudo-)velocity values (psv
, or sv
) calculated by the pyrotd.calc_spec_accels(time_step, accel_ts, osc_freqs, osc_damping=0.05, max_freq_ratio=5, osc_type='psv')
function must be multiplied by psv
values are in units of g-s
.
I obtained the spectral displacement (sd
) of a record by the pyrotd.calc_spec_accels(time_step, accel_ts, osc_freqs, osc_damping=0.05, max_freq_ratio=5, osc_type='sd')
function in the following script, but I can't figure out what the unit of these values is. I calculated the spectral displacement (sd
) with pseudo-spectral acceleration pyrotd
library. There is a plot to illustrate of this huge error.
import numpy as np
import matplotlib.pyplot as plt
import pyrotd
#%% system of units
m = 1.0
s = 1.0
kg = 1.0
N = kg*m/s/s
g = 9.80665*m/s/s
#%% read record
record = 'RSN8883_14383980_13849360.AT2'
record_content = open(record, mode='r').readlines()
# Flag indicating dt is found and that ground motion
# values should be read -- ASSUMES dt is on last line
# of header!!!
flag = 0
record_samples = []
for line in record_content:
if line == '\n':
# Blank line --> do nothing
continue
elif flag == 1:
words = line.split()
for word in words:
record_samples.append(float(word))
else:
words = line.split()
if words[0] == 'NPTS=':
record_NPTS = words[1]
record_DT = float(words[3])
flag = 1
#%% compute spectral parameteres
f = np.logspace(-1, 2, 91)
T = 1/f
xi = 0.05
pyrotd_pSa = pyrotd.calc_spec_accels(record_DT, record_samples, f, xi, max_freq_ratio=5, osc_type='psa')
pyrotd_Sd = pyrotd.calc_spec_accels(record_DT, record_samples, f, xi, max_freq_ratio=5, osc_type='sd')
formulated_Sd = []
for index, psa in enumerate(pyrotd_pSa.spec_accel):
formulated_Sd.append( psa*g * (T[index]**2) / (2 / np.pi)**2 )
formulated_Sd = np.asarray(formulated_Sd)
#%% plot
fig, axs= plt.subplots(layout='constrained')
fig.suptitle('Displacement spectra of ' + record)
axs.plot(T, pyrotd_Sd.spec_accel, label='Sd')
axs.plot(T, formulated_Sd, label=r'Sd = $pSa \cdot g \cdot \frac{T^2}{4\pi^2}$')
axs.set_xlabel('Period, s')
axs.set_ylabel('Spectral displacement')
axs.legend()
plt.show()
I figured out that by multiplying sd
values calculated by pyrotd
library by
#%% plot
fig, axs= plt.subplots(layout='constrained')
fig.suptitle('Displacement spectra of ' + record)
axs.plot(T, pyrotd_Sd.spec_accel, label='$Sd$')
axs.plot(T, pyrotd_Sd.spec_accel*(g**3), label='$Sd \cdot g^3$')
axs.plot(T, formulated_Sd, label=r'$Sd = pSa \cdot g \cdot \frac{T^2}{4\pi^2}$')
axs.set_xlabel('Period, s')
axs.set_ylabel('Spectral displacement')
axs.legend()
plt.show()
init.py at /usr/lib/python2.7/site-packages/pyrotd/ is not compatible with python 2.7.
What kind of changes should be done?
Dear Albert,
In your recent commit "Add optimized approach", you replaced the "interpolation" argument of the numpy percentile function with the new "method" argument, which was introduced in numpy 1.22.0. Would you consider making pyrotd independent of the numpy version, by either:
if [int(val) for val in np.__version__.split('.')] < [1, 22, 0]:
p_peak_resps = np.percentile(rotated.peak_resp, percentiles, interpolation="linear")
else:
p_peak_resps = np.percentile(rotated.peak_resp, percentiles, method="linear")
Unfortunately, I depend on a slightly older numpy version (1.20.2) in my environment...
Hello everyone,
When I use the positional argument obs_type
with the calc_spec_accels()
function, it gives an error.
script:
import numpy as np
import pyrotd
#%% read record
record = 'RSN8883_14383980_13849360.AT2'
record_content = open(record, mode='r').readlines()
# Flag indicating dt is found and that ground motion
# values should be read -- ASSUMES dt is on last line
# of header!!!
flag = 0
record_samples = []
for line in record_content:
if line == '\n':
# Blank line --> do nothing
continue
elif flag == 1:
words = line.split()
for word in words:
record_samples.append(float(word))
else:
words = line.split()
if words[0] == 'NPTS=':
record_NPTS = words[1]
record_DT = float(words[3])
flag = 1
#%% compute spectral acceleration
f = np.logspace(-1, 2, 91)
xi = 0.05
spec_accel = pyrotd.calc_spec_accels(record_DT, record_samples, f, xi, 5, 'sa').spec_accel
error:
TypeError: calc_spec_accels() takes from 3 to 5 positional arguments but 6 were given
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.