Ejemplo n.º 1
0
 def test_get_mfd(self):
     '''
     Tests the main function to get the magnitude frequency distribution
     '''
     self.model = YoungsCoppersmithExponential() 
     self.config = {'MFD_spacing': 0.1,
                    'Maximum_Magnitude': 8.0,
                    'Maximum_Magnitude_Uncertainty': None,
                    'Minimum_Magnitude': 5.0,
                    'Model_Weight': 1.0,
                    'b_value': [1.0, 0.1]}
     self.model.setUp(self.config)
     # Same fault case as for test_cumulative_value - now comparing incremenetal
     # rates
     self.model.get_mmax(self.config, self.msr, 0., 7200.)
     output1 = self.model.get_mfd(1.0, 7200.)
     np.testing.assert_array_almost_equal(YC_EXP_DATA[:, 2], output1[2])
     
     # Test case for when b > 1.5 - should produce array of NaN
     self.model = YoungsCoppersmithExponential() 
     self.config['b_value'] = [1.6, 0.1]
     self.model.setUp(self.config)
     self.model.get_mmax(self.config, self.msr, 0., 7200.)
     _, _, _ = self.model.get_mfd(1.0, 7200.)
     self.assertTrue(np.all(np.isnan(self.model.occurrence_rate)))
Ejemplo n.º 2
0
    def test_get_mmax(self):
        '''
        Tests the function to get Mmax
        Values come from WC1994 (tested in openquake.hazardlib) - only 
        functionality is tested for here!
        '''
        # Case 1 MMmax and uncertainty specified in config
        self.config['Maximum_Magnitude'] = 8.0
        self.config['Maximum_Magnitude_Uncertainty'] = 0.2

        self.model = YoungsCoppersmithExponential()
        self.model.setUp(self.config)
        self.model.get_mmax(self.config, self.msr, 0., 8500.)
        self.assertAlmostEqual(self.model.mmax, 8.0)
        self.assertAlmostEqual(self.model.mmax_sigma, 0.2)

        # Case 2: Mmax and uncertainty not specified in config
        self.config['Maximum_Magnitude'] = None
        self.config['Maximum_Magnitude_Uncertainty'] = None
         
        self.model = YoungsCoppersmithExponential()
        self.model.setUp(self.config)
        self.model.get_mmax(self.config, self.msr, 0., 8500.)
        self.assertAlmostEqual(self.model.mmax, 7.9880073)
        self.assertAlmostEqual(self.model.mmax_sigma, 0.23)
Ejemplo n.º 3
0
 def test_cumulative_value(self):
     '''
     Tests the calculation of the cumulative rate M > Mref
     Data and tests taken from Bungum (2007). Current parameters should 
     reproduce Model 4 line in Figure 1 of Bungum (2007)
     '''
     self.model = YoungsCoppersmithExponential() 
     self.config = {'MFD_spacing': 0.1,
                    'Maximum_Magnitude': 8.0,
                    'Maximum_Magnitude_Uncertainty': None,
                    'Minimum_Magnitude': 5.0,
                    'Model_Weight': 1.0,
                    'b_value': [1.0, 0.1]}
     
     # Test case 1 - Fault of 120 km length and 60 km width (7200 km ** 2 area)
     # b-value 1, slip = 1 mm/yr
     self.model.setUp(self.config)
     self.model.get_mmax(self.config, self.msr, 0., 7200.)
     moment_rate = (30. * 1E9) * (7200. * 1E6) * (1.0 / 1000.)
     momax = _scale_moment(self.model.mmax, in_nm=True)
     beta = log(10.)
     expected_result = YC_EXP_DATA[:, 1]
     mags = np.arange(5.0, 8.1, 0.1)
     for iloc, mag in enumerate(mags):
         self.assertAlmostEqual(
             expected_result[iloc],
             self.model.cumulative_value(mag, moment_rate, beta, momax))
Ejemplo n.º 4
0
 def test_return_oq_mfd(self):
     """
     Tests the function to return the mfd as an instance of the openquake
     EvenlyDiscretizedMFD class
     """
     self.model = YoungsCoppersmithExponential()
     self.config = {
         'MFD_spacing': 0.1,
         'Maximum_Magnitude': 8.0,
         'Maximum_Magnitude_Uncertainty': None,
         'Minimum_Magnitude': 5.0,
         'Model_Weight': 1.0,
         'b_value': [1.0, 0.1]
     }
     self.model.setUp(self.config)
     # Same fault case as for test_cumulative_value - now comparing incremenetal
     # rates
     self.model.get_mmax(self.config, self.msr, 0., 7200.)
     _ = self.model.get_mfd(1.0, 7200.)
     oq_mfd = self.model.to_evenly_discretized_mfd()
     self.assertTrue(isinstance(oq_mfd, EvenlyDiscretizedMFD))
     self.assertAlmostEqual(oq_mfd.min_mag, 5.05)
     self.assertAlmostEqual(oq_mfd.bin_width, 0.1)
     np.testing.assert_array_almost_equal(YC_EXP_DATA[:, 2],
                                          np.array(oq_mfd.occurrence_rates))
Ejemplo n.º 5
0
 def setUp(self):
     '''
     '''
     self.model = YoungsCoppersmithExponential()
     self.msr = WC1994()
     self.config = {'MFD_spacing': 0.1,
                    'Maximum_Magnitude': 8.0,
                    'Maximum_Magnitude_Uncertainty': None,
                    'Minimum_Magnitude': 5.0,
                    'Model_Weight': 1.0,
                    'b_value': [1.0, 0.1]}