Skip to content

Commit

Permalink
Added to_dataframe and calc_vs30 methods to Profile.
Browse files Browse the repository at this point in the history
  • Loading branch information
arkottke committed Aug 28, 2024
1 parent 09add76 commit 6b51ebf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/pystrata/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import matplotlib.pyplot as plt
import numpy as np
import numpy.typing as npt
import pandas as pd
import scipy.constants
import tomli
from scipy.interpolate import interp1d
Expand Down Expand Up @@ -880,6 +881,11 @@ def get_level(cls, model: str, soil_group: str, **kwds: dict[str, float]) -> int
@classmethod
@to_decimal("fines_cont", "plas_index", "water_cont")
def calc_shear_mod(cls, soil_group, **kwds):
"""
Units of MPa
"""
level = cls.get_level("gmax_model", soil_group, **kwds)

if soil_group == "clean_sand_and_gravel":
Expand Down Expand Up @@ -1752,6 +1758,22 @@ def from_dataframe(cls, df, wt_depth=0):
)
return cls(layers, wt_depth)

def to_dataframe(self):
records = []
for layer in self:
st = layer.soil_type
records.append(
(st.name, st.unit_wt, st.damping, layer.thickness, layer.shear_vel)
)

df = pd.DataFrame(
records,
columns=["soil_type", "unit_wt", "damping", "thickness", "shear_vel"],
)
df["depth"] = np.r_[0, df["thickness"].cumsum().iloc[:-1]]

return df

def __iter__(self):
return iter(self.layers)

Expand Down Expand Up @@ -1963,6 +1985,12 @@ def time_average_vel(self, depth):
avg_shear_vel = depth / np.interp(depth, depths, total_travel_times)
return avg_shear_vel

def vs30(self):
"""Compute the Vs30 of the profile."""
tot_time = np.r_[0, np.cumsum(self.thickness / self.initial_shear_vel)[:-1]]
time = np.interp(30, self.depth, tot_time)
return 30 / time

def simplified_rayliegh_vel(self):
"""Simplified Rayliegh velocity of the site.
Expand Down

0 comments on commit 6b51ebf

Please sign in to comment.