#4550 Implement python well methods

This commit is contained in:
Kristian Bendiksen 2020-02-11 14:52:01 +01:00
parent 12a0a8c358
commit 2788c7a6c1
5 changed files with 68 additions and 1 deletions

View File

@ -227,4 +227,4 @@ list ( APPEND GRPC_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list ( APPEND GRPC_CPP_SOURCES ${SOURCE_GROUP_SOURCE_FILES}) list ( APPEND GRPC_CPP_SOURCES ${SOURCE_GROUP_SOURCE_FILES})
source_group( "GrpcInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.cmake ) source_group( "GrpcInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.cmake )
source_group( "GrpcInterface\\GrpcProtos" FILES ${GRPC_PROTO_FILES_FULL_PATH} ) source_group( "GrpcInterface\\GrpcProtos" FILES ${GRPC_PROTO_FILES_FULL_PATH} )

View File

@ -0,0 +1,17 @@
###################################################################################
# This example will connect to ResInsight, retrieve a list of wells and print info
#
###################################################################################
# Import the ResInsight Processing Server Module
import rips
# Connect to ResInsight
resinsight = rips.Instance.find()
if resinsight is not None:
# Get a list of all wells
wells = resinsight.project.wells()
print ("Got " + str(len(wells)) + " wells: ")
for well in wells:
print("Well name: " + well.name)

View File

@ -10,6 +10,7 @@ from rips.gridcasegroup import GridCaseGroup
from rips.pdmobject import PdmObject from rips.pdmobject import PdmObject
from rips.plot import Plot from rips.plot import Plot
from rips.view import View from rips.view import View
from rips.well import Well
from rips.contour_map import ContourMap, ContourMapType from rips.contour_map import ContourMap, ContourMapType
import rips.generated.Commands_pb2 as Cmd import rips.generated.Commands_pb2 as Cmd
@ -298,6 +299,19 @@ class Project(PdmObject):
wellPathFiles=well_path_files)) wellPathFiles=well_path_files))
return res.importWellPathsResult.wellPathNames return res.importWellPathsResult.wellPathNames
def wells(self):
"""Get a list of all wells in the project
Returns:
A list of rips Well objects
"""
pdm_objects = self.descendants("WellPathBase")
wells = []
for pdm_object in pdm_objects:
wells.append(Well(pdm_object.get_value("WellPathName"), pdm_object))
return wells
def import_well_log_files(self, well_log_files=None, well_log_folder=''): def import_well_log_files(self, well_log_files=None, well_log_folder=''):
""" Import well log files into project """ Import well log files into project

View File

@ -0,0 +1,19 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../../'))
import rips
import dataroot
def test_10k(rips_instance, initialize_test):
case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID"
case = rips_instance.project.load_case(path=case_path)
assert(len(case.grids()) == 2)
well_path_files = [case_root_path + "/wellpath_a.dev", case_root_path + "/wellpath_b.dev"]
well_paths = rips_instance.project.import_well_paths(well_path_files)
wells = rips_instance.project.wells()
assert(len(wells) == 2)
assert(wells[0].name == "Well Path A")
assert(wells[1].name == "Well Path B")

View File

@ -0,0 +1,17 @@
"""
ResInsight Well
"""
import rips.generated.Commands_pb2 as Cmd
from rips.pdmobject import PdmObject
class Well(PdmObject):
"""ResInsight well class
Attributes:
name(string): Name of the well.
"""
def __init__(self, name, pdm_object):
PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project())
self.name = name