当前位置: 首页>>代码示例>>Python>>正文


Python catalogue.Catalogue类代码示例

本文整理汇总了Python中hmtk.seismicity.catalogue.Catalogue的典型用法代码示例。如果您正苦于以下问题:Python Catalogue类的具体用法?Python Catalogue怎么用?Python Catalogue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Catalogue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        """
        """
        # Read initial dataset
        filename = os.path.join(self.BASE_DATA_PATH,
                                'completeness_test_cat.csv')
        test_data = np.genfromtxt(filename, delimiter=',', skip_header=1)
        # Create the catalogue A
        self.catalogueA = Catalogue.make_from_dict(
            {'year': test_data[:,3], 'magnitude': test_data[:,17]})

        # Read initial dataset
        filename = os.path.join(self.BASE_DATA_PATH,
                                'recurrence_test_cat_B.csv')
        test_data = np.genfromtxt(filename, delimiter=',', skip_header=1)
        # Create the catalogue A
        self.catalogueB = Catalogue.make_from_dict(
            {'year': test_data[:,3], 'magnitude': test_data[:,17]})

        # Read the verification table A
        filename = os.path.join(self.BASE_DATA_PATH,
                                'recurrence_table_test_A.csv')
        self.true_tableA = np.genfromtxt(filename, delimiter = ',')

        # Read the verification table A
        filename = os.path.join(self.BASE_DATA_PATH,
                                'recurrence_table_test_B.csv')
        self.true_tableB = np.genfromtxt(filename, delimiter = ',')
开发者ID:g-weatherill,项目名称:hmtk,代码行数:28,代码来源:utils_test.py

示例2: read_file

 def read_file(self):
     """
     """
     filedata = open(self.input_file, 'rU')
     catalogue = Catalogue()
     # Reading the data file
     data = csv.DictReader(filedata)
     # Parsing the data content
     for irow, row in enumerate(data):
         if irow == 0:
             valid_key_list = self._header_check(
                 row.keys(),
                 catalogue.TOTAL_ATTRIBUTE_LIST)
         for key in valid_key_list:
             if key in catalogue.FLOAT_ATTRIBUTE_LIST:
                 catalogue.data[key] = self._float_check(
                     catalogue.data[key],
                     row[key])
             elif key in catalogue.INT_ATTRIBUTE_LIST:
                 catalogue.data[key] = self._int_check(
                     catalogue.data[key],
                     row[key])
             else:
                 catalogue.data[key].append(row[key])
     catalogue.update_end_year()
     return catalogue
开发者ID:yetimote,项目名称:hmtk,代码行数:26,代码来源:csv_catalogue_parser.py

示例3: select_catalogue

    def select_catalogue(self, valid_id):
        '''
        Method to post-process the catalogue based on the selection options
        :param numpy.ndarray valid_id:
            Boolean vector indicating whether each event is selected (True)
            or not (False)

        :returns:
            Catalogue of selected events as instance of
            hmtk.seismicity.catalogue.Catalogue class
        '''
        if not np.any(valid_id):
            # No events selected - create clean instance of class
            output = Catalogue()
            output.processes = self.catalogue.processes

        elif np.all(valid_id):
            if self.copycat:
                output = deepcopy(self.catalogue)
            else:
                output = self.catalogue
        else:
            if self.copycat:
                output = deepcopy(self.catalogue)
            else:
                output = self.catalogue
            output.purge_catalogue(valid_id)
        return output
开发者ID:g-weatherill,项目名称:hmtk,代码行数:28,代码来源:selector.py

示例4: test_select_catalogue_rrup

    def test_select_catalogue_rrup(self):
        """
        Tests catalogue selection with Joyner-Boore distance
        """
        self.fault = mtkActiveFault(
            '001',
            'A Fault',
            self.simple_fault,
            [(5., 0.5), (7., 0.5)],
            0.,
            None,
            msr_sigma=[(-1.5, 0.15), (0., 0.7), (1.5, 0.15)])

        cat1 = Catalogue()
        cat1.data = {"eventID": ["001", "002", "003", "004"],
                     "longitude": np.array([30.1, 30.1, 30.5, 31.5]),
                     "latitude": np.array([30.0, 30.25, 30.4, 30.5]),
                     "depth": np.array([5.0, 250.0, 10.0, 10.0])}
        selector = CatalogueSelector(cat1)
        # Select within 50 km of the fault
        self.fault.select_catalogue(selector, 50.0,
                                    distance_metric="rupture")
        np.testing.assert_array_almost_equal(
            self.fault.catalogue.data["longitude"],
            np.array([30.1, 30.5]))
        np.testing.assert_array_almost_equal(
            self.fault.catalogue.data["latitude"],
            np.array([30.0, 30.4]))
        np.testing.assert_array_almost_equal(
            self.fault.catalogue.data["depth"],
            np.array([5.0, 10.0]))
