mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 15:41:00 -05:00
Fault distance from point (#13367)
* Add python interface for distance to closest fault * Split up some older code into multiple files. * Add python test
This commit is contained in:
17 files changed
+896
-554
No files matched your search
@@ -0,0 +1,35 @@
|
||||
###################################################################################
|
||||
# This example prints the distance to and the name of the fault closest to a point
|
||||
###################################################################################
|
||||
|
||||
import rips
|
||||
|
||||
resinsight = rips.Instance.find()
|
||||
if resinsight is None:
|
||||
exit(1)
|
||||
|
||||
cases = resinsight.project.cases()
|
||||
if len(cases) == 0:
|
||||
exit(1)
|
||||
|
||||
case = cases[0]
|
||||
print("Using case: " + case.name)
|
||||
|
||||
# random test point (positive Z for depth)
|
||||
point_x = 5039.84
|
||||
point_y = 6303.76
|
||||
point_z = 4144.21
|
||||
|
||||
print("Looking for closest fault to point %f, %f, %f:" % (point_x, point_y, point_z))
|
||||
|
||||
faultname, distance, facename = case.distance_to_closest_fault(
|
||||
point_x, point_y, point_z
|
||||
)
|
||||
|
||||
if facename == "":
|
||||
print("- No fault found!")
|
||||
else:
|
||||
print(
|
||||
"- Distance to closest fault %s is %f, closest face direction is %s"
|
||||
% (faultname, distance, facename)
|
||||
)
|
||||
@@ -43,6 +43,7 @@ import Case_pb2
|
||||
import Case_pb2_grpc
|
||||
import Commands_pb2 as Cmd
|
||||
import PdmObject_pb2 as PdmObject_pb2
|
||||
import Definitions_pb2
|
||||
|
||||
import Properties_pb2
|
||||
import Properties_pb2_grpc
|
||||
@@ -300,6 +301,17 @@ def reservoir_boundingbox(self):
|
||||
return self.__case_stub.GetReservoirBoundingBox(self.__request())
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def distance_to_closest_fault(self, x: float, y: float, z: float):
|
||||
"""Find the closest fault to the given point and return the distance, fault name and fault face"""
|
||||
request = Case_pb2.ClosestFaultRequest(
|
||||
case_request=self.__request(), point=Definitions_pb2.Vec3d(x=x, y=y, z=z)
|
||||
)
|
||||
reply = self.__case_stub.GetDistanceToClosestFault(request)
|
||||
|
||||
return (reply.fault_name, reply.distance, reply.face_name)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def reservoir_depth_range(self) -> Tuple[float, float]:
|
||||
"""Get the reservoir depth range
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import sys
|
||||
import os
|
||||
import math
|
||||
import pytest
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
||||
import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_faultDistance(rips_instance, initialize_test):
|
||||
case = rips_instance.project.load_case(
|
||||
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
)
|
||||
|
||||
# a test point
|
||||
point_x = 4817.84
|
||||
point_y = 5204.76
|
||||
point_z = 4137.21
|
||||
|
||||
faultname, distance, facename = case.distance_to_closest_fault(
|
||||
point_x, point_y, point_z
|
||||
)
|
||||
|
||||
# Fault name is unstable between grid readers, so we skip this check
|
||||
# assert faultname == "Undefined Grid Faults"
|
||||
|
||||
assert facename == "I+"
|
||||
assert math.isclose(distance, 53.84, abs_tol=0.1)
|
||||
Reference in new issue
Block a user