def _make_source(self, mfd, aspect_ratio, profiles=None,
                     floating_x_step=0.5, floating_y_step=0.5):
        """
        Utility method for creating quickly fault instances
        :param mfd:
            An instance of :class:`openquake.hazardlib.scalerel.base.`
        :param aspect_ratio:
            The rupture aspect ratio
        :param profiles:
            A list of profiles used to build the fault surface
        """

        # Set the fault source parameter
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 2.5
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        tom = self.TOM
        if profiles is None:
            profiles = [Line([Point(0.0, 0.0, 0.0), Point(0.0, 0.01, 15.0)]),
                        Line([Point(0.3, 0.0, 0.0), Point(0.3, 0.01, 15.0)])]

        # Create the source instance
        kfs = KiteFaultSource(source_id, name, trt, mfd, rupture_mesh_spacing,
                              magnitude_scaling_relationship,
                              rupture_aspect_ratio, tom, profiles, rake,
                              floating_x_step=floating_x_step,
                              floating_y_step=floating_y_step)

        # Check we can create a pickled version of this object
        assert_pickleable(kfs)
        return kfs
 def test(self):
     sitecol = SiteCollection([Site(Point(-65.13490, 0.0),
                               vs30=760., z1pt0=48.0, z2pt5=0.607,
                               vs30measured=True)])
     mfd = ArbitraryMFD([6.0], [0.01604252])
     trace = Line([Point(-65.0000, -0.11240), Point(-65.000, 0.11240)])
     # 1.0 km Mesh Spacing
     mesh_spacing = 1.0
     msr = PeerMSR()
     sources = [SimpleFaultSource("001", "PEER Fault Set 2.5",
                                  "Active Shallow Crust", mfd,
                                  mesh_spacing,  msr, 2.0, PoissonTOM(1.0),
                                  0.0, 12., trace, 90., 0.)]
     imtls = {"PGA": [0.001, 0.01, 0.05, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0,
                      1.25, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0]}
     gmpe = ChiouYoungs2014PEER()
     gmpe.mixture_model = {"factors": [0.8, 1.2], "weights": [0.5, 0.5]}
     hcm = calc_hazard_curves(sources, sitecol, imtls,
                              {"Active Shallow Crust": gmpe})
     # Match against the benchmark is not exact - but differences in the
     # log space should be on the order of less than 0.04%
     expected = numpy.array([-4.140470001, -4.140913368, -4.259457496,
                             -4.724733842, -5.900747959, -7.734816415,
                             -9.019329629, -10.03864778, -10.90333404,
                             -11.83885783, -12.65826442, -14.05429951,
                             -15.22535996, -16.23988897, -17.94685518,
                             -19.36079032, -20.57460101, -21.64201335])
     expected = numpy.around(expected, 5)
     hcm_lnpga = numpy.around(numpy.log(hcm["PGA"].flatten()), 5)
     perc_diff = 100.0 * ((hcm_lnpga / expected) - 1.0)
     numpy.testing.assert_allclose(perc_diff, numpy.zeros(len(perc_diff)),
                                   atol=0.04)
    def _make_source(self, mfd, aspect_ratio, fault_trace=None, dip=45):
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 1
        upper_seismogenic_depth = 0
        lower_seismogenic_depth = 4.2426406871192848
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        tom = self.TOM
        if fault_trace is None:
            fault_trace = Line([
                Point(0.0, 0.0),
                Point(0.0, 0.0359728811758),
                Point(0.0190775080917, 0.0550503815181),
                Point(0.03974514139, 0.0723925718855)
            ])

        sfs = SimpleFaultSource(
            source_id, name, trt, mfd, rupture_mesh_spacing,
            magnitude_scaling_relationship, rupture_aspect_ratio, tom,
            upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip,
            rake)
        assert_pickleable(sfs)
        return sfs
