def create_site_parameters( rrup_file, vs30_file, stations=None, vs30_default=500, max_distance=None ): """Create site parameters""" rrups = read_rrup_file(rrup_file) vs30_values = read_vs30_file(vs30_file) sites = list() if max_distance is None: max_distance = float("inf") if stations is None: stations = list(rrups.keys()) for station in stations: rrup, rjbs, rx, ry = rrups[station] if rrup < max_distance: site = Site() site.name = station if station in vs30_values: site.vs30 = vs30_values[station] else: site.vs30 = vs30_default site.Rrup = rrup site.Rjb = rjbs site.Rx = rx site.Ry = ry sites.append(site) return sites
0.012, 0.018, 0.03, 0.05, 0.07, 0.1, 0.16, 0.2, 0.25, 0.3, 0.4, 0.5, 0.75, 1, 1.5, 2, 3, 4, 5, 6.5, 8, 10, -1 ] mags = [4.8, 5, 6.5, 9.2] rrups = np.array([[30, 80], [29, 30], [12, 103], [999, 20], [8, 18], [23, 68]]).T regions = [0, 2, 3, 6] ld = np.array([[29, 30, -120], [0, 45, 25]]).T vs30s = np.array([[67, 485, 2504, 185], [0, 0, 1, 1]]).T z10 = [None, 3, 243] answers = np.fromfile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ask2014.f32'), dtype=np.float32) site = Site() fault = Fault() def test_run(): a = 0 for p in periods: for m in mags: fault.Mw = m for g in ld: fault.rake = g[0] fault.dip = g[1] for r in rrups: site.Rrup = r[0] site.Rjb = r[1] site.Rx = r[2]
from empirical.util.empirical_factory import compute_gmm from empirical.util.classdef import Site, Fault, GMM RRUPS = [10, 70, 200] CB_M = [4.0, 5.4, 7.8] CB_IMS = ["CAV", "AI"] TEST_PARAMS = [(rrup, mag, im) for rrup in RRUPS for mag in CB_M for im in CB_IMS] FAULT = Fault() FAULT.ztor = 0 FAULT.rake = 180 FAULT.dip = 45 SITE = Site() SITE.Rjb = 10 SITE.vs30 = 500 SITE.Rx = -1 SITE.Rtvz = 50 SITE.z2p5 = 0.9186718412435146 @pytest.mark.parametrize("test_rrup, test_mag, test_im", TEST_PARAMS) def test_cb_2012(set_up, test_rrup, test_mag, test_im): SITE.Rrup = test_rrup FAULT.Mw = test_mag test_results = compute_gmm(FAULT, SITE, GMM.CB_12, test_im) with open( os.path.join(
from empirical.test.test_common_setup import set_up from empirical.util import empirical_factory from empirical.util.classdef import Site, Fault, GMM IM = "pSA" RRUPS = [10, 70, 200] PERIODS = [0, 0.01, 0.40370172586, 0.5, 3.0, 8.6974900] FAULT = Fault() FAULT.Mw = 10.5 FAULT.ztor = 0 FAULT.rake = 180 FAULT.dip = 45 SITE = Site() SITE.Rjb = 10 SITE.vs30 = 500 SITE.Rx = -1 SITE.Rtvz = 50 @pytest.mark.parametrize("test_rrup", RRUPS) def test_Bradley_2013_Sa(set_up, test_rrup): SITE.Rrup = test_rrup test_results = empirical_factory.compute_gmm(FAULT, SITE, GMM.Br_10, IM, PERIODS) with open( os.path.join( set_up, "output",
IM = "pSA" TECT_TYPES = [ TectType.SUBDUCTION_SLAB, TectType.SUBDUCTION_INTERFACE, TectType.ACTIVE_SHALLOW, ] SITE_CLASSES = [ SiteClass.SOFTSOIL, SiteClass.MEDIUMSOIL, SiteClass.HARDSOIL, SiteClass.ROCK, SiteClass.HARDROCK, ] SITE = Site() FAULT = Fault() FAULT.Mw = 7.2 FAULT.faultstyle = "interface" FAULT.hdepth = 0 FAULT.ztor = 0 FAULT.rake = 0 FAULT.dip = 0 periods = [0, 0.01, 0.5, 3] rrups = [10, 70, 200] hdepths = [0, 10] def test_zhao_2006(set_up):
df = pd.DataFrame.from_dict(results).T df.columns = ["total", "tau", "phi"] ax = df[["tau", "phi"]].plot() ax.set_xscale("log") ax.set_xlabel("Period (sec)") ax.set_ylabel("Std Dev (LN units)") fig = ax.get_figure() fig.savefig("plots/std.png") ### # Magnitude scaling for T=3 sec for intraslab earthquakes. (Rrup=75 km, VS30=760 m/s, ZTOR=50 km) ### site = Site() site.vs30 = 760 site.Rrup = 75 fault = Fault() fault.ztor = 50 fault.tect_type = TectType.SUBDUCTION_SLAB MAG_RANGE = np.append(np.arange(5, 8.5, 0.1), 8.5) results = {} for Mw in MAG_RANGE: fault.Mw = Mw results[Mw] = a18.Abrahamson_2018(site, fault, "pSA", [3.0])[0][0] df = pd.DataFrame.from_dict(results, orient="index", columns=["pSA_3s"]) ax = df.plot() ax.set_yscale("log") ax.set_xlabel("Magnitude")
""" Plots of models over changes in parameters. Creates plots to be joined by plots_join.sh into PDFs. """ import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from empirical.util.classdef import Site, Fault, TectType, GMM from empirical.util.empirical_factory import compute_gmm from openquake.hazardlib import gsim site = Site() fault = Fault() # IMs to loop through for magnitude and rrup scaling plots ims = ["PGA", "PGV", 0.1, 0.5, 0.75, 1, 3, 5] # rrup scaling plots fixed magnitudes mws = [8, 8.25, 8.5, 8.75, 9, 9.2] # magnitude scaling plots fixed rrups rrs = [25, 50, 75, 100, 300, 600] # set of subduction interface models gmms_if = { gsim.parker_2020.ParkerEtAl2020SInter: ( "Parker 2020", TectType.SUBDUCTION_INTERFACE, ),
RRUPS = [10, 70, 200] AS_M = [5, 6.25, 7.5] AS_IMS = ["Ds575", "Ds595", "Ds2080"] TEST_PARAMS = [(rrup, mag, im) for rrup in RRUPS for mag in AS_M for im in AS_IMS] FAULT = Fault() FAULT.faultstyle = "SHALLOWCRUSTAL" FAULT.ztor = 0 FAULT.rake = 180 FAULT.dip = 45 SITE = Site() SITE.Rjb = 10 SITE.vs30 = 500 SITE.V30measured = None SITE.Rx = -1 SITE.Rtvz = 50 SITE.z2p5 = 0.9186718412435146 @pytest.mark.parametrize("test_rrup, test_mag, test_im", TEST_PARAMS) def test_as_2016(set_up, test_rrup, test_mag, test_im): FAULT.Mw = test_mag SITE.Rrup = test_rrup test_results = compute_gmm(FAULT, SITE, GMM.AS_16, test_im) with open(