Пример #1
0
    def test_get_strike_1(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0635916966572, 0.0635916574897)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2]), 1.0, 6.0,
                                                     89.9, 1.0)

        self.assertAlmostEquals(45.0, surface.get_strike(), delta=1e-4)
Пример #2
0
    def test_get_strike_1(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0635916966572, 0.0635916574897)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2]),
                1.0, 6.0, 89.9, 1.0)

        self.assertAlmostEquals(45.0, surface.get_strike(), delta=1e-4)
Пример #3
0
 def test_inclined_non_planar_surface(self):
     p1 = Point(0.1, 0.1, 0.0)
     p2 = Point(0.1, 0.117986432118, 0.0)
     p3 = Point(0.117986470254, 0.117986426305, 0.0)
     p4 = Point(0.117986470254, 0.0999999941864, 0.0)
     surface = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3, p4]),
                                                  2.0, 4.0, 30.0, 1.0)
     self.assertAlmostEqual(surface.get_width(), 4.0, places=2)
Пример #4
0
    def test_get_dip_2(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0635916966572, 0.0635916574897)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2]), 1.0, 6.0,
                                                     30.0, 1.0)

        self.assertAlmostEquals(30.0, surface.get_dip(), 1)
Пример #5
0
    def test_get_dip_2(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0635916966572, 0.0635916574897)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2]),
                1.0, 6.0, 30.0, 1.0)

        self.assertAlmostEquals(30.0, surface.get_dip(), 1)
Пример #6
0
    def test_get_dip_1(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0635916966572, 0.0635916574897)
        p3 = Point(0.0860747816618, 0.102533437776)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3]),
                1.0, 6.0, 90.0, 1.0)

        self.assertAlmostEquals(90.0, surface.get_dip(), delta=1e-6)
Пример #7
0
    def test_get_mesh_5(self):
        p1 = Point(179.9, 0.0)
        p2 = Point(180.0, 0.0)
        p3 = Point(-179.9, 0.0)

        fault = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3]),
                1.0, 6.0, 90.0, 1.0)

        self.assert_mesh_is(fault, test_data.TEST_5_MESH)
Пример #8
0
    def test_get_dip_1(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0635916966572, 0.0635916574897)
        p3 = Point(0.0860747816618, 0.102533437776)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3]), 1.0,
                                                     6.0, 90.0, 1.0)

        self.assertAlmostEquals(90.0, surface.get_dip(), delta=1e-6)
Пример #9
0
    def test_get_mesh_5(self):
        p1 = Point(179.9, 0.0)
        p2 = Point(180.0, 0.0)
        p3 = Point(-179.9, 0.0)

        fault = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3]), 1.0,
                                                   6.0, 90.0, 1.0)

        self.assert_mesh_is(fault, test_data.TEST_5_MESH)
Пример #10
0
    def test_get_mesh_1(self):
        p1 = Point(0.0, 0.0, 0.0)
        p2 = Point(0.0, 0.0359728811759, 0.0)
        p3 = Point(0.0190775080917, 0.0550503815182, 0.0)
        p4 = Point(0.03974514139, 0.0723925718856, 0.0)

        fault = SimpleFaultSurface.from_fault_data(
            Line([p1, p2, p3, p4]), 0.0, 4.2426406871192848, 45.0, 1.0)

        self.assert_mesh_is(fault, test_data.TEST_1_MESH)
Пример #11
0
    def test_get_mesh_4(self):
        p1 = Point(0.0, 0.0, 0.0)
        p2 = Point(0.0, 0.0359728811759, 0.0)
        p3 = Point(0.0190775080917, 0.0550503815182, 0.0)
        p4 = Point(0.03974514139, 0.0723925718856, 0.0)

        fault = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3, p4]), 0.0,
                                                   4.0, 90.0, 1.0)

        self.assert_mesh_is(fault, test_data.TEST_4_MESH)
Пример #12
0
    def __init__(
        self,
        identifier,
        name,
        tectonic_region,
        aspect_ratio,
        fault_trace,
        dip,
        upper_depth,
        lower_depth,
        mesh_spacing=1.0,
    ):
        """Instantiate class with just the basic attributes
        :param identifier: 
            Integer ID code for the source
        :param name:
            Source Name (string)
        :param tectonic_region:
            Tectonic Region Type (String)
        :param aspect_ratio:
            Ratio of along-strike length to down-dip width (float)
        :param fault_trace:
            Surface trace of the fault [Long., Lat] as np.ndarray
        :param dip:
            Dip of fault (degrees) (Float between 0 and 90)
        :param upper_depth:
            Upper seismogenic depth (km) (Non-negative Float)
        :param lower_depth:
            Lower Seismogenic depth (km) (Non-negative Float)
        :param mesh_spacing:
            Spacing of mesh (km) (Non-negative Float)
        """
        self.typology = "SimpleFault"
        self.source_id = identifier
        self.name = name
        self.tectonic_region_type = tectonic_region
        self.aspect_ratio = aspect_ratio
        self.mfd = None
        self.msr = None
        if upper_depth < 0.0:
            raise ValueError("Upper Depth Must be Non Negative")
        if lower_depth < 0.0 or (lower_depth < upper_depth):
            raise ValueError("Lower Depth must be Non-Negative and > Upper depth")
        self.trace = []
        if np.shape(fault_trace)[1] < 3:
            depth = np.zeros(np.shape(fault_trace)[0], dtype=float)
        else:
            depth = fault_trace[:, 2]

        for iloc, node in enumerate(fault_trace):
            self.trace.append(Point(node[0], node[1], depth[iloc]))
        self.trace = Line(self.trace)
        self.geometry = SimpleFaultSurface.from_fault_data(
            self.trace, self.upper_depth, self.lower_depth, self.dip, mesh_spacing
        )