Beispiel #4
0
def _setup_fault_source():
    """
    Builds a fault source using the PEER Bending Fault case.
    """
    point_order_dipping_east = [
        Point(-64.78365, -0.45236),
        Point(-64.80164, -0.45236),
        Point(-64.90498, -0.36564),
        Point(-65.0000, -0.16188),
        Point(-65.0000, 0.0000)
    ]
    trace_dip_east = Line(point_order_dipping_east)
    fault_surface1 = SimpleFaultSurface.from_fault_data(
        trace_dip_east, 0.0, 12.0, 60., 1.0)
    # Activity Rates
    # cm per km2
    area = 60. * 12.0 / np.sin(np.radians(60.))
    cm2perkm2 = (100. * 1000.)**2.
    mo1 = 3.0E11 * 0.2 * (area * cm2perkm2)
    mo_m6p75 = 10.0**(16.05 + 1.5 * 6.75)
    rate1 = mo1 / mo_m6p75
    mfd1 = EvenlyDiscretizedMFD(6.75, 0.01, [rate1])
    tom = PoissonTOM(1.0)
    aspect = 2.0
    rake = 90.0
    src = SimpleFaultSource("PEER_FLT_EAST", "PEER Bending Fault Dipping East",
                            "Active Shallow Crust", mfd1, 1.0, PeerMSR(), 2.0,
                            tom, 0.0, 12.0, trace_dip_east, 60.0, rake)
    src.num_ruptures = src.count_ruptures()
    return src
Beispiel #5
0
    def test_case_11(self):
        hypocenter_probability = (Decimal(1) /
                                  len(test_data.SET1_CASE11_HYPOCENTERS))
        hypocenter_pmf = PMF([
            (hypocenter_probability, hypocenter)
            for hypocenter in test_data.SET1_CASE11_HYPOCENTERS
        ])
        # apart from hypocenter pmf repeats case 10
        sources = [
            AreaSource(
                source_id='area',
                name='area',
                tectonic_region_type=const.TRT.ACTIVE_SHALLOW_CRUST,
                mfd=test_data.SET1_CASE11_MFD,
                nodal_plane_distribution=PMF([(1, NodalPlane(0.0, 90.0,
                                                             0.0))]),
                hypocenter_distribution=hypocenter_pmf,
                upper_seismogenic_depth=0.0,
                lower_seismogenic_depth=10.0,
                magnitude_scaling_relationship=PeerMSR(),
                rupture_aspect_ratio=test_data.SET1_RUPTURE_ASPECT_RATIO,
                polygon=test_data.SET1_CASE11_SOURCE_POLYGON,
                area_discretization=30.0,
                rupture_mesh_spacing=10.0)
        ]
        sites = SiteCollection([
            test_data.SET1_CASE11_SITE1, test_data.SET1_CASE11_SITE2,
            test_data.SET1_CASE11_SITE3, test_data.SET1_CASE11_SITE4
        ])
        gsims = {const.TRT.ACTIVE_SHALLOW_CRUST: SadighEtAl1997()}
        truncation_level = 0
        time_span = 1.0
        imts = {test_data.IMT: test_data.SET1_CASE11_IMLS}

        curves = hazard_curves(sources, sites, imts, time_span, gsims,
                               truncation_level)
        s1hc, s2hc, s3hc, s4hc = curves[test_data.IMT]

        assert_hazard_curve_is(self,
                               s1hc,
                               test_data.SET1_CASE11_SITE1_POES,
                               tolerance=2e-3)
        assert_hazard_curve_is(self,
                               s2hc,
                               test_data.SET1_CASE11_SITE2_POES,
                               tolerance=2e-3)
        assert_hazard_curve_is(self,
                               s3hc,
                               test_data.SET1_CASE11_SITE3_POES,
                               tolerance=2e-3)
        assert_hazard_curve_is(self,
                               s4hc,
                               test_data.SET1_CASE11_SITE4_POES,
                               tolerance=2e-3)
