本文整理汇总了Python中openquake.hazardlib.site.SiteCollection.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python SiteCollection.__new__方法的具体用法?Python SiteCollection.__new__怎么用?Python SiteCollection.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.hazardlib.site.SiteCollection
的用法示例。
在下文中一共展示了SiteCollection.__new__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_sites
# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import __new__ [as 别名]
def test_from_sites(self):
s1 = Site(location=Point(10, 20, 30),
vs30=1.2, vs30measured=True,
z1pt0=3.4, z2pt5=5.6, backarc=True)
s2 = Site(location=Point(-1.2, -3.4, -5.6),
vs30=55.4, vs30measured=False,
z1pt0=66.7, z2pt5=88.9, backarc=False)
cll = SiteCollection([s1, s2])
self.assertTrue((cll.vs30 == [1.2, 55.4]).all())
self.assertTrue((cll.vs30measured == [True, False]).all())
self.assertTrue((cll.z1pt0 == [3.4, 66.7]).all())
self.assertTrue((cll.z2pt5 == [5.6, 88.9]).all())
self.assertTrue((cll.mesh.lons == [10, -1.2]).all())
self.assertTrue((cll.mesh.lats == [20, -3.4]).all())
self.assertTrue((cll.backarc == [True, False]).all())
self.assertIs(cll.mesh.depths, None)
for arr in (cll.vs30, cll.z1pt0, cll.z2pt5):
self.assertIsInstance(arr, numpy.ndarray)
self.assertEqual(arr.flags.writeable, False)
self.assertEqual(arr.dtype, float)
for arr in (cll.vs30measured, cll.backarc):
self.assertIsInstance(arr, numpy.ndarray)
self.assertEqual(arr.flags.writeable, False)
self.assertEqual(arr.dtype, bool)
self.assertEqual(len(cll), 2)
# test __toh5__ and __fromh5__
array, attrs = cll.__toh5__()
newcll = cll.__new__(cll.__class__)
newcll.__fromh5__(array, attrs)
self.assertEqual(newcll, cll)