Пример #13
0
    def test_get_mesh_2(self):
        p1 = Point(0.0, 0.0, 0.0)
        p2 = Point(0.0, 0.0359728811759, 0.0)
        p3 = Point(0.0190775080917, 0.0550503815182, 0.0)
        p4 = Point(0.03974514139, 0.0723925718856, 0.0)

        fault = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3,
                                                         p4]), 2.12132034356,
                                                   4.2426406871192848, 45.0,
                                                   1.0)

        self.assert_mesh_is(fault, test_data.TEST_2_MESH)
Пример #14
0
    def _make_source(self, *args, **kwargs):
        source = super(ComplexFaultSourceSimpleGeometryIterRupturesTestCase,
                       self)._make_source(*args, **kwargs)
        surface = SimpleFaultSurface.from_fault_data(
            source.fault_trace, source.upper_seismogenic_depth,
            source.lower_seismogenic_depth, source.dip,
            source.rupture_mesh_spacing)
        mesh = surface.get_mesh()
        top_edge = Line(list(mesh[0:1]))
        bottom_edge = Line(list(mesh[-1:]))

        return ComplexFaultSource(source.source_id, source.name,
                                  source.tectonic_region_type, source.mfd,
                                  source.rupture_mesh_spacing,
                                  source.magnitude_scaling_relationship,
                                  source.rupture_aspect_ratio,
                                  [top_edge, bottom_edge], source.rake)
Пример #15
0
    def iter_ruptures(self, temporal_occurrence_model):
        """
        See :meth:`nhlib.source.base.SeismicSource.iter_ruptures`.

        Generates a ruptures using the "floating" algorithm: for all the
        magnitude values of assigned MFD calculates the rupture size with
        respect to MSR and aspect ratio and then places ruptures of that
        size on the surface of the whole fault source. The occurrence
        rate of each of those ruptures is the magnitude occurrence rate
        divided by the number of ruptures that can be placed in a fault.
        """
        whole_fault_surface = SimpleFaultSurface.from_fault_data(
            self.fault_trace, self.upper_seismogenic_depth,
            self.lower_seismogenic_depth, self.dip, self.rupture_mesh_spacing
        )
        whole_fault_mesh = whole_fault_surface.get_mesh()
        mesh_rows, mesh_cols = whole_fault_mesh.shape
        fault_length = float((mesh_cols - 1) * self.rupture_mesh_spacing)
        fault_width = float((mesh_rows - 1) * self.rupture_mesh_spacing)

        for (mag, mag_occ_rate) in self.get_annual_occurrence_rates():
            rup_cols, rup_rows = self._get_rupture_dimensions(
                fault_length, fault_width, mag
            )
            num_rup_along_length = mesh_cols - rup_cols + 1
            num_rup_along_width = mesh_rows - rup_rows + 1
            num_rup = num_rup_along_length * num_rup_along_width

            occurrence_rate = mag_occ_rate / float(num_rup)

            for first_row in xrange(num_rup_along_width):
                for first_col in xrange(num_rup_along_length):
                    mesh = whole_fault_mesh[first_row : first_row + rup_rows,
                                            first_col : first_col + rup_cols]
                    hypocenter = mesh.get_middle_point()
                    surface = SimpleFaultSurface(mesh)
                    yield ProbabilisticRupture(
                        mag, self.rake, self.tectonic_region_type, hypocenter,
                        surface, type(self),
                        occurrence_rate, temporal_occurrence_model
                    )
