예제 #1
0
import os
import pickle
import pytest

from empirical.test.test_common_setup import set_up
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
예제 #2
0
    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]
                    site.Ry = r[3]
예제 #3
0
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):
    set_up = Path(set_up)
    expected_results = pd.read_csv(set_up / "output" / "zhao_output_21p8.csv")
예제 #4
0
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")
ax.set_ylabel("pSA (g)")
ax.set_ylim(0.0001, 1)
ax.grid(True, "both", linestyle="-", color="lightgray")
def create_fault_parameters(srf_info):
    """Create fault parameters"""
    fault = Fault()
    f = h5py.File(srf_info, "r")
    attrs = f.attrs
    dip = attrs["dip"]
    if np.max(dip) == np.min(dip):
        fault.dip = np.min(dip)
    else:
        print("unexpected dip value")
        exit()
    fault.Mw = np.max(attrs["mag"])
    rake = attrs["rake"]
    if np.max(rake) == np.min(rake):
        fault.rake = np.min(rake)
    else:
        print("unexpected rake value")
        exit()
    fault.Mw = attrs["mag"]
    if "dtop" in attrs:
        fault.ztor = np.min(attrs["dtop"])
    else:
        fault.ztor = attrs["hdepth"]
    if "dbottom" in attrs:
        fault.zbot = np.min(attrs["dbottom"])
    else:
        fault.zbot = attrs["hdepth"]
    if "tect_type" in attrs:
        try:
            fault.tect_type = TectType[
                attrs["tect_type"]
            ]  # ok if attrs['tect_type'] is str
        except KeyError:  # bytes
            fault.tect_type = TectType[attrs["tect_type"].decode("utf-8")]
    else:
        print("tect_type not found assuming 'ACTIVE_SHALLOW'")
        fault.tect_type = TectType.ACTIVE_SHALLOW
    fault.hdepth = attrs["hdepth"]
    if "width" in attrs:
        fault.width = np.max(attrs["width"])
    else:
        fault.width = 0
    return fault
예제 #6
0
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,
    ),
    gsim.phung_2020.PhungEtAl2020SInter:
import pickle
import pytest

from empirical.test.test_common_setup import set_up
from empirical.util.empirical_factory import compute_gmm
from empirical.util.classdef import Site, Fault, GMM

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)