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


Python SiteCollection.indices方法代码示例

本文整理汇总了Python中openquake.hazardlib.site.SiteCollection.indices方法的典型用法代码示例。如果您正苦于以下问题:Python SiteCollection.indices方法的具体用法?Python SiteCollection.indices怎么用?Python SiteCollection.indices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openquake.hazardlib.site.SiteCollection的用法示例。


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

示例1: test_sites_of_interest

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import indices [as 别名]
    def test_sites_of_interest(self):
        calc = hazard_getters.GroundMotionValuesCalcGetter(
            self.imt, self.sites, self.sites_assets, 0, self.gsims, None)

        r = ProbabilisticRupture(
            mag=5.5,
            rake=123.45,
            tectonic_region_type=mock.Mock(),
            hypocenter=Point(5, 6, 7),
            surface=PlanarSurface(10, 11, 12,
                                  Point(0, 0, 1), Point(1, 0, 1),
                                  Point(1, 0, 2), Point(0, 0, 2)
                                  ),
            occurrence_rate=1,
            temporal_occurrence_model=mock.Mock(),
            source_typology=mock.Mock())

        r.source_typology.filter_sites_by_distance_to_rupture = mock.Mock(
            return_value=None)
        sites, _idxs = calc.sites_of_interest(r, 0)
        self.assertEqual([], sites)

        ret = SiteCollection(list(iter(self.sites)))
        ret.indices = [1]
        r.source_typology.filter_sites_by_distance_to_rupture = mock.Mock(
            return_value=ret)
        sites, idxs = calc.sites_of_interest(r, 100)
        self.assertEqual(1, len(sites))
        self.assertEqual(1, len(idxs))
        self.assertEqual(1, idxs[0])
        self.assertEqual(1, sites.get_by_id(1).id)

        ret.indices = [0, 2]
        r.source_typology.filter_sites_by_distance_to_rupture = mock.Mock(
            return_value=ret)
        sites, idxs = calc.sites_of_interest(r, 1000)
        self.assertEqual(2, len(sites))
        self.assertEqual([0, 2], idxs)
开发者ID:Chunghan,项目名称:oq-engine,代码行数:40,代码来源:hazard_getters_test.py

示例2: test_expand_2d

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import indices [as 别名]
 def test_expand_2d(self):
     col = SiteCollection(self.SITES)
     col.indices = numpy.array([1, 3, 5, 6])
     data_condensed = numpy.array([
         [1, 2, 3],
         [5, 6, 7],
         [10, 11, 12],
         [15, 16, 17]
     ])
     data_expanded = col.expand(data_condensed, total_sites=8,
                                placeholder=-1)
     data_expanded_expected = numpy.array([
         [-1, -1, -1],
         [1, 2, 3],
         [-1, -1, -1],
         [5, 6, 7],
         [-1, -1, -1],
         [10, 11, 12],
         [15, 16, 17],
         [-1, -1, -1]
     ])
     numpy.testing.assert_array_equal(data_expanded, data_expanded_expected)
开发者ID:MaksimEritov,项目名称:oq-hazardlib,代码行数:24,代码来源:site_test.py


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