Beispiel #6
0
    def test01(self):
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 2.5
        upper_seismogenic_depth = 0
        lower_seismogenic_depth = 4.2426406871192848
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = 2.0
        tom = self.TOM
        fault_trace = Line([
            Point(0.0, 0.0),
            Point(0.0, 0.0359728811758),
            Point(0.0190775080917, 0.0550503815181),
            Point(0.03974514139, 0.0723925718855)
        ])
        mfd = TruncatedGRMFD(a_val=0.5,
                             b_val=1.0,
                             min_mag=5.8,
                             max_mag=6.2,
                             bin_width=0.1)
        floating_x_step = 10.0
        floating_y_step = 5.0
        dip = 90.0
        src = KiteFaultSource.as_simple_fault(
            source_id, name, trt, mfd, rupture_mesh_spacing,
            magnitude_scaling_relationship, rupture_aspect_ratio, tom,
            upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip,
            rake, floating_x_step, floating_y_step)

        sfs = SimpleFaultSurface.from_fault_data(fault_trace,
                                                 upper_seismogenic_depth,
                                                 lower_seismogenic_depth, dip,
                                                 rupture_mesh_spacing)

        msh = Mesh(lons=numpy.array([0.02]),
                   lats=numpy.array([0.03]),
                   depths=numpy.array([0.0]))

        rrup_sf = sfs.get_min_distance(msh)
        rrup_kf = src.surface.get_min_distance(msh)
        numpy.testing.assert_almost_equal(rrup_sf, rrup_kf, decimal=1)

        if MAKE_PICTURES:
            ppp(src.profiles, src.surface)
Beispiel #7
0
    def test_case_5(self):
        # only mfd differs from case 2
        sources = [SimpleFaultSource(source_id='fault1', name='fault1',
            tectonic_region_type=const.TRT.ACTIVE_SHALLOW_CRUST,
            mfd=test_data.SET1_CASE5_MFD,
            rupture_mesh_spacing=1.0,
            magnitude_scaling_relationship=PeerMSR(),
            rupture_aspect_ratio=test_data.SET1_RUPTURE_ASPECT_RATIO,
            temporal_occurrence_model=PoissonTOM(1.),
            upper_seismogenic_depth=test_data.SET1_CASE1TO9_UPPER_SEISMOGENIC_DEPTH,
            lower_seismogenic_depth=test_data.SET1_CASE1TO9_LOWER_SEISMOGENIC_DEPTH,
            fault_trace=test_data.SET1_CASE1TO9_FAULT_TRACE,
            dip=test_data.SET1_CASE1TO9_DIP,
            rake=test_data.SET1_CASE1TO9_RAKE
        )]
        sites = SiteCollection([
            test_data.SET1_CASE1TO9_SITE1, test_data.SET1_CASE1TO9_SITE2,
            test_data.SET1_CASE1TO9_SITE3, test_data.SET1_CASE1TO9_SITE4,
            test_data.SET1_CASE1TO9_SITE5, test_data.SET1_CASE1TO9_SITE6,
            test_data.SET1_CASE1TO9_SITE7
        ])
        gsims = {const.TRT.ACTIVE_SHALLOW_CRUST: SadighEtAl1997()}
        truncation_level = 0
        imts = {str(test_data.IMT): test_data.SET1_CASE5_IMLS}

        curves = calc_hazard_curves(
            sources, sites, imts, gsims, truncation_level)
        s1hc, s2hc, s3hc, s4hc, s5hc, s6hc, s7hc = curves[str(test_data.IMT)]

        assert_hazard_curve_is(self, s1hc, test_data.SET1_CASE5_SITE1_POES,
                               atol=1e-3, rtol=1e-5)
        assert_hazard_curve_is(self, s2hc, test_data.SET1_CASE5_SITE2_POES,
                               atol=1e-3, rtol=1e-5)
        assert_hazard_curve_is(self, s3hc, test_data.SET1_CASE5_SITE3_POES,
                               atol=1e-3, rtol=1e-5)
        assert_hazard_curve_is(self, s4hc, test_data.SET1_CASE5_SITE4_POES,
                               atol=1e-3, rtol=1e-5)
        assert_hazard_curve_is(self, s5hc, test_data.SET1_CASE5_SITE5_POES,
                               atol=1e-3, rtol=1e-5)
        assert_hazard_curve_is(self, s6hc, test_data.SET1_CASE5_SITE6_POES,
                               atol=1e-3, rtol=1e-5)
        assert_hazard_curve_is(self, s7hc, test_data.SET1_CASE5_SITE7_POES,
                               atol=1e-3, rtol=1e-5)
