Exemple #1
0
 def _get_rupture(self,
                  min_mag,
                  max_mag,
                  hypocenter_depth,
                  aspect_ratio,
                  dip,
                  rupture_mesh_spacing,
                  upper_seismogenic_depth=2,
                  lower_seismogenic_depth=16):
     source_id = name = 'test-source'
     trt = TRT.ACTIVE_SHALLOW_CRUST
     mfd = TruncatedGRMFD(a_val=2,
                          b_val=1,
                          min_mag=min_mag,
                          max_mag=max_mag,
                          bin_width=1)
     location = Point(0, 0)
     nodal_plane = NodalPlane(strike=45, dip=dip, rake=-123.23)
     nodal_plane_distribution = PMF([(1, nodal_plane)])
     hypocenter_distribution = PMF([(1, hypocenter_depth)])
     magnitude_scaling_relationship = PeerMSR()
     rupture_aspect_ratio = aspect_ratio
     tom = PoissonTOM(time_span=50)
     point_source = PointSource(
         source_id, name, trt, mfd, rupture_mesh_spacing,
         magnitude_scaling_relationship, rupture_aspect_ratio, tom,
         upper_seismogenic_depth, lower_seismogenic_depth, location,
         nodal_plane_distribution, hypocenter_distribution)
     ruptures = list(point_source.iter_ruptures())
     self.assertEqual(len(ruptures), 1)
     [rupture] = ruptures
     self.assertIs(rupture.temporal_occurrence_model, tom)
     self.assertIs(rupture.tectonic_region_type, trt)
     self.assertEqual(rupture.rake, nodal_plane.rake)
     self.assertIsInstance(rupture.surface, PlanarSurface)
     return rupture
Exemple #2
0
def make_point_source(**kwargs):
    default_arguments = {
        'source_id': 'source_id',
        'name': 'source name',
        'tectonic_region_type': TRT.SUBDUCTION_INTRASLAB,
        'mfd': TruncatedGRMFD(a_val=1,
                              b_val=2,
                              min_mag=3,
                              max_mag=5,
                              bin_width=1),
        'location': Point(1.2, 3.4, 5.6),
        'nodal_plane_distribution': PMF([(1, NodalPlane(1, 2, 3))]),
        'hypocenter_distribution': PMF([(1, 4)]),
        'upper_seismogenic_depth': 1.3,
        'lower_seismogenic_depth': 4.9,
        'magnitude_scaling_relationship': PeerMSR(),
        'rupture_aspect_ratio': 1.333,
        'rupture_mesh_spacing': 1.234
    }
    default_arguments.update(kwargs)
    kwargs = default_arguments
    ps = PointSource(**kwargs)
    assert_pickleable(ps)
    return ps
Exemple #3
0
                         1.0,
                         PoissonTOM(1.0),
                         0.,
                         40.,
                         PMF([(1.0, NodalPlane(0.0, 90.0, 0.0))]),
                         PMF([(0.5, 5.0), (0.5, 15.0)]),
                         AREA_POLY,
                         4.0)

SIMPLE_TRACE = Line([Point(14.975, 15.0, 0.0), Point(15.025, 15.0, 0.0)])

SIMPLE_FAULT = SimpleFaultSource("SFLT000", "Simple Fault Source",
                                 "Active Shallow Crust",
                                 EvenlyDiscretizedMFD(7.0, 0.1, [1.0]),
                                 1.0,
                                 PeerMSR(),
                                 1.0,
                                 PoissonTOM(1.0),
                                 0.0,
                                 20.0,
                                 SIMPLE_TRACE,
                                 90.,
                                 0.0)

COMPLEX_EDGES = [SIMPLE_TRACE,
                 Line([Point(14.975, 15.0, 20.0),
                       Point(15.025, 15.0, 20.0)])]

COMPLEX_FAULT = ComplexFaultSource("CFLT000", "Complex Fault Source",
                                   "Active Shallow Crust",
                                   EvenlyDiscretizedMFD(7.0, 0.1, [1.0]),
Exemple #4
0
    Point(15.05, 14.95),
    Point(14.95, 14.95)
])

AREA_SOURCE = AreaSource("AREA000", "Area 000", "Active Shallow Crust",
                         EvenlyDiscretizedMFD(5.0, 0.1, [1.0]), 1.0,
                         PointMSR(), 1.0, PoissonTOM(1.0), 0., 40.,
                         PMF([(1.0, NodalPlane(0.0, 90.0, 0.0))]),
                         PMF([(0.5, 5.0), (0.5, 15.0)]), AREA_POLY, 4.0)

SIMPLE_TRACE = Line([Point(14.975, 15.0, 0.0), Point(15.025, 15.0, 0.0)])

SIMPLE_FAULT = SimpleFaultSource("SFLT000", "Simple Fault Source",
                                 "Active Shallow Crust",
                                 EvenlyDiscretizedMFD(7.0, 0.1, [1.0]), 1.0,
                                 PeerMSR(), 1.0, PoissonTOM(1.0), 0.0, 20.0,
                                 SIMPLE_TRACE, 90., 0.0)

COMPLEX_EDGES = [
    SIMPLE_TRACE,
    Line([Point(14.975, 15.0, 20.0),
          Point(15.025, 15.0, 20.0)])
]

COMPLEX_FAULT = ComplexFaultSource("CFLT000", "Complex Fault Source",
                                   "Active Shallow Crust",
                                   EvenlyDiscretizedMFD(7.0, 0.1, [1.0]), 1.0,
                                   PeerMSR(), 1.0, PoissonTOM(1.0),
                                   COMPLEX_EDGES, 0.0)

