def make_non_parametric_source():
    surf1 = PlanarSurface(
        mesh_spacing=2., strike=0, dip=90,
        top_left=Point(0., -1., 0.), top_right=Point(0., 1., 0.),
        bottom_right=Point(0., 1., 10.), bottom_left=Point(0., -1., 10.)
    )
    surf2 = PlanarSurface(
        mesh_spacing=2., strike=90., dip=90.,
        top_left=Point(-1., 0., 0.), top_right=Point(1., 0., 0.),
        bottom_right=Point(1., 0., 10.), bottom_left=Point(-1., 0., 10.)
    )
    rup1 = Rupture(
        mag=5., rake=90., tectonic_region_type='ASC',
        hypocenter=Point(0., 0., 5.), surface=surf1, source_typology=None
    )
    rup2 = Rupture(
        mag=6, rake=0, tectonic_region_type='ASC',
        hypocenter=Point(0., 0., 5.), surface=surf2, source_typology=None
    )
    pmf1 = PMF([(Decimal('0.7'), 0), (Decimal('0.3'), 1)])
    pmf2 = PMF([(Decimal('0.7'), 0), (Decimal('0.2'), 1), (Decimal('0.1'), 2)])
    kwargs = {
        'source_id': 'source_id', 'name': 'source name',
        'tectonic_region_type': 'tectonic region',
        'data': [(rup1, pmf1), (rup2, pmf2)]
    }
    npss = NonParametricSeismicSource(**kwargs)
    assert_pickleable(npss)
    return npss, kwargs
Exemple #2
0
 def get_rupture(self):
     """
     Returns the rupture as an instance of the
     openquake.hazardlib.source.rupture.Rupture class
     """
     return Rupture(self.magnitude, self.rake, self.trt, self.hypocentre,
                    self.surface, PointSource)
Exemple #3
0
def _create_rupture(distance, magnitude,
                    tectonic_region_type=TRT.ACTIVE_SHALLOW_CRUST):
    # Return a rupture with a fixed geometry located at a given r_jb distance
    # from a site located at (0.0, 0.0).
    # parameter float distance:
    #    Joyner and Boore rupture-site distance
    # parameter float magnitude:
    #    Rupture magnitude

    # Find the point at a given distance
    lonp, latp = point_at(0.0, 0.0, 90., distance)
    mag = magnitude
    rake = 0.0
    tectonic_region_type = tectonic_region_type
    hypocenter = Point(lonp, latp, 2.5)
    surface = PlanarSurface.from_corner_points(0.01,
                                               Point(lonp, -1, 0.),
                                               Point(lonp, +1, 0.),
                                               Point(lonp, +1, 5.),
                                               Point(lonp, -1, 5.))
    surface = SimpleFaultSurface.from_fault_data(
        fault_trace=Line([Point(lonp, -1), Point(lonp, 1)]),
        upper_seismogenic_depth=0.0,
        lower_seismogenic_depth=5.0,
        dip=90.0,
        mesh_spacing=1.0)
    # check effective rupture-site distance
    from openquake.hazardlib.geo.mesh import Mesh
    mesh = Mesh(numpy.array([0.0]), numpy.array([0.0]))
    assert abs(surface.get_joyner_boore_distance(mesh)-distance) < 1e-2
    return Rupture(mag, rake, tectonic_region_type, hypocenter,
                   surface, NonParametricSeismicSource)
Exemple #4
0
 def __init__(self, id, trt, mag=5.0, rake=90.):
     hypocenter = Point(17.788328, -77.219496, 7.8125)
     lons = numpy.array(
         [-78.18106621, -78.18013243, -78.17919864, -78.15399318,
          -78.15305962, -78.15212606])
     lats = numpy.array(
         [15.615, 15.615, 15.615, 15.56553731,
          15.56553731,  15.56553731])
     surface = ComplexFaultSurface(Mesh(lons, lats, None))
     self.rupture = Rupture(mag, rake, trt, hypocenter,
                            surface, ComplexFaultSource)
     self.id = id
Exemple #5
0
def build_rupture_from_file(rupture_file, trt="Active Shallow Crust"):
    """
    Reads an OpenQuake Rupture Model file and parses it to an instance of
    :calass: openquake.hazardlib.source.rupture.Rupture
    """
    parser = RuptureModelParser(rupture_file)
    rupture = parser.parse()
    surface = build_planar_surface(rupture.geometry)
    hypocentre = Point(rupture.hypocenter[0], rupture.hypocenter[1],
                       rupture.hypocenter[2])
    return Rupture(rupture.magnitude, rupture.rake, trt, hypocentre, surface,
                   SimpleFaultSource)
Exemple #6
0
    def setUp(self):
        super(MakeContextsTestCase, self).setUp()
        self.site1_location = Point(1, 2)
        self.site2_location = Point(-2, -3)
        self.site1 = Site(vs30=456,
                          vs30measured=False,
                          z1pt0=12.1,
                          z2pt5=15.1,
                          location=self.site1_location)
        self.site2 = Site(vs30=1456,
                          vs30measured=True,
                          z1pt0=112.1,
                          z2pt5=115.1,
                          location=self.site2_location)
        min_distance = numpy.array([10, 11])
        rx_distance = numpy.array([4, 5])
        jb_distance = numpy.array([6, 7])
        ry0_distance = numpy.array([8, 9])
        top_edge_depth = 30
        width = 15
        strike = 60.123

        class FakeSurface(object):
            call_counts = collections.Counter()

            def get_strike(self):
                self.call_counts['get_strike'] += 1
                return strike

            def get_dip(self):
                self.call_counts['get_dip'] += 1
                return 45.4545

            def get_min_distance(fake_surface, mesh):
                self.assertIsInstance(mesh, Mesh)
                [point1, point2] = mesh
                self.assertEqual(point1, self.site1_location)
                self.assertEqual(point2, self.site2_location)
                fake_surface.call_counts['get_min_distance'] += 1
                return min_distance

            def get_rx_distance(fake_surface, mesh):
                self.assertIsInstance(mesh, Mesh)
                [point1, point2] = mesh
                self.assertEqual(point1, self.site1_location)
                self.assertEqual(point2, self.site2_location)
                fake_surface.call_counts['get_rx_distance'] += 1
                return rx_distance

            def get_ry0_distance(fake_surface, mesh):
                self.assertIsInstance(mesh, Mesh)
                [point1, point2] = mesh
                self.assertEqual(point1, self.site1_location)
                self.assertEqual(point2, self.site2_location)
                fake_surface.call_counts['get_ry0_distance'] += 1
                return ry0_distance

            def get_joyner_boore_distance(fake_surface, mesh):
                self.assertIsInstance(mesh, Mesh)
                [point1, point2] = mesh
                self.assertEqual(point1, self.site1_location)
                self.assertEqual(point2, self.site2_location)
                fake_surface.call_counts['get_joyner_boore_distance'] += 1
                return jb_distance

            def get_top_edge_depth(fake_surface):
                fake_surface.call_counts['get_top_edge_depth'] += 1
                return top_edge_depth

            def get_width(fake_surface):
                fake_surface.call_counts['get_width'] += 1
                return width

        self.rupture_hypocenter = Point(2, 3, 40)
        self.rupture = Rupture(mag=123.45,
                               rake=123.56,
                               tectonic_region_type=const.TRT.VOLCANIC,
                               hypocenter=self.rupture_hypocenter,
                               surface=FakeSurface(),
                               source_typology=object())
        self.gsim_class.DEFINED_FOR_TECTONIC_REGION_TYPE = const.TRT.VOLCANIC
        self.fake_surface = FakeSurface