Exemple #1
0
class KijkoSmitTest(unittest.TestCase):
    def setUp(self):
        """
        This generates a catalogue to be used for the regression.
        """
        # Generates a data set assuming b=1
        self.dmag = 0.1
        mext = np.arange(4.0, 7.01, 0.1)
        self.mval = mext[0:-1] + self.dmag / 2.0
        self.bval = 1.0
        numobs = np.flipud(np.diff(np.flipud(10.0**(-self.bval * mext + 7.0))))

        # Define completeness window
        numobs[0:6] *= 10
        numobs[6:13] *= 20
        numobs[13:22] *= 50
        numobs[22:] *= 100

        compl = np.array([[1900, 1950, 1980, 1990], [6.34, 5.44, 4.74, 3.0]])
        self.compl = np.flipud(compl.transpose())
        numobs = np.around(numobs)

        magnitude = np.zeros((np.sum(numobs)))
        year = np.zeros((np.sum(numobs))) * 1999

        lidx = 0
        for mag, nobs in zip(self.mval, numobs):
            uidx = int(lidx + nobs)
            magnitude[lidx:uidx] = mag + 0.01
            year_low = compl[0, np.min(np.nonzero(compl[1, :] < mag)[0])]
            year[lidx:uidx] = (year_low + np.random.rand(uidx - lidx) *
                               (2000 - year_low))
            lidx = uidx

        self.catalogue = Catalogue.make_from_dict({
            'magnitude': magnitude,
            'year': year
        })
        self.ks_ml = KijkoSmit()
        self.config = {'Average Type': 'Weighted'}

    def test_kijko_smit_maximum_likelihood(self):
        """
        Tests that the computed b value corresponds to the same value
        used to generate the test data set
        """
        bval, sigma_b, aval, sigma_a = self.ks_ml.calculate(
            self.catalogue, self.config, self.compl)
        print bval, sigma_b
        self.assertAlmostEqual(self.bval, bval, 1)

    def test_kijko_smit_set_reference_magnitude(self):
        completeness_table = np.array([[1900, 1.0]])
        catalogue = Catalogue.make_from_dict({
            'magnitude': np.array([5.0, 6.0]),
            'year': np.array([2000, 2000])
        })
        config = {'reference_magnitude': 0.0}
        self.ks_ml.calculate(catalogue, config, completeness_table)
class KijkoSmitTest(unittest.TestCase):

    def setUp(self):
        """
        This generates a catalogue to be used for the regression.
        """
        # Generates a data set assuming b=1
        self.dmag = 0.1
        mext = np.arange(4.0,7.01,0.1)
        self.mval = mext[0:-1] + self.dmag / 2.0
        self.bval = 1.0
        numobs = np.flipud(np.diff(np.flipud(10.0**(-self.bval*mext+7.0))))

        # Define completeness window
        numobs[0:6] *= 10
        numobs[6:13] *= 20
        numobs[13:22] *= 50
        numobs[22:] *= 100

        compl = np.array([[1900, 1950, 1980, 1990], [6.34, 5.44, 4.74, 3.0]])
        self.compl = np.flipud(compl.transpose())
        numobs = np.around(numobs)

        magnitude = np.zeros(int(np.sum(numobs)))
        year = np.zeros(int(np.sum(numobs))) * 1999

        lidx = 0
        for mag, nobs in zip(self.mval, numobs):
            uidx = int(lidx+nobs)
            magnitude[lidx:uidx] = mag + 0.01
            year_low = compl[0, np.min(np.nonzero(compl[1, :] < mag)[0])]
            year[lidx:uidx] = (year_low + np.random.rand(uidx-lidx) *
                               (2000-year_low))
            lidx = uidx

        self.catalogue = Catalogue.make_from_dict(
            {'magnitude': magnitude, 'year': year})
        self.ks_ml = KijkoSmit()
        self.config = {'Average Type': 'Weighted'}

    def test_kijko_smit_maximum_likelihood(self):
        """
        Tests that the computed b value corresponds to the same value
        used to generate the test data set
        """
        bval, sigma_b, aval, sigma_a = self.ks_ml.calculate(
            self.catalogue, self.config, self.compl)
        print(bval, sigma_b)
        self.assertAlmostEqual(self.bval, bval, 1)

    def test_kijko_smit_set_reference_magnitude(self):
        completeness_table = np.array([[1900, 1.0]])
        catalogue = Catalogue.make_from_dict(
            {'magnitude': np.array([5.0, 6.0]),
             'year': np.array([2000, 2000])})
        config = {'reference_magnitude': 0.0}
        self.ks_ml.calculate(catalogue, config, completeness_table)
Exemple #3
0
# In[ ]:

# Set up the configuration parameters
bwc_recurrence = Weichert()

bval, sigmab, seismicity_rate, sigma_rate = bwc_recurrence.calculate(catalogue, 
                                                          recurrence_config, 
                                                          completeness_table)

print 'B-value = %9.4f +/- %9.4f' %(bval, sigmab)
print 'Rate = %9.4f +/- %9.4f' %(seismicity_rate, sigma_rate)


# In[ ]:
# In[ ]:

# Set up the configuration parameters
bks_recurrence = KijkoSmit()
 
bval, sigmab, seismicity_rate, sigma_rate = bks_recurrence.calculate(catalogue, 
                                                          recurrence_config, 
                                                          completeness_table)
 
print 'B-value = %9.4f +/- %9.4f' % (bval, sigmab)
print 'Rate (M >= 4.0) = %9.4f +/- %9.4f' % (seismicity_rate, sigma_rate)




Exemple #4
0
bml_recurrence = BMaxLikelihood()

bval, sigmab, seismicity_rate, sigma_rate = bml_recurrence.calculate(
    catalogue, recurrence_config, completeness_table)

print 'B-value = %9.4f +/- %9.4f' % (bval, sigmab)
print 'Rate = %9.4f +/- %9.4f' % (seismicity_rate, sigma_rate)

# In[ ]:

# Set up the configuration parameters
bwc_recurrence = Weichert()

bval, sigmab, seismicity_rate, sigma_rate = bwc_recurrence.calculate(
    catalogue, recurrence_config, completeness_table)

print 'B-value = %9.4f +/- %9.4f' % (bval, sigmab)
print 'Rate = %9.4f +/- %9.4f' % (seismicity_rate, sigma_rate)

# In[ ]:
# In[ ]:

# Set up the configuration parameters
bks_recurrence = KijkoSmit()

bval, sigmab, seismicity_rate, sigma_rate = bks_recurrence.calculate(
    catalogue, recurrence_config, completeness_table)

print 'B-value = %9.4f +/- %9.4f' % (bval, sigmab)
print 'Rate (M >= 4.0) = %9.4f +/- %9.4f' % (seismicity_rate, sigma_rate)