SIMPLE_FAULT_SURFACE = SimpleFaultSurface.from_fault_data(
Exemple #5
0
    def test_7_many_ruptures(self):
        source_id = name = 'test7-source'
        trt = TRT.VOLCANIC
        mag1 = 4.5
        mag2 = 5.5
        mag1_rate = 9e-3
        mag2_rate = 9e-4
        hypocenter1 = 9.0
        hypocenter2 = 10.0
        hypocenter1_weight = Decimal('0.8')
        hypocenter2_weight = Decimal('0.2')
        nodalplane1 = NodalPlane(strike=45, dip=90, rake=0)
        nodalplane2 = NodalPlane(strike=0, dip=45, rake=10)
        nodalplane1_weight = Decimal('0.3')
        nodalplane2_weight = Decimal('0.7')
        upper_seismogenic_depth = 2
        lower_seismogenic_depth = 16
        rupture_aspect_ratio = 2
        rupture_mesh_spacing = 0.5
        location = Point(0, 0)
        magnitude_scaling_relationship = PeerMSR()
        tom = PoissonTOM(time_span=50)

        mfd = EvenlyDiscretizedMFD(min_mag=mag1,
                                   bin_width=(mag2 - mag1),
                                   occurrence_rates=[mag1_rate, mag2_rate])
        nodal_plane_distribution = PMF([(nodalplane1_weight, nodalplane1),
                                        (nodalplane2_weight, nodalplane2)])
        hypocenter_distribution = PMF([(hypocenter1_weight, hypocenter1),
                                       (hypocenter2_weight, hypocenter2)])
        point_source = PointSource(
            source_id, name, trt, mfd, rupture_mesh_spacing,
            magnitude_scaling_relationship, rupture_aspect_ratio, tom,
            upper_seismogenic_depth, lower_seismogenic_depth, location,
            nodal_plane_distribution, hypocenter_distribution)
        actual_ruptures = list(point_source.iter_ruptures())
        self.assertEqual(len(actual_ruptures), point_source.count_ruptures())
        expected_ruptures = {
            (mag1, nodalplane1.rake, hypocenter1): (
                # probabilistic rupture's occurrence rate
                9e-3 * 0.3 * 0.8,
                # rupture surface corners
                planar_surface_test_data.TEST_7_RUPTURE_1_CORNERS),
            (mag2, nodalplane1.rake, hypocenter1):
            (9e-4 * 0.3 * 0.8,
             planar_surface_test_data.TEST_7_RUPTURE_2_CORNERS),
            (mag1, nodalplane2.rake, hypocenter1):
            (9e-3 * 0.7 * 0.8,
             planar_surface_test_data.TEST_7_RUPTURE_3_CORNERS),
            (mag2, nodalplane2.rake, hypocenter1):
            (9e-4 * 0.7 * 0.8,
             planar_surface_test_data.TEST_7_RUPTURE_4_CORNERS),
            (mag1, nodalplane1.rake, hypocenter2):
            (9e-3 * 0.3 * 0.2,
             planar_surface_test_data.TEST_7_RUPTURE_5_CORNERS),
            (mag2, nodalplane1.rake, hypocenter2):
            (9e-4 * 0.3 * 0.2,
             planar_surface_test_data.TEST_7_RUPTURE_6_CORNERS),
            (mag1, nodalplane2.rake, hypocenter2):
            (9e-3 * 0.7 * 0.2,
             planar_surface_test_data.TEST_7_RUPTURE_7_CORNERS),
            (mag2, nodalplane2.rake, hypocenter2):
            (9e-4 * 0.7 * 0.2,
             planar_surface_test_data.TEST_7_RUPTURE_8_CORNERS)
        }
        for actual_rupture in actual_ruptures:
            expected_occurrence_rate, expected_corners = expected_ruptures[(
                actual_rupture.mag, actual_rupture.rake,
                actual_rupture.hypocenter.depth)]
            self.assertTrue(
                isinstance(actual_rupture, ParametricProbabilisticRupture))
            self.assertEqual(actual_rupture.occurrence_rate,
                             expected_occurrence_rate)
            self.assertIs(actual_rupture.temporal_occurrence_model, tom)
            self.assertEqual(actual_rupture.tectonic_region_type, trt)
            surface = actual_rupture.surface

            tl, tr, br, bl = expected_corners
            self.assertEqual(tl, surface.top_left)
            self.assertEqual(tr, surface.top_right)
            self.assertEqual(bl, surface.bottom_left)
            self.assertEqual(br, surface.bottom_right)
Exemple #6
0
    "NS": 70.,  # Normal with strike-slip component
    "TS": 45.,  # Reverse with strike-slip component
    "O": 90.0
}


# mean utilities (geometric, arithmetic, ...):
SCALAR_XY = {
    "Geometric": lambda x, y: np.sqrt(x * y),
    "Arithmetic": lambda x, y: (x + y) / 2.,
    "Larger": lambda x, y: np.max(np.array([x, y]), axis=0),
    "Vectorial": lambda x, y: np.sqrt(x ** 2. + y ** 2.)
}


DEFAULT_MSR = PeerMSR()


def get_interpolated_period(target_period, periods, values):
    """
    Returns the spectra interpolated in loglog space

    :param float target_period: Period required for interpolation
    :param np.ndarray periods: Spectral Periods
    :param np.ndarray values: Ground motion values
    """
    if (target_period < np.min(periods)) or (target_period > np.max(periods)):
        raise ValueError("Period not within calculated range: %s" %
                         str(target_period))
    lval = np.where(periods <= target_period)[0][-1]
    uval = np.where(periods >= target_period)[0][0]