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


Python catalogue.Catalogue类代码示例

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


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

示例1: 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:gem,项目名称:oq-hazardlib,代码行数:34,代码来源:catalogue_test.py

示例2: 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:gem,项目名称:oq-hazardlib,代码行数:28,代码来源:utils_test.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
            openquake.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:digitalsatori,项目名称:oq-engine,代码行数:29,代码来源: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:gem,项目名称:oq-hazardlib,代码行数:31,代码来源:test_fault_model.py

示例5: 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:gem,项目名称:oq-hazardlib,代码行数:8,代码来源: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:gem,项目名称:oq-hazardlib,代码行数:8,代码来源:catalogue_test.py

示例7: 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:gem,项目名称:oq-hazardlib,代码行数:12,代码来源:catalogue_test.py

示例8: 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:gem,项目名称:oq-hazardlib,代码行数:14,代码来源:catalogue_test.py

示例9: 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:gem,项目名称:oq-hazardlib,代码行数:15,代码来源:catalogue_test.py

示例10: setUp

 def setUp(self):
     """
     This generates a minimum data-set to be used for the regression.
     """
     # Test A: Generates a data set assuming b=1 and N(m=4.0)=10.0 events
     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
     self.numobs = np.flipud(
         np.diff(np.flipud(10.0 ** (-self.bval * mext + 8.0))))
     # Test B: Generate a completely artificial catalogue using the
     # Gutenberg-Richter distribution defined above
     numobs = np.around(self.numobs)
     size = int(np.sum(self.numobs))
     magnitude = np.zeros(size)
     lidx = 0
     for mag, nobs in zip(self.mval, numobs):
         uidx = int(lidx + nobs)
         magnitude[lidx:uidx] = mag + 0.01
         lidx = uidx
     year = np.ones(size) * 1999
     self.catalogue = Catalogue.make_from_dict(
         {'magnitude': magnitude, 'year': year})
     # Create the seismicity occurrence calculator
     self.aki_ml = AkiMaxLikelihood()
开发者ID:digitalsatori,项目名称:oq-engine,代码行数:26,代码来源:aki_maximum_likelihood_test.py

示例11: test_select_within_magnitude_range

    def test_select_within_magnitude_range(self):
        '''
        Tests the function to select within the magnitude range
        '''
        # Setup function
        self.catalogue = Catalogue()
        self.catalogue.data['magnitude'] = np.array([4., 5., 6., 7., 8.])

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

        # Test case 2: Lower depth limit specfied only
        test_cat_1 = selector0.within_magnitude_range(lower_mag=5.5)
        np.testing.assert_array_almost_equal(test_cat_1.data['magnitude'],
                                             np.array([6., 7., 8.]))
        # Test case 3: Upper depth limit specified only
        test_cat_1 = selector0.within_magnitude_range(upper_mag=5.5)
        np.testing.assert_array_almost_equal(test_cat_1.data['magnitude'],
                                             np.array([4., 5.]))

        # Test case 4: Both depth limits specified
        test_cat_1 = selector0.within_magnitude_range(upper_mag=7.5,
                                                      lower_mag=5.5)
        np.testing.assert_array_almost_equal(test_cat_1.data['magnitude'],
                                             np.array([6., 7.]))
开发者ID:gem,项目名称:oq-hazardlib,代码行数:28,代码来源:test_selector.py

示例12: 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:gem,项目名称:oq-hazardlib,代码行数:7,代码来源:kijko_smit_test.py

示例13: 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:gem,项目名称:oq-hazardlib,代码行数:27,代码来源:test_selector.py

示例14: test_input_checks_use_reference_magnitude

 def test_input_checks_use_reference_magnitude(self):
     fake_completeness_table = 0.0
     catalogue = Catalogue.make_from_dict({'year': [1900]})
     config = {'reference_magnitude' : 3.0}
     cmag, ctime, ref_mag, dmag, _ = rec_utils.input_checks(catalogue,
             config, fake_completeness_table)
     self.assertEqual(3.0, ref_mag)
开发者ID:gem,项目名称:oq-hazardlib,代码行数:7,代码来源:utils_test.py

示例15: test_input_checks_sets_magnitude_interval

 def test_input_checks_sets_magnitude_interval(self):
     fake_completeness_table = 0.0
     catalogue = Catalogue.make_from_dict({'year': [1900]})
     config = {'magnitude_interval' : 0.1}
     cmag, ctime, ref_mag, dmag, _ = rec_utils.input_checks(catalogue,
             config, fake_completeness_table)
     self.assertEqual(0.1, dmag)
开发者ID:gem,项目名称:oq-hazardlib,代码行数:7,代码来源:utils_test.py


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