def build_planar_surface(geometry): """ Builds the planar rupture surface from the openquake.nrmllib.models instance """ # Read geometry from wkt geom = wkt.loads(geometry.wkt) top_left = Point(geom.xy[0][0], geom.xy[1][0], geometry.upper_seismo_depth) top_right = Point(geom.xy[0][1], geom.xy[1][1], geometry.upper_seismo_depth) strike = top_left.azimuth(top_right) dip_dir = (strike + 90.) % 360. depth_diff = geometry.lower_seismo_depth - geometry.upper_seismo_depth bottom_right = top_right.point_at( depth_diff / np.tan(geometry.dip * (np.pi / 180.)), depth_diff, dip_dir) bottom_left = top_left.point_at( depth_diff / np.tan(geometry.dip * (np.pi / 180.)), depth_diff, dip_dir) return PlanarSurface(1.0, strike, geometry.dip, top_left, top_right, bottom_right, bottom_left)