class CsvCatalogueParserTestCase(unittest.TestCase):
    """ Unit tests for the csv Catalogue Parser Class"""
    BASE_DATA_PATH = os.path.join(os.path.dirname(__file__), 'data')

    def setUp(self):
        self.gardner_knopoff_window = GardnerKnopoffWindow()
        self.gruenthal_window = GruenthalWindow()
        self.uhrhammer_window = UhrhammerWindow()

    def test_gardner_knopoff_window(self):
        """
        Test the Gardner and Knopoff Distance-Time window
        """
        mag = np.array([5.0, 6.6])
        sw_space, sw_time = self.gardner_knopoff_window.calc(mag)
        self.assertAlmostEqual(sw_space[0], 39.99447, places=5)
        self.assertAlmostEqual(sw_space[1], 63.10736, places=5)
        self.assertAlmostEqual(sw_time[0], 143.71430 / 364.75, places=5)
        self.assertAlmostEqual(sw_time[1], 891.45618 / 364.75, places=5)

    def test_gruenthal_window(self):
        """
        Test the Gruenthal Distance-Time window
        """
        mag = np.array([5.0, 6.6])
        sw_space, sw_time = self.gruenthal_window.calc(mag)
        #self.assertAlmostEqual(sw_space[0], 39.99447, places=5)
        #self.assertAlmostEqual(sw_time[0], 143.71430/364.75, places=5)
        #self.assertAlmostEqual(sw_space[1], 63.10736, places=5)
        #self.assertAlmostEqual(sw_time[1], 891.45618/364.75, places=5)

    def test_uhrhammer_window(self):
        mag = np.array([5.0, 6.6])
        sw_space, sw_time = self.uhrhammer_window.calc(mag)
class CsvCatalogueParserTestCase(unittest.TestCase):
    """ Unit tests for the csv Catalogue Parser Class"""
    BASE_DATA_PATH = os.path.join(os.path.dirname(__file__), 'data')

    def setUp(self):
        self.gardner_knopoff_window = GardnerKnopoffWindow()
        self.gruenthal_window = GruenthalWindow()
        self.uhrhammer_window = UhrhammerWindow()

    def test_gardner_knopoff_window(self):
        """
        Test the Gardner and Knopoff Distance-Time window
        """
        mag = np.array([5.0, 6.6])
        sw_space, sw_time = self.gardner_knopoff_window.calc(mag)
        self.assertAlmostEqual(sw_space[0], 39.99447, places=5)
        self.assertAlmostEqual(sw_space[1], 63.10736, places=5)
        self.assertAlmostEqual(sw_time[0], 143.71430 / 364.75, places=5)
        self.assertAlmostEqual(sw_time[1], 891.45618 / 364.75, places=5)

    def test_gruenthal_window(self):
        """
        Test the Gruenthal Distance-Time window
        """
        mag = np.array([5.0, 6.6])
        sw_space, sw_time = self.gruenthal_window.calc(mag)
        #self.assertAlmostEqual(sw_space[0], 39.99447, places=5)
        #self.assertAlmostEqual(sw_time[0], 143.71430/364.75, places=5)
        #self.assertAlmostEqual(sw_space[1], 63.10736, places=5)
        #self.assertAlmostEqual(sw_time[1], 891.45618/364.75, places=5)

    def test_uhrhammer_window(self):
        mag = np.array([5.0, 6.6])
        sw_space, sw_time = self.uhrhammer_window.calc(mag)
 def test_dec_gardner_knopoff(self):
     # Testing the Gardner and Knopoff algorithm
     config = {'time_distance_window': GardnerKnopoffWindow(),
               'fs_time_prop': 1.0}
     # Instantiate the declusterer and process the sample catalogue
     dec = GardnerKnopoffType1()
     vcl, flagvector = dec.decluster(self.cat, config)
     print('vcl:', vcl)
     print('flagvector:', flagvector, self.cat.data['flag'])
     np.testing.assert_allclose(flagvector, self.cat.data['flag'])
Example #4
0
 def test_dec_afteran(self):
     """
     Testing the Afteran algorithm
     """
     config = {
         'time_distance_window': GardnerKnopoffWindow(),
         'time_window': 60.}
     # Instantiate the declusterer and process the sample catalogue
     # self.dec = Afteran()
     print(dir(self.dec))
     vcl, flagvector = self.dec.decluster(self.cat, config)
     print('vcl:', vcl)
     print('flagvector:', flagvector, self.cat.data['flag'])
     self.assertTrue(np.allclose(flagvector, self.cat.data['flag']))
Example #5
0
 def test_dec_gardner_knopoff_time_cutoff(self):
     """
     Testing the Gardner and Knopoff algorithm using a cutoff
     time of 100 days
     """
     config = {'time_distance_window' : GardnerKnopoffWindow(),
               'fs_time_prop' : 1.0,
               'time_cutoff' : 100}
     # Instantiate the declusterer and process the sample catalogue
     dec = GardnerKnopoffType1()
     vcl, flagvector = dec.decluster(self.cat, config)
     print('vcl:', vcl)
     catalog_flag = self.cat.data['flag']
     catalog_flag[4] = 0 # event becomes mainshock when time_cutoff = 100
     print('flagvector:', catalog_flag)
     np.testing.assert_allclose(flagvector,self.cat.data['flag'])
 def setUp(self):
     self.gardner_knopoff_window = GardnerKnopoffWindow()
     self.gruenthal_window = GruenthalWindow()
     self.uhrhammer_window = UhrhammerWindow()
 def setUp(self):
     self.gardner_knopoff_window = GardnerKnopoffWindow()
     self.gruenthal_window = GruenthalWindow()
     self.uhrhammer_window = UhrhammerWindow()