本文整理汇总了Python中openquake.hazardlib.site.SiteCollection.filter方法的典型用法代码示例。如果您正苦于以下问题:Python SiteCollection.filter方法的具体用法?Python SiteCollection.filter怎么用?Python SiteCollection.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.hazardlib.site.SiteCollection
的用法示例。
在下文中一共展示了SiteCollection.filter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
def test_filter(self):
col = SiteCollection(self.SITES)
filtered = col.filter(numpy.array([True, False, True, False]))
arreq = numpy.testing.assert_array_equal
arreq(filtered.vs30, [1.2, 2])
arreq(filtered.vs30measured, [True, True])
arreq(filtered.z1pt0, [3, 9])
arreq(filtered.z2pt5, [5, 17])
arreq(filtered.mesh.lons, [10, 0])
arreq(filtered.mesh.lats, [20, 2])
arreq(filtered.mesh.depths, [30, 0])
arreq(filtered.sids, [0, 2])
filtered = col.filter(numpy.array([False, True, True, True]))
arreq(filtered.vs30, [55.4, 2, 4])
arreq(filtered.vs30measured, [False, True, False])
arreq(filtered.z1pt0, [6, 9, 22])
arreq(filtered.z2pt5, [8, 17, 11])
arreq(filtered.mesh.lons, [11, 0, 1])
arreq(filtered.mesh.lats, [12, 2, 1])
arreq(filtered.mesh.depths, [13, 0, 3])
# test serialization to hdf5
fd, fpath = tempfile.mkstemp(suffix='.hdf5')
os.close(fd)
with hdf5.File(fpath, 'w') as f:
f['sitecol'] = filtered
saved = f['sitecol']
self.assertEqual(saved, filtered)
os.remove(fpath)
示例2: test_expand_1d
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
def test_expand_1d(self):
col = SiteCollection(self.SITES)
col = col.filter(numpy.array([1, 0, 1, 1]))
data_condensed = numpy.array([5, 6, 7])
data_expanded = col.expand(data_condensed, placeholder=100)
data_expanded_expected = numpy.array([5, 100, 6, 7])
numpy.testing.assert_array_equal(data_expanded, data_expanded_expected)
示例3: test_filter
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
def test_filter(self):
col = SiteCollection(self.SITES)
filtered = col.filter(numpy.array([True, False, True, False]))
self.assertIsInstance(filtered, FilteredSiteCollection)
arreq = numpy.testing.assert_array_equal
arreq(filtered.vs30, [1.2, 2])
arreq(filtered.vs30measured, [True, True])
arreq(filtered.z1pt0, [3, 9])
arreq(filtered.z2pt5, [5, 17])
arreq(filtered.mesh.lons, [10, 0])
arreq(filtered.mesh.lats, [20, 2])
self.assertIs(filtered.mesh.depths, None)
filtered = col.filter(numpy.array([False, True, True, True]))
self.assertIsInstance(filtered, FilteredSiteCollection)
arreq(filtered.vs30, [55.4, 2, 4])
arreq(filtered.vs30measured, [False, True, False])
arreq(filtered.z1pt0, [6, 9, 22])
arreq(filtered.z2pt5, [8, 17, 11])
arreq(filtered.mesh.lons, [11, 0, 1])
arreq(filtered.mesh.lats, [12, 2, 1])
self.assertIs(filtered.mesh.depths, None)
示例4: test_double_filter
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
def test_double_filter(self):
col = SiteCollection(self.SITES)
filtered = col.filter(numpy.array([True, False, True, True]))
filtered2 = filtered.filter(numpy.array([False, True, False]))
arreq = numpy.testing.assert_array_equal
arreq(filtered2.vs30, [2])
arreq(filtered2.vs30measured, [True])
arreq(filtered2.z1pt0, [9])
arreq(filtered2.z2pt5, [17])
arreq(filtered2.mesh.lons, [0])
arreq(filtered2.mesh.lats, [2])
arreq(filtered2.mesh.depths, [0])
filtered2 = filtered.filter(numpy.array([True, False, True]))
arreq(filtered2.vs30, [1.2, 4.])
示例5: test_filter_all_in
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
def test_filter_all_in(self):
col = SiteCollection(self.SITES)
filtered = col.filter(numpy.ones(len(self.SITES), bool))
self.assertIs(filtered, col)
示例6: test_filter_all_out
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
def test_filter_all_out(self):
col = SiteCollection(self.SITES)
filtered = col.filter(numpy.zeros(len(self.SITES), bool))
self.assertIs(filtered, None)