开发者ID:g-weatherill,项目名称:hmtk,代码行数:31,代码来源:test_fault_model.py

示例5: TestMagnitudeTimeDistribution

class TestMagnitudeTimeDistribution(unittest.TestCase):
    """
    Simple class to test the magnitude time density distribution
    """
    def setUp(self):
        self.catalogue = Catalogue()
        x, y = np.meshgrid(np.arange(1915., 2010., 10.),
                           np.arange(5.5, 9.0, 1.0))
        nx, ny = np.shape(x)
        self.catalogue.data['magnitude'] = (y.reshape([nx * ny, 1])).flatten()
        x = (x.reshape([nx * ny, 1])).flatten()
        self.catalogue.data['year'] = x.astype(int)
        self.catalogue.data['month'] = np.ones_like(x, dtype=int)
        self.catalogue.data['day'] = np.ones_like(x, dtype=int)
        self.catalogue.data['hour'] = np.ones_like(x, dtype=int)
        self.catalogue.data['minute'] = np.ones_like(x, dtype=int)
        self.catalogue.data['second'] = np.ones_like(x, dtype=float)

    def test_magnitude_time_distribution_no_uncertainties(self):
        # Tests the magnitude-depth distribution without uncertainties
        mag_range = np.arange(5., 10., 1.)
        time_range = np.arange(1910., 2020., 10.)
        # Without normalisation
        expected_array = np.ones([len(time_range) - 1, len(mag_range) - 1],
                                 dtype=float)
        np.testing.assert_array_almost_equal(
            expected_array,
            self.catalogue.get_magnitude_time_distribution(
                mag_range, time_range))
        # With Normalisation
        np.testing.assert_array_almost_equal(
            expected_array / np.sum(expected_array),
            self.catalogue.get_magnitude_time_distribution(
                mag_range, time_range, normalisation=True))
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:34,代码来源:catalogue_test.py

示例6: test_hypocentres_as_mesh

 def test_hypocentres_as_mesh(self):
     # Tests the function to render the hypocentres to a
     # hazardlib.geo.mesh.Mesh object.
     cat = Catalogue()
     cat.data['longitude'] = np.array([2., 3.])
     cat.data['latitude'] = np.array([2., 3.])
     cat.data['depth'] = np.array([2., 3.])
     self.assertTrue(isinstance(cat.hypocentres_as_mesh(), Mesh))
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:8,代码来源:catalogue_test.py

示例7: test_load_from_array

 def test_load_from_array(self):
     # Tests the creation of a catalogue from an array and a key list
     cat = Catalogue()
     cat.load_from_array(['year', 'magnitude'], self.data_array)
     np.testing.assert_allclose(cat.data['magnitude'],
                                self.data_array[:, 1])
     np.testing.assert_allclose(cat.data['year'],
                                self.data_array[:, 0].astype(int))
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:8,代码来源:catalogue_test.py

示例8: test_load_to_array

 def test_load_to_array(self):
     """
     Tests the creation of a catalogue from an array and a key list 
     """
     cat = Catalogue()
     cat.load_from_array(['year','magnitude'], self.data_array)
     data = cat.load_to_array(['year','magnitude'])
     self.assertTrue(np.allclose(data, self.data_array))
开发者ID:julgp,项目名称:hmtk,代码行数:8,代码来源:catalogue_test.py

示例9: test_load_from_array

 def test_load_from_array(self):
     """
     Tests the creation of a catalogue from an array and a key list 
     """
     cat = Catalogue()
     cat.load_from_array(['year','magnitude'], self.data_array)
     self.assertTrue(np.allclose(cat.data['magnitude'],self.data_array[:,1]))
     self.assertTrue(np.allclose(cat.data['year'],
                                 self.data_array[:,0].astype(int)))
开发者ID:julgp,项目名称:hmtk,代码行数:9,代码来源:catalogue_test.py

