Coder Social home page Coder Social logo

pyrotd's People

Contributors

arkottke avatar krisvanneste avatar stickler-ci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyrotd's Issues

What is the unit of 'sd'?

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 $g$ (the acceleration of gravity). In other words, the 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 $$Sd = pSa \cdot g \cdot \frac{T^2}{4\pi^2}$$ and there is a huge error between the calculated values by formula and the computed values by 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()

RSN8883_14383980_13849360 AT2 displacement spectra

I figured out that by multiplying sd values calculated by pyrotdlibrary by $g^3$, the error will be reduced significantly.

#%% 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()

RSN8883_14383980_13849360 AT2 displacement spectra

Dependency on numpy version

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:

  • removing the interpolation/method argument, as "linear" was and still is the default value
  • checking for the numpy version, and pass the correct argument, something like:
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...

Positional argument `osc_type` doesn't work (pyrotd 0.5.4)

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.