Beispiel #1
0
 def test_simple_fault_rate_out_of_magnitude_range(self):
     """
     Tests the simple fault rates out of the magnitude range
     """
     rate_grid1 = RateGrid(self.limits, [SIMPLE_FAULT],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     rate_grid1.get_rates(6.0, 6.5)
     np.testing.assert_array_almost_equal(rate_grid1.rates, expected_rates)
Beispiel #2
0
 def test_point_rate_out_of_limits(self):
     """
     Tests the point rates when the point is outside the limits
     """
     rate_grid1 = RateGrid(self.limits, [OUTSIDE_POINT_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     rate_grid1.get_rates(5.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates, expected_rates)
Beispiel #3
0
 def test_simple_fault_rate_out_of_magnitude_range(self):
     """
     Tests the simple fault rates out of the magnitude range
     """
     rate_grid1 = RateGrid(self.limits, [SIMPLE_FAULT],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     rate_grid1.get_rates(6.0, 6.5)
     np.testing.assert_array_almost_equal(rate_grid1.rates,
                                          expected_rates)
Beispiel #4
0
 def test_point_rate_out_of_limits(self):
     """
     Tests the point rates when the point is outside the limits
     """
     rate_grid1 = RateGrid(self.limits, [OUTSIDE_POINT_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     rate_grid1.get_rates(5.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates,
                                          expected_rates)
Beispiel #5
0
 def test_area_rate(self):
     """
     Tests the area rates
     """
     rate_grid1 = RateGrid(self.limits, [AREA_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     expected_rates[:, 0, :] = 1.0 / 12.0
     expected_rates[:, 1, :] = 2.0 / 12.0
     rate_grid1.get_rates(5.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates, expected_rates)
Beispiel #6
0
 def test_area_rate(self):
     """
     Tests the area rates
     """
     rate_grid1 = RateGrid(self.limits, [AREA_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     expected_rates[:, 0, :] = 1.0 / 12.0
     expected_rates[:, 1, :] = 2.0 / 12.0
     rate_grid1.get_rates(5.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates,
                                          expected_rates)
Beispiel #7
0
 def test_characteristic_fault_rate(self):
     """
     Tests the simple fault rates
     """
     rate_grid1 = RateGrid(self.limits, [CHARACTERISTIC_FAULT],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     expected_rates[:, :, 0] = np.array([[10., 20.], [0., 30.]])
     expected_rates[:, :, 1] = np.array([[11., 22.], [0., 33.]])
     rate_grid1.get_rates(6.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates,
                                          expected_rates / 126.0)
Beispiel #8
0
 def test_characteristic_fault_rate(self):
     """
     Tests the simple fault rates
     """
     rate_grid1 = RateGrid(self.limits, [CHARACTERISTIC_FAULT],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     expected_rates[:, :, 0] = np.array([[10., 20.],
                                         [0., 30.]])
     expected_rates[:, :, 1] = np.array([[11., 22.],
                                         [0., 33.]])
     rate_grid1.get_rates(6.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates,
                                          expected_rates / 126.0)
Beispiel #9
0
 def test_source_input_equivalence(self):
     """
     Verify that the same source model gives the same rate grid results
     when input as a source model or as an xml
     """
     ratemodel1 = RateGrid(self.limits, [
         POINT_SOURCE, AREA_SOURCE, SIMPLE_FAULT, COMPLEX_FAULT,
         CHARACTERISTIC_FAULT,
         Dummy("Rubbish")
     ],
                           area_discretisation=4.0)
     ratemodel2 = RateGrid.from_model_files(self.limits,
                                            SOURCE_MODEL_FILE,
                                            complex_mesh_spacing=1.0,
                                            area_discretisation=4.0)
     ratemodel1.get_rates(5.0)
     ratemodel2.get_rates(5.0)
     np.testing.assert_array_almost_equal(ratemodel1.rates,
                                          ratemodel2.rates)
Beispiel #10
0
 def test_source_input_equivalence(self):
     """
     Verify that the same source model gives the same rate grid results
     when input as a source model or as an xml
     """
     ratemodel1 = RateGrid(self.limits,
                           [POINT_SOURCE,
                            AREA_SOURCE,
                            SIMPLE_FAULT,
                            COMPLEX_FAULT,
                            CHARACTERISTIC_FAULT,
                            Dummy("Rubbish")],
                           area_discretisation=4.0)
     ratemodel2 = RateGrid.from_model_files(self.limits,
                                            SOURCE_MODEL_FILE,
                                            complex_mesh_spacing=1.0,
                                            area_discretisation=4.0)
     ratemodel1.get_rates(5.0)
     ratemodel2.get_rates(5.0)
     np.testing.assert_array_almost_equal(ratemodel1.rates,
                                          ratemodel2.rates)
Beispiel #11
0
 def test_point_rate_simple(self):
     """
     Tests the point rates when the point is inside the limits
     """
     rate_grid1 = RateGrid(self.limits, [POINT_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     expected_rates[1, 1, 0] = 1.0
     rate_grid1.get_rates(5.0)
     np.testing.assert_array_almost_equal(rate_grid1.rates,
                                          expected_rates)
     # Tests the case when Mmin is outside the magnitude range
     rate_grid2 = RateGrid(self.limits, [POINT_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     rate_grid2.get_rates(6.0)
     np.testing.assert_array_almost_equal(rate_grid2.rates,
                                          expected_rates)
     # Tests the case when Mmax is set below the rate of the source
     rate_grid3 = RateGrid(self.limits, [POINT_SOURCE],
                           area_discretisation=4.0)
     expected_rates = np.zeros([2, 2, 2])
     rate_grid3.get_rates(4.0, 4.5)
     np.testing.assert_array_almost_equal(rate_grid3.rates,
                                          expected_rates)