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
Пример #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
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