コード例 #1
0
 def _test_ruptures(self, expected_ruptures, source):
     tom = PoissonTOM(time_span=50)
     ruptures = list(source.iter_ruptures(tom))
     for rupture in ruptures:
         self.assertIsInstance(rupture, ProbabilisticRupture)
         self.assertIs(rupture.temporal_occurrence_model, tom)
         self.assertIs(rupture.tectonic_region_type, self.TRT)
         self.assertEqual(rupture.rake, self.RAKE)
     self.assertEqual(len(expected_ruptures), len(ruptures))
     for i in xrange(len(expected_ruptures)):
         expected_rupture, rupture = expected_ruptures[i], ruptures[i]
         self.assertAlmostEqual(rupture.mag, expected_rupture['mag'])
         self.assertAlmostEqual(rupture.rake, expected_rupture['rake'])
         self.assertAlmostEqual(rupture.occurrence_rate,
                                expected_rupture['occurrence_rate'])
         assert_mesh_is(self, rupture.surface, expected_rupture['surface'])
         self.assertEqual(rupture.hypocenter,
                          Point(*expected_rupture['hypocenter']))
         assert_angles_equal(self,
                             rupture.surface.get_strike(),
                             expected_rupture['strike'],
                             delta=0.5)
         assert_angles_equal(self,
                             rupture.surface.get_dip(),
                             expected_rupture['dip'],
                             delta=3)
コード例 #2
0
ファイル: mesh_test.py プロジェクト: angri/nhlib
    def test_two_cells(self):
        top = [Point(0, -0.01), Point(0, 0.01)]
        middle = [Point(0.01, -0.01, 1.11), Point(0.01, 0.01, 1.11)]
        bottom = [Point(0.01, -0.01, 2.22), Point(0.01, 0.01, 2.22)]

        mesh = RectangularMesh.from_points_list([top, middle, bottom])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(dip, math.degrees(math.atan2(2, 1)), delta=0.1)
        self.assertAlmostEqual(strike, 0, delta=0.02)

        bottom = [Point(0.01, -0.01, 3.33), Point(0.01, 0.01, 3.33)]
        mesh = RectangularMesh.from_points_list([top, middle, bottom])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(dip, math.degrees(math.atan2(3, 1)), delta=0.1)
        self.assertAlmostEqual(strike, 0, delta=0.02)

        row1 = [Point(90, -0.1), Point(90, 0), Point(90, 0.1)]
        row2 = [Point(90, -0.1, 1), Point(90, 0, 1), Point(90, 0.1, 1)]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(dip, 90)
        assert_angles_equal(self, strike, 360, delta=1e-7)

        row1 = [Point(-90.1, -0.1), Point(-90, 0), Point(-89.9, 0.1)]
        row2 = [
            Point(-90.0, -0.1, 1),
            Point(-89.9, 0, 1),
            Point(-89.8, 0.1, 1)
        ]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(strike, 45, delta=1e-4)

        row1 = [Point(-90.1, -0.1), Point(-90, 0), Point(-89.9, 0.1)]
        row2 = [
            Point(-90.0, -0.1, 1),
            Point(-89.9, 0, 1),
            Point(-89.8, 0.1, 1)
        ]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(strike, 45, delta=1e-3)

        row1 = [Point(-90.1, -0.1), Point(-90, 0), Point(-89.9, 0.1)]
        row2 = [Point(-90.2, -0.1, 1), Point(-90.1, 0, 1), Point(-90, 0.1, 1)]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(strike, 225, delta=1e-3)
コード例 #3
0
    def test_two_cells(self):
        top = [Point(0, -0.01), Point(0, 0.01)]
        middle = [Point(0.01, -0.01, 1.11), Point(0.01, 0.01, 1.11)]
        bottom = [Point(0.01, -0.01, 2.22), Point(0.01, 0.01, 2.22)]

        mesh = RectangularMesh.from_points_list([top, middle, bottom])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(dip, math.degrees(math.atan2(2, 1)), delta=0.1)
        self.assertAlmostEqual(strike, 0, delta=0.02)

        bottom = [Point(0.01, -0.01, 3.33), Point(0.01, 0.01, 3.33)]
        mesh = RectangularMesh.from_points_list([top, middle, bottom])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(dip, math.degrees(math.atan2(3, 1)), delta=0.1)
        self.assertAlmostEqual(strike, 0, delta=0.02)

        row1 = [Point(90, -0.1), Point(90, 0), Point(90, 0.1)]
        row2 = [Point(90, -0.1, 1), Point(90, 0, 1), Point(90, 0.1, 1)]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(dip, 90)
        assert_angles_equal(self, strike, 360, delta=1e-7)

        row1 = [Point(-90.1, -0.1), Point(-90, 0), Point(-89.9, 0.1)]
        row2 = [Point(-90.0, -0.1, 1), Point(-89.9, 0, 1),
                Point(-89.8, 0.1, 1)]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(strike, 45, delta=1e-4)

        row1 = [Point(-90.1, -0.1), Point(-90, 0), Point(-89.9, 0.1)]
        row2 = [Point(-90.0, -0.1, 1), Point(-89.9, 0, 1),
                Point(-89.8, 0.1, 1)]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(strike, 45, delta=1e-3)

        row1 = [Point(-90.1, -0.1), Point(-90, 0), Point(-89.9, 0.1)]
        row2 = [Point(-90.2, -0.1, 1), Point(-90.1, 0, 1), Point(-90, 0.1, 1)]
        mesh = RectangularMesh.from_points_list([row1, row2])
        dip, strike = mesh.get_mean_inclination_and_azimuth()
        self.assertAlmostEqual(strike, 225, delta=1e-3)
コード例 #4
0
 def _test_ruptures(self, expected_ruptures, source):
     tom = PoissonTOM(time_span=50)
     ruptures = list(source.iter_ruptures(tom))
     for rupture in ruptures:
         self.assertIsInstance(rupture, ProbabilisticRupture)
         self.assertIs(rupture.temporal_occurrence_model, tom)
         self.assertIs(rupture.tectonic_region_type, self.TRT)
         self.assertEqual(rupture.rake, self.RAKE)
     self.assertEqual(len(expected_ruptures), len(ruptures))
     for i in xrange(len(expected_ruptures)):
         expected_rupture, rupture = expected_ruptures[i], ruptures[i]
         self.assertAlmostEqual(rupture.mag, expected_rupture['mag'])
         self.assertAlmostEqual(rupture.rake, expected_rupture['rake'])
         self.assertAlmostEqual(rupture.occurrence_rate,
                                expected_rupture['occurrence_rate'])
         assert_mesh_is(self, rupture.surface,
                        expected_rupture['surface'])
         self.assertEqual(rupture.hypocenter,
                          Point(*expected_rupture['hypocenter']))
         assert_angles_equal(self, rupture.surface.get_strike(),
                             expected_rupture['strike'], delta=0.5)
         assert_angles_equal(self, rupture.surface.get_dip(),
                             expected_rupture['dip'], delta=3)