示例10: test_catalogue_mt_filter

 def test_catalogue_mt_filter(self):
     """
     Tests the catalogue magnitude-time filter
     """
     cat = Catalogue()
     cat.load_from_array(['year','magnitude'], self.data_array)
     cat.catalogue_mt_filter(self.mt_table)
     mag = np.array([7.0, 5.5, 5.01, 6.99])
     yea = np.array([1920, 1970, 1960, 1960])
     self.assertTrue(np.allclose(cat.data['magnitude'],mag))
     self.assertTrue(np.allclose(cat.data['year'],yea))
     
开发者ID:juliogarciagem,项目名称:hmtk,代码行数:11,代码来源:catalogue_test.py

示例11: test_get_bounding_box

 def test_get_bounding_box(self):
     """
     Tests the method to return the bounding box of a catalogue
     """
     cat1 = Catalogue()
     cat1.data["longitude"] = np.array([10.0, 20.0])
     cat1.data["latitude"] = np.array([40.0, 50.0])
     bbox = cat1.get_bounding_box()
     self.assertAlmostEqual(bbox[0], 10.0)
     self.assertAlmostEqual(bbox[1], 20.0)
     self.assertAlmostEqual(bbox[2], 40.0)
     self.assertAlmostEqual(bbox[3], 50.0)
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:12,代码来源:catalogue_test.py

示例12: test_hypocentres_to_cartesian

 def test_hypocentres_to_cartesian(self):
     # Tests the function to render the hypocentres to a cartesian array.
     # The invoked function nhlib.geo.utils.spherical_to_cartesian is
     # tested as part of the nhlib suite. The test here is included for
     # coverage
     cat = Catalogue()
     cat.data['longitude'] = np.array([2., 3.])
     cat.data['latitude'] = np.array([2., 3.])
     cat.data['depth'] = np.array([2., 3.])
     expected_data = spherical_to_cartesian(cat.data['longitude'],
                                            cat.data['latitude'],
                                            cat.data['depth'])
     model_output = cat.hypocentres_to_cartesian()
     np.testing.assert_array_almost_equal(expected_data, model_output)
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:14,代码来源:catalogue_test.py

示例13: setUp

    def setUp(self):
        cat1 = Catalogue()
        cat1.end_year = 2000
        cat1.start_year = 1900
        cat1.data['eventID'] = [1.0, 2.0, 3.0]
        cat1.data['magnitude'] = np.array([1.0, 2.0, 3.0])

        cat2 = Catalogue()
        cat2.end_year = 1990
        cat2.start_year = 1910
        cat2.data['eventID'] = [1.0, 2.0, 3.0]
        cat2.data['magnitude'] = np.array([1.0, 2.0, 3.0])

        self.cat1 = cat1
        self.cat2 = cat2
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:15,代码来源:catalogue_test.py

示例14: test_kijko_smit_set_reference_magnitude

 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)
开发者ID:GEMScienceTools,项目名称:hmtk,代码行数:7,代码来源:kijko_smit_test.py

示例15: test_select_within_depth_range

    def test_select_within_depth_range(self):
        '''
        Tests the function to select within the depth range
        '''
        # Setup function
        self.catalogue = Catalogue()
        self.catalogue.data['depth'] = np.array([5., 15., 25., 35., 45.])

        selector0 = CatalogueSelector(self.catalogue)
        # Test case 1: No limits specified - all catalogue valid
        test_cat_1 = selector0.within_depth_range()
        np.testing.assert_array_almost_equal(test_cat_1.data['depth'],
                                             self.catalogue.data['depth'])

        # Test case 2: Lower depth limit specfied only
        test_cat_1 = selector0.within_depth_range(lower_depth=30.)
        np.testing.assert_array_almost_equal(test_cat_1.data['depth'],
                                             np.array([5., 15., 25.]))
        # Test case 3: Upper depth limit specified only
        test_cat_1 = selector0.within_depth_range(upper_depth=20.)
        np.testing.assert_array_almost_equal(test_cat_1.data['depth'],
                                             np.array([25., 35., 45.]))

        # Test case 4: Both depth limits specified
        test_cat_1 = selector0.within_depth_range(upper_depth=20., 
                                                  lower_depth=40.)
        np.testing.assert_array_almost_equal(test_cat_1.data['depth'],
                                             np.array([25., 35.]))
开发者ID:atalayayele,项目名称:hmtk,代码行数:28,代码来源:test_selector.py


注:本文中的hmtk.seismicity.catalogue.Catalogue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。