Beispiel #8
0
Basic Pseudo-database built on top of hdf5 for a set of processed strong
motion records
"""
import os
import h5py
import numpy as np
from datetime import datetime
from openquake.hazardlib.gsim.base import (SitesContext, DistancesContext,
                                           RuptureContext)
from openquake.hazardlib.site import Site, SiteCollection
from openquake.hazardlib.geo.point import Point
from openquake.hazardlib.scalerel import PeerMSR
from smtk.trellis.configure import vs30_to_z1pt0_as08, z1pt0_to_z2pt5
from smtk.trellis.configure import vs30_to_z1pt0_cy14, vs30_to_z2pt5_cb14

DEFAULT_MSR = PeerMSR()


class Magnitude(object):
    """
    Class to hold magnitude attributes
    :param float value:
        The magnitude value
    :param str mtype:
        Magnitude Type
    :param float sigma:
        The magnitude uncertainty (standard deviation)
    """
    def __init__(self, value, mtype, sigma=None, source=""):
        """
        Instantiate the class
Beispiel #9
0
    def test_case_2(self):
        sources = [
            SimpleFaultSource(
                source_id='fault1',
                name='fault1',
                tectonic_region_type=const.TRT.ACTIVE_SHALLOW_CRUST,
                mfd=test_data.SET1_CASE2_MFD,
                rupture_mesh_spacing=1.0,
                magnitude_scaling_relationship=PeerMSR(),
                rupture_aspect_ratio=test_data.SET1_RUPTURE_ASPECT_RATIO,
                upper_seismogenic_depth=test_data.
                SET1_CASE1TO9_UPPER_SEISMOGENIC_DEPTH,
                lower_seismogenic_depth=test_data.
                SET1_CASE1TO9_LOWER_SEISMOGENIC_DEPTH,
                fault_trace=test_data.SET1_CASE1TO9_FAULT_TRACE,
                dip=test_data.SET1_CASE1TO9_DIP,
                rake=test_data.SET1_CASE1TO9_RAKE)
        ]
        sites = SiteCollection([
            test_data.SET1_CASE1TO9_SITE1, test_data.SET1_CASE1TO9_SITE2,
            test_data.SET1_CASE1TO9_SITE3, test_data.SET1_CASE1TO9_SITE4,
            test_data.SET1_CASE1TO9_SITE5, test_data.SET1_CASE1TO9_SITE6,
            test_data.SET1_CASE1TO9_SITE7
        ])
        gsims = {const.TRT.ACTIVE_SHALLOW_CRUST: SadighEtAl1997()}
        truncation_level = 0
        time_span = 1.0
        imts = {test_data.IMT: test_data.SET1_CASE2_IMLS}

        curves = hazard_curves(sources, sites, imts, time_span, gsims,
                               truncation_level)
        s1hc, s2hc, s3hc, s4hc, s5hc, s6hc, s7hc = curves[test_data.IMT]

        assert_hazard_curve_is(self,
                               s1hc,
                               test_data.SET1_CASE2_SITE1_POES,
                               tolerance=3e-3)
        assert_hazard_curve_is(self,
                               s2hc,
                               test_data.SET1_CASE2_SITE2_POES,
                               tolerance=2e-5)
        assert_hazard_curve_is(self,
                               s3hc,
                               test_data.SET1_CASE2_SITE3_POES,
                               tolerance=2e-5)
        assert_hazard_curve_is(self,
                               s4hc,
                               test_data.SET1_CASE2_SITE4_POES,
                               tolerance=1e-3)
        assert_hazard_curve_is(self,
                               s5hc,
                               test_data.SET1_CASE2_SITE5_POES,
                               tolerance=1e-3)
        assert_hazard_curve_is(self,
                               s6hc,
                               test_data.SET1_CASE2_SITE6_POES,
                               tolerance=1e-3)
        assert_hazard_curve_is(self,
                               s7hc,
                               test_data.SET1_CASE2_SITE7_POES,
                               tolerance=2e-5)