Пример #16
0
    def iter_ruptures(self, temporal_occurrence_model):
        """
        See :meth:`nhlib.source.base.SeismicSource.iter_ruptures`.

        Generates a ruptures using the "floating" algorithm: for all the
        magnitude values of assigned MFD calculates the rupture size with
        respect to MSR and aspect ratio and then places ruptures of that
        size on the surface of the whole fault source. The occurrence
        rate of each of those ruptures is the magnitude occurrence rate
        divided by the number of ruptures that can be placed in a fault.
        """
        whole_fault_surface = SimpleFaultSurface.from_fault_data(
            self.fault_trace, self.upper_seismogenic_depth,
            self.lower_seismogenic_depth, self.dip, self.rupture_mesh_spacing)
        whole_fault_mesh = whole_fault_surface.get_mesh()
        mesh_rows, mesh_cols = whole_fault_mesh.shape
        fault_length = float((mesh_cols - 1) * self.rupture_mesh_spacing)
        fault_width = float((mesh_rows - 1) * self.rupture_mesh_spacing)

        for (mag, mag_occ_rate) in self.get_annual_occurrence_rates():
            rup_cols, rup_rows = self._get_rupture_dimensions(
                fault_length, fault_width, mag)
            num_rup_along_length = mesh_cols - rup_cols + 1
            num_rup_along_width = mesh_rows - rup_rows + 1
            num_rup = num_rup_along_length * num_rup_along_width

            occurrence_rate = mag_occ_rate / float(num_rup)

            for first_row in xrange(num_rup_along_width):
                for first_col in xrange(num_rup_along_length):
                    mesh = whole_fault_mesh[first_row:first_row + rup_rows,
                                            first_col:first_col + rup_cols]
                    hypocenter = mesh.get_middle_point()
                    surface = SimpleFaultSurface(mesh)
                    yield ProbabilisticRupture(mag, self.rake,
                                               self.tectonic_region_type,
                                               hypocenter, surface, type(self),
                                               occurrence_rate,
                                               temporal_occurrence_model)
Пример #17
0
    def test_get_dip_5(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0, 0.0899322029395)
        p3 = Point(0.0899323137217, 0.0899320921571)
        p4 = Point(0.0899323137217, -1.10782376538e-07)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3, p4]),
                                                     0.0, 10.0, 45.0, 1.0)

        # fault contains three segments. the one in the middle is inclined
        # with dip of 45 degrees. other two are purely vertical (they are
        # perpendicular to the middle one). the middle segment is rectangle
        # and the side ones are parallelograms. area of those parallelograms
        # is area of middle segment times sine of their acute angle.
        mid_area = 1.0
        mid_dip = pi / 4  # 45 degree
        side_area = sin(mid_dip) * mid_area
        side_dip = pi / 2  # 90 degree

        expected_dip = degrees(
            atan2((mid_area * sin(mid_dip) + 2 * (side_area * sin(side_dip))) /
                  3.0, (mid_area * cos(mid_dip) + 2 *
                        (side_area * cos(side_dip))) / 3.0))
        self.assertAlmostEquals(surface.get_dip(), expected_dip, delta=1e-3)
Пример #18
0
    def test_get_dip_5(self):
        p1 = Point(0.0, 0.0)
        p2 = Point(0.0, 0.0899322029395)
        p3 = Point(0.0899323137217, 0.0899320921571)
        p4 = Point(0.0899323137217, -1.10782376538e-07)

        surface = SimpleFaultSurface.from_fault_data(Line([p1, p2, p3, p4]),
                                                     0.0, 10.0, 45.0, 1.0)

        # fault contains three segments. the one in the middle is inclined
        # with dip of 45 degrees. other two are purely vertical (they are
        # perpendicular to the middle one). the middle segment is rectangle
        # and the side ones are parallelograms. area of those parallelograms
        # is area of middle segment times sine of their acute angle.
        mid_area = 1.0
        mid_dip = pi / 4  # 45 degree
        side_area = sin(mid_dip) * mid_area
        side_dip = pi / 2  # 90 degree

        expected_dip = degrees(atan2(
            (mid_area * sin(mid_dip) + 2 * (side_area * sin(side_dip))) / 3.0,
            (mid_area * cos(mid_dip) + 2 * (side_area * cos(side_dip))) / 3.0
        ))
        self.assertAlmostEquals(surface.get_dip(), expected_dip, delta=1e-3)
Пример #19
0
 def test_vertical_planar_surface(self):
     p1 = Point(0.1, 0.1, 0.0)
     p2 = Point(0.1, 0.126979648178, 0.0)
     surface = SimpleFaultSurface.from_fault_data(Line([p1, p2]),
                                                  2.0, 4.0, 90.0, 1.0)
     self.assertAlmostEqual(surface.get_width(), 2.0)
Пример #20
0
 def test_get_strike_along_meridian(self):
     line = Line([Point(0, 0), Point(1e-5, 1e-3), Point(0, 2e-3)])
     surface = SimpleFaultSurface.from_fault_data(line, 1.0, 6.0, 89.9, 0.1)
     self.assertAlmostEquals(0, surface.get_strike(), delta=6e-2)
Пример #21
0
 def test_get_strike_along_meridian(self):
     line = Line([Point(0, 0), Point(1e-5, 1e-3), Point(0, 2e-3)])
     surface = SimpleFaultSurface.from_fault_data(line, 1.0, 6.0, 89.9, 0.1)
     self.assertAlmostEquals(0, surface.get_strike(), delta=6e-2)