In [1]:
import matplotlib.pyplot as plt
import numpy as np
import pysra
%matplotlib inline
In [2]:
# Increased figure sizes
plt.rcParams['figure.dpi'] = 120
In [3]:
m = pysra.motion.SourceTheoryRvtMotion(6.0, 30, 'wna')
m.calc_fourier_amps()
In [4]:
profile = pysra.site.Profile([
pysra.site.Layer(
pysra.site.DarendeliSoilType(
18., plas_index=0, ocr=1, stress_mean=100), 10, 400),
pysra.site.Layer(
pysra.site.DarendeliSoilType(
18., plas_index=0, ocr=1, stress_mean=200), 10, 450),
pysra.site.Layer(
pysra.site.DarendeliSoilType(
18., plas_index=0, ocr=1, stress_mean=400), 30, 600),
pysra.site.Layer(
pysra.site.SoilType('Rock', 24., None, 0.01), 0, 1200),
])
In [5]:
calc = pysra.propagation.EquivalentLinearCalculator()
In [6]:
var_thickness = pysra.variation.ToroThicknessVariation()
var_velocity = pysra.variation.ToroVelocityVariation.generic_model(
'USGS C')
var_soiltypes = pysra.variation.SpidVariation(
-0.5, std_mod_reduc=0.15, std_damping=0.30)
In [7]:
freqs = np.logspace(-1, 2, num=500)
outputs = pysra.output.OutputCollection([
pysra.output.ResponseSpectrumOutput(
# Frequency
freqs,
# Location of the output
pysra.output.OutputLocation('outcrop', index=0),
# Damping
0.05),
pysra.output.ResponseSpectrumRatioOutput(
# Frequency
freqs,
# Location in (denominator),
pysra.output.OutputLocation('outcrop', index=-1),
# Location out (numerator)
pysra.output.OutputLocation('outcrop', index=0),
# Damping
0.05),
pysra.output.InitialVelProfile(),
])
In [8]:
count = 100
for p in pysra.variation.iter_varied_profiles(
profile,
count,
var_thickness=var_thickness,
var_velocity=var_velocity,
var_soiltypes=var_soiltypes
):
# Here we auto-descretize the profile for wave propagation purposes
calc(m, p.auto_discretize(), p.location('outcrop', index=-1))
outputs(calc)
In [9]:
for o in outputs[:-1]:
fig, ax = o.plot()
fig;
In [10]:
fig, ax = outputs[-1].plot()
The statistics of the output can be also retrieved and returned as either a dict
or pandas.DataFrame
.
In [11]:
outputs[-1].calc_stats()
Out[11]:
In [12]:
outputs[-1].calc_stats(as_dataframe=True)
Out[12]:
The generic DepthDependToroVelVariation
follows the SPID guidance.
In [13]:
var_velocity_dd = pysra.variation\
.DepthDependToroVelVariation.generic_model('USGS C')
In [14]:
outputs.reset()
count = 100
for p in pysra.variation.iter_varied_profiles(
profile,
count,
var_thickness=var_thickness,
var_velocity=var_velocity_dd,
var_soiltypes=var_soiltypes
):
calc(m, p.auto_discretize(), p.location('outcrop', index=-1))
outputs(calc)
In [15]:
for o in outputs[:-1]:
fig, ax = o.plot()
fig;
In [16]:
fig, ax = outputs[-1].plot()
In [17]:
outputs[-1].calc_stats(as_dataframe=True)
Out[17]:
In [18]:
var_velocity_dd = pysra.variation\
.DepthDependToroVelVariation.generic_model(
'USGS C',
depth=[0, 10, 20],
ln_std=[0.25, 0.15, 0.10]
)
In [19]:
outputs.reset()
count = 100
for p in pysra.variation.iter_varied_profiles(
profile,
count,
var_thickness=var_thickness,
var_velocity=var_velocity_dd,
var_soiltypes=var_soiltypes
):
calc(m, p.auto_discretize(), p.location('outcrop', index=-1))
outputs(calc)
In [20]:
for o in outputs[:-1]:
fig, ax = o.plot()
fig;
In [21]:
fig, ax = outputs[-1].plot()
In [22]:
outputs[-1].calc_stats(as_dataframe=True)
Out[22]:
In [ ]: