本文整理汇总了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)
示例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)