本文整理汇总了Python中openquake.hazardlib.geo.point.Point.distance方法的典型用法代码示例。如果您正苦于以下问题:Python Point.distance方法的具体用法?Python Point.distance怎么用?Python Point.distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.hazardlib.geo.point.Point
的用法示例。
在下文中一共展示了Point.distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_mesh_is
# 需要导入模块: from openquake.hazardlib.geo.point import Point [as 别名]
# 或者: from openquake.hazardlib.geo.point.Point import distance [as 别名]
def assert_mesh_is(testcase, surface, expected_mesh):
mesh = surface.get_mesh()
testcase.assertIs(mesh, surface.get_mesh())
expected_mesh = list(itertools.chain(*expected_mesh))
testcase.assertEqual(len(mesh), len(expected_mesh))
testcase.assertIsInstance(mesh, Mesh)
for i, point in enumerate(mesh):
expected_point = Point(*expected_mesh[i])
distance = expected_point.distance(point) * 1e3
testcase.assertAlmostEqual(
0, distance, delta=2, # allow discrepancy of 2 meters
msg="point %d is off: %s != %s (distance is %.3fm)"
% (i, point, expected_point, distance)
)
示例2: getLength
# 需要导入模块: from openquake.hazardlib.geo.point import Point [as 别名]
# 或者: from openquake.hazardlib.geo.point.Point import distance [as 别名]
def getLength(self):
"""
Compute length of rupture (km). For EdgeRupture, we compute the length
as the length of the top edge projected to the surface.
Returns:
float: Rupture length in km.
"""
lons = self._toplons
lats = self._toplats
seg = self._group_index
groups = np.unique(seg)
ng = len(groups)
rlength = 0
for i in range(ng):
group_segments = np.where(groups[i] == seg)[0]
nseg = len(group_segments) - 1
for j in range(nseg):
ind = group_segments[j]
P0 = Point(lons[ind], lats[ind])
P1 = Point(lons[ind + 1], lats[ind + 1])
dist = P0.distance(P1)
rlength = rlength + dist
return rlength