示例#1
0
    def testcase01(self):
        """
        Testing TR change from crustal to stable crustal
        """
        ini_fname = os.path.join(BASE_PATH, '../../data/tr/acr_scr.ini')
        cat = os.path.join(BASE_PATH, '../../data/tr/catalogue.pkl')
        treg_filename = os.path.join(BASE_PATH, '../../tmp/test02.hdf5')
        event_change = os.path.join(BASE_PATH, '../../data/tr/ev_change.csv')
        #
        # classify
        classify(ini_fname, True, self.root_folder)
        f = h5py.File(treg_filename, 'r')
        #
        # manually change an event
        change(cat, treg_filename, event_change)

        # testing new file to see if the swap worked
        treg_filename2 = os.path.join(BASE_PATH, '../../tmp/test02_up.hdf5')
        f2 = h5py.File(treg_filename2, 'r')

        expected = [1, 0, 0, 0, 0]
        numpy.testing.assert_array_equal(f2['crustal_active'][:], expected)
        #
        # testing crustal stable
        expected = [0, 0, 1, 0, 1]
        numpy.testing.assert_array_equal(f2['crustal_stable'][:], expected)
        #
        f.close()
示例#2
0
 def testcase01(self):
     """
     Testing TR - Case 02 - Crustal and Subduction
     """
     tmps = '../../data/tr02/cls_v2_1500_2017.ini'
     ini_fname = os.path.join(BASE_PATH, tmps)
     tmps = '../../tmp/SARA_V2_1500_2017_nc.hdf5'
     treg_filename = os.path.join(BASE_PATH, tmps)
     #
     # classify
     classify(ini_fname, True, self.root_folder)
     f = h5py.File(treg_filename, 'r')
     #
     # testing crustal active
     expected = [1, 1, 0, 0, 0, 0, 0, 0, 0]
     numpy.testing.assert_array_equal(f['crustal'][:], expected)
     #
     # testing subduction interface 1
     expected = [0, 0, 0, 0, 0, 0, 1, 0, 0]
     numpy.testing.assert_array_equal(f['interface_1'][:], expected)
     #
     # testing subduction interface 4a
     expected = [0, 0, 0, 0, 0, 0, 0, 1, 1]
     numpy.testing.assert_array_equal(f['interface_4a'][:], expected)
     #
     f.close()
示例#3
0
 def testcase01(self):
     """
     Testing TR for an idealized case - only crustal
     """
     ini_fname = os.path.join(BASE_PATH, '../../data/tr/only_crustal.ini')
     treg_filename = os.path.join(BASE_PATH, '../../tmp/test01.hdf5')
     #
     # classify
     classify(ini_fname, True, self.root_folder)
     #
     #
     f = h5py.File(treg_filename, 'r')
     numpy.testing.assert_array_equal(f['crustal'][:], [1, 0, 1, 0, 1])
     f.close()
示例#4
0
 def testcase02(self):
     """
     Testing TR for an idealized case - stable and active crust
     """
     ini_fname = os.path.join(BASE_PATH, '../../data/tr/acr_scr.ini')
     treg_filename = os.path.join(BASE_PATH, '../../tmp/test02.hdf5')
     #
     # classify
     classify(ini_fname, True, self.root_folder)
     f = h5py.File(treg_filename, 'r')
     #
     # testing crustal active
     expected = [1, 0, 1, 0, 0]
     numpy.testing.assert_array_equal(f['crustal_active'][:], expected)
     #
     # testing crustal stable
     expected = [0, 0, 0, 0, 1]
     numpy.testing.assert_array_equal(f['crustal_stable'][:], expected)
     #
     f.close()
示例#5
0
 def testcase01(self):
     """
     Testing TR
     """
     ini_fname = os.path.join(BASE_PATH, '../../data/tr01/tr01.ini')
     treg_filename = os.path.join(BASE_PATH, '../../tmp/test02.hdf5')
     #
     # classify
     classify(ini_fname, True, self.root_folder)
     f = h5py.File(treg_filename, 'r')
     #
     # testing crustal active
     expected = [1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]
     numpy.testing.assert_array_equal(f['crustal'][:], expected)
     #
     # testing interface
     expected = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0]
     numpy.testing.assert_array_equal(f['int_cam'][:], expected)
     #
     # testing slab
     expected = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1]
     numpy.testing.assert_array_equal(f['slab_cam'][:], expected)
     #
     f.close()
示例#6
0
def clssfy(ini_fname, compute_distances, rootf):
    """
    Classify an earthquake catalogue
    """
    classify(ini_fname, compute_distances, rootf)