Make Python code use the new generated skeleton and rename ResInsight parameters to fit

This commit is contained in:
Gaute Lindkvist 2020-02-21 12:10:02 +01:00
parent ae3651ab30
commit 1f6e9513de
42 changed files with 2078 additions and 2085 deletions

View File

@ -178,7 +178,9 @@ if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
"rips/instance.py"
"rips/pdmobject.py"
"rips/plot.py"
"rips/simulation_well.py"
"rips/view.py"
"rips/wellpath.py"
"rips/well_log_plot.py"
"rips/well_bore_stability_plot.py"
"rips/PythonExamples/instance_example.py"
@ -209,6 +211,9 @@ if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
"rips/tests/test_project.py"
"rips/tests/conftest.py"
"rips/tests/dataroot.py"
"rips/tests/test_nnc_properties.py"
"rips/tests/test_simulation_wells.py"
"rips/tests/test_wells.py"
"requirements.txt"
"setup.py"
"README.md"

View File

@ -14,10 +14,10 @@ if resinsight is not None:
print ("Got " + str(len(cases)) + " cases: ")
for case in cases:
print("Case id: " + str(case.case_id))
print("Case id: " + str(case.id))
print("Case name: " + case.name)
print("Case type: " + case.type)
print("Case grid path: " + case.grid_path())
print("Case file name: " + case.file_path)
print("Case reservoir bounding box:", case.reservoir_boundingbox())
timesteps = case.time_steps()

View File

@ -13,7 +13,7 @@ if resinsight is not None:
cases = resinsight.project.cases()
for case in cases:
print("Case id: " + str(case.case_id))
print("Case id: " + str(case.id))
print("Case name: " + case.name)
timesteps = case.time_steps()

View File

@ -10,7 +10,7 @@ import rips
resinsight = rips.Instance.find()
if resinsight is not None:
# Get a list of all wells
wells = resinsight.project.wells()
wells = resinsight.project.well_paths()
print ("Got " + str(len(wells)) + " wells: ")
for well in wells:

View File

@ -16,14 +16,12 @@ case_group.print_object_info()
#stat_cases = caseGroup.statistics_cases()
#case_ids = []
#for stat_case in stat_cases:
# stat_case.set_value("DynamicPropertiesToCalculate", ["SWAT"])
# stat_case.update()
# case_ids.append(stat_case.get_value("CaseId"))
# stat_case.set_dynamic_properties_to_calculate(["SWAT"])
# case_ids.append(stat_case.id)
case_group.compute_statistics()
view = case_group.views()[0]
cell_result = view.set_cell_result()
cell_result.set_value("ResultVariable", "PRESSURE_DEV")
cell_result.update()
cell_result = view.cell_result()
cell_result.set_result_variable("PRESSURE_DEV")

View File

@ -33,8 +33,8 @@ for case in cases:
if case.type == "GeoMechCase":
min_res_depth, max_res_depth = case.reservoir_depth_range()
print (case.case_id)
case_path = case.grid_path()
print (case.id)
case_path = case.file_path
folder_name = os.path.dirname(case_path)
case.import_formation_names(formation_files=['D:/Projects/ResInsight-regression-test/ModelData/norne/Norne_ATW2013.lyr'])
@ -45,16 +45,19 @@ for case in cases:
for well_path in well_paths:
try:
# Create plot with parameters
wbsplot = case.create_well_bore_stability_plot(well_path=well_path, time_step=0, wbs_parameters=wbs_parameters)
wbsplot = case.create_well_bore_stability_plot(well_path=well_path.name, time_step=0, wbs_parameters=wbs_parameters)
# Example of setting parameters for existing plots
replace_params = wbsplot.parameters()
replace_params.user_poisson_ratio = 0.654321
replace_params.user_fg_shale = 1.0321
wbsplot.set_parameters(replace_params)
# Demonstrate altering general well log plot settings
min_depth, max_depth = wbsplot.depth_range()
wbsplot.set_depth_range(max(min_depth, min_res_depth), min(max_depth, max_res_depth))
#wbsplot.set_depth_type("TRUE_VERTICAL_DEPTH_RKB")
min_depth = max(wbsplot.minimum_depth, min_res_depth)
max_depth = min(wbsplot.maximum_depth, max_res_depth)
wbsplot.minimum_depth = min_depth
wbsplot.maximum_depth = max_depth
wbsplot.update()
#wbsplot.depth_type = "TRUE_VERTICAL_DEPTH_RKB"
wbsplot.export_snapshot(export_folder=dirname)

View File

@ -15,7 +15,7 @@ print("Exporting to: " + export_folder)
for plot in plots:
plot.export_snapshot(export_folder=export_folder)
plot.export_snapshot(export_folder=export_folder, output_format='PDF')
well_log_plot = rips.WellLogPlot.from_pdm_object(plot)
well_log_plot = plot.cast(rips.WellLogPlot)
if well_log_plot is not None:
well_log_plot.export_data_as_las(export_folder=export_folder)
well_log_plot.export_data_as_ascii(export_folder=export_folder)
well_log_plot.export_data_as_ascii(export_folder=export_folder)

View File

@ -18,9 +18,9 @@ property_list = ['SOIL', 'PRESSURE'] # list of parameter for snapshot
print ("Looping through cases")
for case in cases:
print("Case name: ", case.name)
print("Case id: ", case.case_id)
print("Case id: ", case.id)
# Get grid path and its folder name
case_path = case.grid_path()
case_path = case.file_path
folder_name = os.path.dirname(case_path)
# create a folder to hold the snapshots

View File

@ -3,24 +3,24 @@ import rips
# Connect to ResInsight instance
resInsight = rips.Instance.find()
well_path_names = resInsight.project.import_well_paths(well_path_folder='D:/Projects/ResInsight-regression-test/ModelData/norne/wellpaths')
well_paths = resInsight.project.import_well_paths(well_path_folder='D:/Projects/ResInsight-regression-test/ModelData/norne/wellpaths')
if resInsight.project.has_warnings():
for warning in resInsight.project.warnings():
print(warning)
for well_path_name in well_path_names:
print("Imported from folder: " + well_path_name)
for well_path in well_paths:
print("Imported from folder: " + well_path.name)
well_path_names = resInsight.project.import_well_paths(well_path_files=['D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/E-3H.json',
well_paths = resInsight.project.import_well_paths(well_path_files=['D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/E-3H.json',
'D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/C-1H.json'])
if resInsight.project.has_warnings():
for warning in resInsight.project.warnings():
print(warning)
for well_path_name in well_path_names:
print("Imported from indivdual files: " + well_path_name)
for well_path in well_paths:
print("Imported from individual files: " + well_path.name)
well_path_names = resInsight.project.import_well_log_files(well_log_folder='D:/Projects/ResInsight-regression-test/ModelData/Norne_PLT_LAS')

View File

@ -16,14 +16,14 @@ if resinsight is not None:
views = case.views()
for view in views:
# Set some parameters for the view
view.set_show_grid_box(not view.show_grid_box())
view.set_background_color("#3388AA")
view.show_grid_box = not view.show_grid_box
view.background_color = "#3388AA"
# Update the view in ResInsight
view.update()
# Clone the first view
new_view = views[0].clone()
view.set_show_grid_box(False)
new_view.set_background_color("#FFAA33")
new_view.background_color = "#FFAA33"
new_view.update()
view.show_grid_box = False
view.set_visible(False)
view.update()

View File

@ -10,7 +10,9 @@ from rips.instance import Instance
from rips.pdmobject import PdmObject
from rips.view import View
from rips.project import Project
from rips.plot import Plot
from rips.plot import Plot, PlotWindow
from rips.contour_map import ContourMap, ContourMapType
from rips.well_log_plot import WellLogPlot
from rips.well_bore_stability_plot import WellBoreStabilityPlot, WbsParameters
from rips.simulation_well import SimulationWell
from rips.wellpath import WellPathBase

File diff suppressed because it is too large Load Diff

View File

@ -27,9 +27,8 @@ class ContourMap(View):
view_id(int): View Id corresponding to the View Id in ResInsight project.
"""
def __init__(self, pdm_object, project, map_type):
View.__init__(self, pdm_object, project)
self.view_id = pdm_object.get_value("ViewId")
def __init__(self, pdm_object, map_type):
View.__init__(self, pdm_object)
self.map_type = map_type
@ -48,4 +47,4 @@ class ContourMap(View):
exportLocalCoordinates=export_local_coordinates,
undefinedValueLabel=undefined_value_label,
excludeUndefinedValues=exclude_undefined_values,
viewId=self.view_id))
viewId=self.id))

View File

@ -28,7 +28,7 @@ class Grid:
Returns:
Vec3i: class with integer attributes i, j, k giving extent in all three dimensions.
"""
case_request = Case_pb2.CaseRequest(id=self.case.case_id)
case_request = Case_pb2.CaseRequest(id=self.case.id)
return self.__stub.GetDimensions(
Grid_pb2.GridRequest(case_request=case_request,
grid_index=self.index)).dimensions
@ -40,7 +40,7 @@ class Grid:
Returns:
Iterator to a list of Vec3d: class with double attributes x, y, x giving cell centers
"""
case_request = Case_pb2.CaseRequest(id=self.case.case_id)
case_request = Case_pb2.CaseRequest(id=self.case.id)
chunks = self.__stub.GetCellCenters(
Grid_pb2.GridRequest(case_request=case_request,
grid_index=self.index))
@ -66,7 +66,7 @@ class Grid:
Returns:
iterator to a list of CellCorners: a class with Vec3d for each corner (c0, c1.., c7)
"""
case_request = Case_pb2.CaseRequest(id=self.case.case_id)
case_request = Case_pb2.CaseRequest(id=self.case.id)
chunks = self.__stub.GetCellCorners(
Grid_pb2.GridRequest(case_request=case_request,
grid_index=self.index))

View File

@ -2,74 +2,67 @@
Grid Case Group statistics module
"""
from rips.pdmobject import PdmObject
from rips.pdmobject import PdmObject, add_method
from rips.view import View
from rips.case import Case
import rips.generated.Commands_pb2 as Cmd
from rips.generated.pdm_objects import GridCaseGroup
class GridCaseGroup(PdmObject):
"""ResInsight Grid Case Group class
Operate on a ResInsight case group specified by a Case Group Id integer.
Attributes:
group_id (int): Grid Case Group Id corresponding to case group Id in ResInsight project.
@add_method(GridCaseGroup)
def create_statistics_case(self):
"""Create a Statistics case in the Grid Case Group
Returns:
A new Case
"""
def __init__(self, pdm_object):
self.group_id = pdm_object.get_value("GroupId")
PdmObject.__init__(self, pdm_object._pb2_object, pdm_object._channel, pdm_object._project)
command_reply = self._execute_command(
createStatisticsCase=Cmd.CreateStatisticsCaseRequest(
caseGroupId=self.group_id))
return Case(self.channel,
command_reply.createStatisticsCaseResult.caseId)
def create_statistics_case(self):
"""Create a Statistics case in the Grid Case Group
@add_method(GridCaseGroup)
def statistics_cases(self):
"""Get a list of all statistics cases in the Grid Case Group"""
stat_case_collection = self.children("StatisticsCaseCollection")[0]
return stat_case_collection.children("Reservoirs")
Returns:
A new Case
"""
command_reply = self._execute_command(
createStatisticsCase=Cmd.CreateStatisticsCaseRequest(
caseGroupId=self.group_id))
return Case(self.channel,
command_reply.createStatisticsCaseResult.caseId)
@add_method(GridCaseGroup)
def views(self):
"""Get a list of views belonging to a grid case group"""
pdm_objects = self.descendants(EclipseView)
view_list = []
for pdm_object in pdm_objects:
view_list.append(pdm_object)
return view_list
def statistics_cases(self):
"""Get a list of all statistics cases in the Grid Case Group"""
stat_case_collection = self.children("StatisticsCaseCollection")[0]
return stat_case_collection.children("Reservoirs")
@add_method(GridCaseGroup)
def view(self, view_id):
"""Get a particular view belonging to a case group by providing view id
Arguments:
id(int): view id
def views(self):
"""Get a list of views belonging to a grid case group"""
pdm_objects = self.descendants("ReservoirView")
view_list = []
for pdm_object in pdm_objects:
view_list.append(View(pdm_object))
return view_list
Returns: a view object
def view(self, view_id):
"""Get a particular view belonging to a case group by providing view id
Arguments:
id(int): view id
"""
views = self.views()
for view_object in views:
if view_object.id == view_id:
return view_object
return None
Returns: a view object
@add_method(GridCaseGroup)
def compute_statistics(self, case_ids=None):
""" Compute statistics for the given case ids
"""
views = self.views()
for view_object in views:
if view_object.id == view_id:
return view_object
return None
Arguments:
case_ids(list of integers): list of case ids.
If this is None all cases in group are included
def compute_statistics(self, case_ids=None):
""" Compute statistics for the given case ids
Arguments:
case_ids(list of integers): list of case ids.
If this is None all cases in group are included
"""
if case_ids is None:
case_ids = []
return self._execute_command(
computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest(
caseIds=case_ids, caseGroupId=self.group_id))
"""
if case_ids is None:
case_ids = []
return self._execute_command(
computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest(
caseIds=case_ids, caseGroupId=self.group_id))

View File

@ -204,7 +204,7 @@ class Instance:
self.client_version_string())
# Service packages
self.project = Project(self.channel)
self.project = Project.create(self.channel)
path = os.getcwd()
self.set_start_dir(path=path)

View File

@ -3,210 +3,322 @@
ResInsight caf::PdmObject connection module
"""
from functools import partial, wraps
import grpc
import re
import builtins
import importlib
import inspect
import sys
import rips.generated.PdmObject_pb2 as PdmObject_pb2
import rips.generated.PdmObject_pb2_grpc as PdmObject_pb2_grpc
import rips.generated.Commands_pb2 as Cmd
import rips.generated.Commands_pb2_grpc as CmdRpc
from rips.generated.pdm_objects import PdmObject
class PdmObject:
"""
Generic ResInsight object. Corresponds to items in the Project Tree
"""
def camel_to_snake(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
def _execute_command(self, **command_params):
self.__warnings = []
response, call = self._commands.Execute.with_call(Cmd.CommandParams(**command_params))
for key, value in call.trailing_metadata():
value = value.replace(';;', '\n')
if key == 'warning':
self.__warnings.append(value)
def add_method(cls):
def decorator(func):
setattr(cls, func.__name__, func)
return func # returning func means func can still be used normally
return decorator
return response
def add_static_method(cls):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
setattr(cls, func.__name__, wrapper)
# Note we are not binding func, but wrapper which accepts self but does exactly the same as func
return func # returning func means func can still be used normally
return decorator
def __init__(self, pb2_object, channel, project):
@add_method(PdmObject)
def _execute_command(self, **command_params):
self.__warnings = []
response, call = self._commands.Execute.with_call(Cmd.CommandParams(**command_params))
for key, value in call.trailing_metadata():
value = value.replace(';;', '\n')
if key == 'warning':
self.__warnings.append(value)
return response
@add_method(PdmObject)
def __custom_init__(self, pb2_object, channel):
self.__warnings = []
self.__keyword_translation = {}
if pb2_object is not None:
self._pb2_object = pb2_object
self._channel = channel
self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self._channel)
self._commands = CmdRpc.CommandsStub(channel)
self._project = project
self.__warnings = []
else:
self._pb2_object = PdmObject_pb2.PdmObject(class_keyword=self.__class__.__name__)
@classmethod
def create(cls, class_keyword, channel, project):
pb2_object = PdmObject_pb2.PdmObject(class_keyword=class_keyword)
return cls(pb2_object, channel, project)
def warnings(self):
return self.__warnings
def has_warnings(self):
return len(self.__warnings) > 0
def pb2_object(self):
""" Private method"""
return self._pb2_object
def channel(self):
""" Private method"""
return self._channel
def project(self):
""" Private method"""
return self._project
def address(self):
"""Get the unique address of the PdmObject
Returns:
A 64-bit unsigned integer address
"""
return self._pb2_object.address
def class_keyword(self):
"""Get the class keyword in the ResInsight Data Model for the given PdmObject"""
return self._pb2_object.class_keyword
def set_visible(self, visible):
"""Set the visibility of the object in the ResInsight project tree"""
self._pb2_object.visible = visible
def visible(self):
"""Get the visibility of the object in the ResInsight project tree"""
return self._pb2_object.visible
self._channel = channel
def keywords(self):
"""Get a list of all parameter keywords available in the object"""
list_of_keywords = []
for keyword in self._pb2_object.parameters:
list_of_keywords.append(keyword)
return list_of_keywords
if self.pb2_object() is not None and self.channel() is not None:
if self.channel() is not None:
self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self.channel())
self._commands = CmdRpc.CommandsStub(self.channel())
for camel_keyword in self._pb2_object.parameters:
snake_keyword = camel_to_snake(camel_keyword)
setattr(self, snake_keyword, self.__get_grpc_value(camel_keyword))
self.__keyword_translation[snake_keyword] = camel_keyword
self._superclasses = self.superclasses()
def print_object_info(self):
"""Print the structure and data content of the PdmObject"""
print("Class Keyword: " + self.class_keyword())
for keyword in self.keywords():
print(keyword + " [" + type(self.get_value(keyword)).__name__ +
"]: " + str(self.get_value(keyword)))
@add_method(PdmObject)
def copy_from(self, object):
"""Copy attribute values from object to self
"""
for attribute in dir(object):
if not attribute.startswith('__'):
value = getattr(object, attribute)
if not callable(value):
setattr(self, attribute, value)
def __to_value(self, value):
if value.lower() == 'false':
return False
if value.lower() == 'true':
return True
@add_method(PdmObject)
def cast(self, class_definition):
if class_definition.__name__ == self.class_keyword() or class_definition.__name__ in self._superclasses:
new_object = class_definition(self.pb2_object(), self.channel())
new_object.copy_from(self)
return new_object
return None
@add_method(PdmObject)
def warnings(self):
return self.__warnings
@add_method(PdmObject)
def has_warnings(self):
return len(self.__warnings) > 0
@add_method(PdmObject)
def pb2_object(self):
""" Private method"""
return self._pb2_object
@add_method(PdmObject)
def channel(self):
""" Private method"""
return self._channel
@add_method(PdmObject)
def address(self):
"""Get the unique address of the PdmObject
Returns:
A 64-bit unsigned integer address
"""
return self._pb2_object.address
@add_method(PdmObject)
def class_keyword(self):
"""Get the class keyword in the ResInsight Data Model for the given PdmObject"""
return self._pb2_object.class_keyword
@add_method(PdmObject)
def set_visible(self, visible):
"""Set the visibility of the object in the ResInsight project tree"""
self._pb2_object.visible = visible
@add_method(PdmObject)
def visible(self):
"""Get the visibility of the object in the ResInsight project tree"""
return self._pb2_object.visible
@add_method(PdmObject)
def print_object_info(self):
"""Print the structure and data content of the PdmObject"""
print("=========== " + self.class_keyword() + " =================")
print("Object Attributes: ")
for snake_kw, camel_kw in self.__keyword_translation.items():
print(" " + snake_kw + " [" + type(getattr(self, snake_kw)).__name__ +
"]: " + str(getattr(self, snake_kw)))
print("Object Methods:")
for method in dir(self):
if not method.startswith("_") and callable(getattr(self, method)):
print (" " + method)
@add_method(PdmObject)
def __convert_from_grpc_value(self, value):
if value.lower() == 'false':
return False
if value.lower() == 'true':
return True
try:
int_val = int(value)
return int_val
except ValueError:
try:
int_val = int(value)
return int_val
float_val = float(value)
return float_val
except ValueError:
try:
float_val = float(value)
return float_val
except ValueError:
# We may have a string. Strip internal start and end quotes
value = value.strip('\"')
if self.__islist(value):
return self.__makelist(value)
return value
# We may have a string. Strip internal start and end quotes
value = value.strip('\"')
if self.__islist(value):
return self.__makelist(value)
return value
def __from_value(self, value):
if isinstance(value, bool):
if value:
return "true"
return "false"
if isinstance(value, list):
list_of_strings = []
for val in value:
list_of_strings.append(self.__from_value('\"' + val + '\"'))
return "[" + ", ".join(list_of_strings) + "]"
return str(value)
@add_method(PdmObject)
def __convert_to_grpc_value(self, value):
if isinstance(value, bool):
if value:
return "true"
return "false"
if isinstance(value, list):
list_of_strings = []
for val in value:
list_of_strings.append(self.__convert_to_grpc_value('\"' + val + '\"'))
return "[" + ", ".join(list_of_strings) + "]"
return str(value)
def get_value(self, keyword):
"""Get the value associated with the provided keyword
Arguments:
keyword(str): A string containing the parameter keyword
@add_method(PdmObject)
def __get_grpc_value(self, camel_keyword):
return self.__convert_from_grpc_value(self._pb2_object.parameters[camel_keyword])
Returns:
The value of the parameter. Can be int, str or list.
"""
value = self._pb2_object.parameters[keyword]
return self.__to_value(value)
@add_method(PdmObject)
def __set_grpc_value(self, camel_keyword, value):
self._pb2_object.parameters[camel_keyword] = self.__convert_to_grpc_value(value)
def __islist(self, value):
return value.startswith("[") and value.endswith("]")
@add_method(PdmObject)
def set_value(self, snake_keyword, value):
"""Set the value associated with the provided keyword and updates ResInsight
Arguments:
keyword(str): A string containing the parameter keyword
value(varying): A value matching the type of the parameter.
See keyword documentation and/or print_object_info() to find
the correct data type.
"""
setattr(self, snake_keyword, value)
self.update()
def __makelist(self, list_string):
list_string = list_string.lstrip("[")
list_string = list_string.rstrip("]")
strings = list_string.split(", ")
values = []
for string in strings:
values.append(self.__to_value(string))
return values
@add_method(PdmObject)
def __islist(self, value):
return value.startswith("[") and value.endswith("]")
def set_value(self, keyword, value):
"""Set the value associated with the provided keyword
Arguments:
keyword(str): A string containing the parameter keyword
value(varying): A value matching the type of the parameter.
See keyword documentation and/or print_object_info() to find
the correct data type.
"""
self._pb2_object.parameters[keyword] = self.__from_value(value)
@add_method(PdmObject)
def __makelist(self, list_string):
list_string = list_string.lstrip("[")
list_string = list_string.rstrip("]")
strings = list_string.split(", ")
values = []
for string in strings:
values.append(self.__convert_from_grpc_value(string))
return values
def descendants(self, class_keyword):
"""Get a list of all project tree descendants matching the class keyword
Arguments:
class_keyword[str]: A class keyword matching the type of class wanted
@add_method(PdmObject)
def descendants(self, class_keyword_or_class):
"""Get a list of all project tree descendants matching the class keyword
Arguments:
class_keyword_or_class[str/Class]: A class keyword matching the type of class wanted or a Class definition
Returns:
A list of PdmObjects matching the keyword provided
"""
request = PdmObject_pb2.PdmDescendantObjectRequest(
object=self._pb2_object, child_keyword=class_keyword)
object_list = self._pdm_object_stub.GetDescendantPdmObjects(
request).objects
Returns:
A list of PdmObjects matching the keyword provided
"""
class_definition = PdmObject
class_keyword = ""
if isinstance(class_keyword_or_class, str):
class_keyword = class_keyword_or_class
else:
assert(inspect.isclass(class_keyword_or_class))
class_keyword = class_keyword_or_class.__name__
class_definition = class_keyword_or_class
request = PdmObject_pb2.PdmDescendantObjectRequest(
object=self._pb2_object, child_keyword=class_keyword)
object_list = self._pdm_object_stub.GetDescendantPdmObjects(
request).objects
child_list = []
for pb2_object in object_list:
pdm_object = PdmObject(pb2_object=pb2_object, channel=self.channel())
if class_definition.__name__ == PdmObject.__name__:
child_list.append(pdm_object)
else:
casted_object = pdm_object.cast(class_definition)
if casted_object:
child_list.append(casted_object)
return child_list
@add_method(PdmObject)
def children(self, child_field, class_definition=PdmObject):
"""Get a list of all direct project tree children inside the provided child_field
Arguments:
child_field[str]: A field name
Returns:
A list of PdmObjects inside the child_field
"""
request = PdmObject_pb2.PdmChildObjectRequest(object=self._pb2_object,
child_field=child_field)
try:
object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects
child_list = []
for pdm_object in object_list:
child_list.append(PdmObject(pdm_object, self._channel, self._project))
for pb2_object in object_list:
pdm_object = PdmObject(pb2_object=pb2_object, channel=self.channel())
if class_definition.__name__ == PdmObject.__name__:
child_list.append(pdm_object)
else:
child_list.append(pdm_object.cast(class_definition))
return child_list
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND:
return []
raise e
def children(self, child_field):
"""Get a list of all direct project tree children inside the provided child_field
Arguments:
child_field[str]: A field name
Returns:
A list of PdmObjects inside the child_field
"""
request = PdmObject_pb2.PdmChildObjectRequest(object=self._pb2_object,
child_field=child_field)
try:
object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects
child_list = []
for pdm_object in object_list:
child_list.append(PdmObject(pdm_object, self._channel, self._project))
return child_list
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND:
return []
raise e
@add_method(PdmObject)
def ancestor(self, class_keyword_or_class):
"""Find the first ancestor that matches the provided class_keyword
Arguments:
class_keyword_or_class[str/Class]: A class keyword matching the type of class wanted or a Class definition
"""
class_definition = PdmObject
class_keyword = ""
if isinstance(class_keyword_or_class, str):
class_keyword = class_keyword_or_class
else:
assert(inspect.isclass(class_keyword_or_class))
class_keyword = class_keyword_or_class.__name__
class_definition = class_keyword_or_class
def ancestor(self, class_keyword):
"""Find the first ancestor that matches the provided class_keyword
Arguments:
class_keyword[str]: A class keyword matching the type of class wanted
"""
request = PdmObject_pb2.PdmParentObjectRequest(
object=self._pb2_object, parent_keyword=class_keyword)
try:
return PdmObject(self._pdm_object_stub.GetAncestorPdmObject(request),
self._channel, self._project)
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND:
return None
raise e
request = PdmObject_pb2.PdmParentObjectRequest(
object=self._pb2_object, parent_keyword=class_keyword)
try:
pb2_object = self._pdm_object_stub.GetAncestorPdmObject(request)
pdm_object = PdmObject(pb2_object=pb2_object,
channel=self._channel)
if class_definition.__name__ == PdmObject.__name__:
return pdm_object
else:
return pdm_object.cast(class_definition)
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND:
return None
raise e
@add_method(PdmObject)
def update(self):
"""Sync all fields from the Python Object to ResInsight"""
if self._pdm_object_stub is not None and self._pb2_object is not None:
for snake_kw, camel_kw in self.__keyword_translation.items():
self.__set_grpc_value(camel_kw, getattr(self, snake_kw))
def update(self):
"""Sync all fields from the Python Object to ResInsight"""
self._pdm_object_stub.UpdateExistingPdmObject(self._pb2_object)
else:
raise Exception("Object is not connected to GRPC service so cannot update ResInsight")
@add_method(PdmObject)
def superclasses(self):
names = []
mod = importlib.import_module("rips.generated.pdm_objects")
for name, obj in inspect.getmembers(mod):
if (inspect.isclass(obj) and name == self.class_keyword()):
class_hierarchy = inspect.getmro(obj)
for cls in class_hierarchy:
names.append(cls.__name__)
return names

View File

@ -4,32 +4,24 @@ ResInsight 2d plot module
import rips.generated.Commands_pb2 as Cmd
from rips.pdmobject import PdmObject
from rips.generated.pdm_objects import PlotWindow, Plot
from rips.pdmobject import add_method
class Plot(PdmObject):
"""ResInsight plot class
Attributes:
view_id(int): View Id corresponding to the View Id in ResInsight project.
"""
def __init__(self, pdm_object):
PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project())
self.view_id = pdm_object.get_value("ViewId")
def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG'):
""" Export snapshot for the current plot
@add_method(PlotWindow)
def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG'):
""" Export snapshot for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
prefix (str): Exported file name prefix
output_format(str): Enum string. Can be 'PNG' or 'PDF'.
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
prefix (str): Exported file name prefix
output_format(str): Enum string. Can be 'PNG' or 'PDF'.
"""
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS',
prefix=file_prefix,
viewId=self.view_id,
exportFolder=export_folder,
plotOutputFormat=output_format))
"""
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS',
prefix=file_prefix,
viewId=self.id,
exportFolder=export_folder,
plotOutputFormat=output_format))

View File

@ -3,343 +3,364 @@
"""
The ResInsight project module
"""
import builtins
import grpc
from rips.case import Case
from rips.gridcasegroup import GridCaseGroup
from rips.pdmobject import PdmObject
from rips.pdmobject import PdmObject, add_method, add_static_method
from rips.plot import Plot
from rips.view import View
from rips.well import Well
from rips.wellpath import WellPathBase
from rips.contour_map import ContourMap, ContourMapType
import rips.generated.Commands_pb2 as Cmd
from rips.generated.Definitions_pb2 import Empty
import rips.generated.Project_pb2_grpc as Project_pb2_grpc
import rips.generated.Project_pb2 as Project_pb2
import rips.generated.PdmObject_pb2 as PdmObject_pb2
from rips.generated.pdm_objects import Project, PlotWindow
class Project(PdmObject):
"""ResInsight project. Not intended to be created separately.
@add_method(Project)
def __custom_init__(self, pb2_object, channel):
self._project_stub = Project_pb2_grpc.ProjectStub(self._channel)
@add_static_method(Project)
def create(channel):
project_stub = Project_pb2_grpc.ProjectStub(channel)
pb2_object = project_stub.GetPdmObject(Empty())
return Project(pb2_object, channel)
@add_method(Project)
def open(self, path):
"""Open a new project from the given path
Arguments:
path(str): path to project file
Automatically created and assigned to Instance.
"""
def __init__(self, channel):
self._project_stub = Project_pb2_grpc.ProjectStub(channel)
PdmObject.__init__(self, self._project_stub.GetPdmObject(Empty()),
channel, self)
def open(self, path):
"""Open a new project from the given path
Arguments:
path(str): path to project file
"""
self._execute_command(openProject=Cmd.FilePathRequest(path=path))
return self
self._execute_command(openProject=Cmd.FilePathRequest(path=path))
return self
def save(self, path=""):
"""Save the project to the existing project file, or to a new file
Arguments:
path(str): File path to the file to save the project to. If empty, saves to the active project file
"""
self._execute_command(saveProject=Cmd.SaveProjectRequest(filePath=path))
return self
@add_method(Project)
def save(self, path=""):
"""Save the project to the existing project file, or to a new file
Arguments:
path(str): File path to the file to save the project to. If empty, saves to the active project file
"""
self._execute_command(saveProject=Cmd.SaveProjectRequest(filePath=path))
return self
def close(self):
"""Close the current project (and open new blank project)"""
self._execute_command(closeProject=Empty())
@add_method(Project)
def close(self):
"""Close the current project (and open new blank project)"""
self._execute_command(closeProject=Empty())
def load_case(self, path):
"""Load a new case from the given file path
@add_method(Project)
def load_case(self, path):
"""Load a new case from the given file path
Arguments:
path(str): file path to case
Returns:
A rips Case object
"""
command_reply = self._execute_command(loadCase=Cmd.FilePathRequest(
path=path))
return Case(self._channel, command_reply.loadCaseResult.id, self)
Arguments:
path(str): file path to case
Returns:
A rips Case object
"""
command_reply = self._execute_command(loadCase=Cmd.FilePathRequest(
path=path))
return self.case(command_reply.loadCaseResult.id)
def selected_cases(self):
"""Get a list of all cases selected in the project tree
@add_method(Project)
def selected_cases(self):
"""Get a list of all cases selected in the project tree
Returns:
A list of rips Case objects
"""
case_infos = self._project_stub.GetSelectedCases(Empty())
cases = []
for case_info in case_infos.data:
cases.append(Case(self._channel, case_info.id, self))
return cases
Returns:
A list of rips Case objects
"""
case_infos = self._project_stub.GetSelectedCases(Empty())
cases = []
for case_info in case_infos.data:
cases.append(self.case(case_info.id))
return cases
def cases(self):
"""Get a list of all cases in the project
@add_method(Project)
def cases(self):
"""Get a list of all cases in the project
Returns:
A list of rips Case objects
"""
try:
case_infos = self._project_stub.GetAllCases(Empty())
Returns:
A list of rips Case objects
"""
pdm_objects = self.descendants(Case.__name__)
cases = []
for case_info in case_infos.data:
cases.append(Case(self._channel, case_info.id, self))
return cases
except grpc.RpcError as rpc_error:
if rpc_error.code() == grpc.StatusCode.NOT_FOUND:
return []
print("ERROR: ", rpc_error)
return []
cases = []
for pdm_object in pdm_objects:
cases.append(pdm_object.cast(Case))
return cases
def case(self, case_id):
"""Get a specific case from the provided case Id
@add_method(Project)
def case(self, case_id):
"""Get a specific case from the provided case Id
Arguments:
id(int): case id
Returns:
A rips Case object
"""
try:
case = Case(self._channel, case_id, self)
Arguments:
id(int): case id
Returns:
A rips Case object
"""
allCases = self.cases()
for case in allCases:
if case.id == case_id:
return case
except grpc.RpcError:
return None
return None
def replace_source_cases(self, grid_list_file, case_group_id=0):
"""Replace all source cases within a case group
@add_method(Project)
def replace_source_cases(self, grid_list_file, case_group_id=0):
"""Replace all source cases within a case group
Arguments:
grid_list_file (str): path to file containing a list of cases
case_group_id (int): id of the case group to replace
"""
return self._execute_command(
replaceSourceCases=Cmd.ReplaceSourceCasesRequest(
gridListFile=grid_list_file, caseGroupId=case_group_id))
Arguments:
grid_list_file (str): path to file containing a list of cases
case_group_id (int): id of the case group to replace
"""
return self._execute_command(
replaceSourceCases=Cmd.ReplaceSourceCasesRequest(
gridListFile=grid_list_file, caseGroupId=case_group_id))
def create_grid_case_group(self, case_paths):
"""Create a Grid Case Group from a list of cases
@add_method(Project)
def create_grid_case_group(self, case_paths):
"""Create a Grid Case Group from a list of cases
Arguments:
case_paths (list): list of file path strings
Returns:
A case group id and name
"""
command_reply = self._execute_command(
createGridCaseGroup=Cmd.CreateGridCaseGroupRequest(
casePaths=case_paths))
return self.grid_case_group(
command_reply.createGridCaseGroupResult.groupId)
Arguments:
case_paths (list): list of file path strings
Returns:
A case group id and name
"""
command_reply = self._execute_command(
createGridCaseGroup=Cmd.CreateGridCaseGroupRequest(
casePaths=case_paths))
return self.grid_case_group(
command_reply.createGridCaseGroupResult.groupId)
def views(self):
"""Get a list of views belonging to a project"""
pdm_objects = self.descendants("ReservoirView")
view_list = []
for pdm_object in pdm_objects:
view_list.append(View(pdm_object, self._project))
return view_list
@add_method(Project)
def views(self):
"""Get a list of views belonging to a project"""
pdm_objects = self.descendants("ReservoirView")
view_list = []
for pdm_object in pdm_objects:
view_list.append(View(pdm_object))
return view_list
def view(self, view_id):
"""Get a particular view belonging to a case by providing view id
@add_method(Project)
def view(self, view_id):
"""Get a particular view belonging to a case by providing view id
Arguments:
view_id(int): view id
Returns: a view object
"""
views = self.views()
for view_object in views:
if view_object.view_id == view_id:
return view_object
return None
Arguments:
view_id(int): view id
Returns: a view object
"""
views = self.views()
for view_object in views:
if view_object.id == view_id:
return view_object
return None
def plots(self):
"""Get a list of all plots belonging to a project"""
pdm_objects = self.descendants("RimPlotWindow")
plot_list = []
for pdm_object in pdm_objects:
plot = Plot(pdm_object)
if plot.view_id != -1:
plot_list.append(plot)
return plot_list
@add_method(Project)
def plots(self):
"""Get a list of all plots belonging to a project"""
pdm_objects = self.descendants(PlotWindow)
plot_list = []
for pdm_object in pdm_objects:
if pdm_object.id != -1:
plot_list.append(pdm_object)
return plot_list
def plot(self, view_id):
"""Get a particular plot by providing view id
Arguments:
view_id(int): view id
Returns: a plot object
"""
plots = self.plots()
for plot_object in plots:
if plot_object.view_id == view_id:
return plot_object
return None
@add_method(Project)
def plot(self, view_id):
"""Get a particular plot by providing view id
Arguments:
view_id(int): view id
Returns: a plot object
"""
plots = self.plots()
for plot_object in plots:
if plot_object.id == view_id:
return plot_object
return None
def contour_maps(self, map_type=ContourMapType.ECLIPSE):
"""Get a list of all contour maps belonging to a project"""
@add_method(Project)
def contour_maps(self, map_type=ContourMapType.ECLIPSE):
"""Get a list of all contour maps belonging to a project"""
pdm_objects = self.descendants(ContourMapType.get_identifier(map_type))
contour_maps = []
for pdm_object in pdm_objects:
contour_maps.append(ContourMap(pdm_object, self._project, map_type))
return contour_maps
pdm_objects = self.descendants(ContourMapType.get_identifier(map_type))
contour_maps = []
for pdm_object in pdm_objects:
contour_maps.append(ContourMap(pdm_object, map_type))
return contour_maps
def well_paths(self):
"""Get a list of all the well path names in the project"""
pdm_objects = self.descendants("WellPathBase")
well_path_list = []
for pdm_object in pdm_objects:
well_path_list.append(pdm_object.get_value("WellPathName"))
return well_path_list
@add_method(Project)
def grid_case_groups(self):
"""Get a list of all grid case groups in the project"""
case_groups = self.descendants(GridCaseGroup)
return case_groups
def grid_case_groups(self):
"""Get a list of all grid case groups in the project"""
case_groups = self.descendants("RimIdenticalGridCaseGroup")
case_group_list = []
for pdm_group in case_groups:
case_group_list.append(GridCaseGroup(pdm_group))
return case_group_list
def grid_case_group(self, group_id):
"""Get a particular grid case group belonging to a project
@add_method(Project)
def grid_case_group(self, group_id):
"""Get a particular grid case group belonging to a project
Arguments:
groupId(int): group id
Arguments:
groupId(int): group id
Returns: a grid case group object
"""
case_groups = self.grid_case_groups()
for case_group in case_groups:
if case_group.group_id == group_id:
return case_group
return None
Returns: a grid case group object
"""
case_groups = self.grid_case_groups()
for case_group in case_groups:
if case_group.group_id == group_id:
return case_group
return None
def export_multi_case_snapshots(self, grid_list_file):
"""Export snapshots for a set of cases
@add_method(Project)
def export_multi_case_snapshots(self, grid_list_file):
"""Export snapshots for a set of cases
Arguments:
grid_list_file (str): Path to a file containing a list of grids to export snapshot for
"""
return self._execute_command(
exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest(
gridListFile=grid_list_file))
Arguments:
grid_list_file (str): Path to a file containing a list of grids to export snapshot for
"""
return self._execute_command(
exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest(
gridListFile=grid_list_file))
def export_snapshots(self, snapshot_type='ALL', prefix='', plot_format='PNG'):
""" Export all snapshots of a given type
@add_method(Project)
def export_snapshots(self, snapshot_type='ALL', prefix='', plot_format='PNG'):
""" Export all snapshots of a given type
Arguments:
snapshot_type (str): Enum string ('ALL', 'VIEWS' or 'PLOTS')
prefix (str): Exported file name prefix
plot_format(str): Enum string, 'PNG' or 'PDF'
"""
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(
type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1, plotOutputFormat=plot_format))
Arguments:
snapshot_type (str): Enum string ('ALL', 'VIEWS' or 'PLOTS')
prefix (str): Exported file name prefix
plot_format(str): Enum string, 'PNG' or 'PDF'
"""
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(
type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1, plotOutputFormat=plot_format))
def export_well_paths(self, well_paths=None, md_step_size=5.0):
""" Export a set of well paths
@add_method(Project)
def export_well_paths(self, well_paths=None, md_step_size=5.0):
""" Export a set of well paths
Arguments:
well_paths(list): List of strings of well paths. If none, export all.
md_step_size(double): resolution of the exported well path
"""
if well_paths is None:
well_paths = []
elif isinstance(well_paths, str):
well_paths = [well_paths]
return self._execute_command(exportWellPaths=Cmd.ExportWellPathRequest(
wellPathNames=well_paths, mdStepSize=md_step_size))
Arguments:
well_paths(list): List of strings of well paths. If none, export all.
md_step_size(double): resolution of the exported well path
"""
if well_paths is None:
well_paths = []
elif isinstance(well_paths, str):
well_paths = [well_paths]
return self._execute_command(exportWellPaths=Cmd.ExportWellPathRequest(
wellPathNames=well_paths, mdStepSize=md_step_size))
def scale_fracture_template(self, template_id, half_length, height,
d_factor, conductivity):
""" Scale fracture template parameters
@add_method(Project)
def scale_fracture_template(self, template_id, half_length, height,
d_factor, conductivity):
""" Scale fracture template parameters
Arguments:
template_id(int): ID of fracture template
half_length (double): Half Length scale factor
height (double): Height scale factor
d_factor (double): D-factor scale factor
conductivity (double): Conductivity scale factor
"""
return self._execute_command(
scaleFractureTemplate=Cmd.ScaleFractureTemplateRequest(
id=template_id,
halfLength=half_length,
height=height,
dFactor=d_factor,
conductivity=conductivity))
Arguments:
template_id(int): ID of fracture template
half_length (double): Half Length scale factor
height (double): Height scale factor
d_factor (double): D-factor scale factor
conductivity (double): Conductivity scale factor
"""
return self._execute_command(
scaleFractureTemplate=Cmd.ScaleFractureTemplateRequest(
id=template_id,
halfLength=half_length,
height=height,
dFactor=d_factor,
conductivity=conductivity))
def set_fracture_containment(self, template_id, top_layer, base_layer):
""" Set fracture template containment parameters
@add_method(Project)
def set_fracture_containment(self, template_id, top_layer, base_layer):
""" Set fracture template containment parameters
Arguments:
template_id(int): ID of fracture template
top_layer (int): Top layer containment
base_layer (int): Base layer containment
"""
return self._execute_command(
setFractureContainment=Cmd.SetFracContainmentRequest(
id=template_id, topLayer=top_layer, baseLayer=base_layer))
Arguments:
template_id(int): ID of fracture template
top_layer (int): Top layer containment
base_layer (int): Base layer containment
"""
return self._execute_command(
setFractureContainment=Cmd.SetFracContainmentRequest(
id=template_id, topLayer=top_layer, baseLayer=base_layer))
def import_well_paths(self, well_path_files=None, well_path_folder=''):
""" Import well paths into project
@add_method(Project)
def import_well_paths(self, well_path_files=None, well_path_folder=''):
""" Import well paths into project
Arguments:
well_path_files(list): List of file paths to import
well_path_folder(str): A folder path containing files to import
Arguments:
well_path_files(list): List of file paths to import
well_path_folder(str): A folder path containing files to import
Returns:
A list of well path names (strings)
"""
if well_path_files is None:
well_path_files = []
Returns:
A list of WellPathBase objects
"""
if well_path_files is None:
well_path_files = []
res = self._execute_command(importWellPaths=Cmd.ImportWellPathsRequest(wellPathFolder=well_path_folder,
wellPathFiles=well_path_files))
return res.importWellPathsResult.wellPathNames
res = self._execute_command(importWellPaths=Cmd.ImportWellPathsRequest(wellPathFolder=well_path_folder,
wellPathFiles=well_path_files))
well_paths = []
for well_path_name in res.importWellPathsResult.wellPathNames:
well_paths.append(self.well_path_by_name(well_path_name))
return well_paths
def wells(self):
"""Get a list of all wells in the project
@add_method(Project)
def well_paths(self):
"""Get a list of all well paths 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
Returns:
A list of rips WellPathBase objects
"""
return self.descendants(WellPathBase)
@add_method(Project)
def well_path_by_name(self, well_path_name):
"""Get a specific well path by name from the project
def import_well_log_files(self, well_log_files=None, well_log_folder=''):
""" Import well log files into project
Returns:
A WellPathBase object
"""
all_well_paths = self.well_paths()
for well_path in all_well_paths:
if well_path.name == well_path_name:
return well_path
return None
Arguments:
well_log_files(list): List of file paths to import
well_log_folder(str): A folder path containing files to import
@add_method(Project)
def import_well_log_files(self, well_log_files=None, well_log_folder=''):
""" Import well log files into project
Returns:
A list of well path names (strings) that had logs imported
"""
Arguments:
well_log_files(list): List of file paths to import
well_log_folder(str): A folder path containing files to import
if well_log_files is None:
well_log_files = []
res = self._execute_command(importWellLogFiles=Cmd.ImportWellLogFilesRequest(wellLogFolder=well_log_folder,
wellLogFiles=well_log_files))
return res.importWellLogFilesResult.wellPathNames
Returns:
A list of well path names (strings) that had logs imported
"""
def import_formation_names(self, formation_files=None):
""" Import formation names into project
if well_log_files is None:
well_log_files = []
res = self._execute_command(importWellLogFiles=Cmd.ImportWellLogFilesRequest(wellLogFolder=well_log_folder,
wellLogFiles=well_log_files))
return res.importWellLogFilesResult.wellPathNames
Arguments:
formation_files(list): list of files to import
@add_method(Project)
def import_formation_names(self, formation_files=None):
""" Import formation names into project
"""
if formation_files is None:
formation_files = []
elif isinstance(formation_files, str):
formation_files = [formation_files]
Arguments:
formation_files(list): list of files to import
res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
applyToCaseId=-1))
"""
if formation_files is None:
formation_files = []
elif isinstance(formation_files, str):
formation_files = [formation_files]
res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
applyToCaseId=-1))

View File

@ -10,30 +10,29 @@ import rips.generated.Properties_pb2 as Properties_pb2
import rips.generated.Properties_pb2_grpc as Properties_pb2_grpc
import rips.generated.Commands_pb2 as Cmd
from rips.generated.pdm_objects import SimulationWell
from rips.pdmobject import PdmObject
from rips.pdmobject import PdmObject, add_method
import rips.case
class SimulationWell(PdmObject):
"""ResInsight simulation well class
@add_method(SimulationWell)
def __custom_init__(self, pb2_object, channel):
self._simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(channel)
Attributes:
name(string): Name of the well.
@add_method(SimulationWell)
def status(self, timestep):
sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case().id,
well_name=self.name,
timestep=timestep)
return self._simulation_well_stub.GetSimulationWellStatus(sim_well_request)
"""
def __init__(self, name, case_id, pdm_object):
PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project())
self._simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(pdm_object.channel())
self.name = name
self.case_id = case_id
@add_method(SimulationWell)
def cells(self, timestep):
sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case().id,
well_name=self.name,
timestep=timestep)
return self._simulation_well_stub.GetSimulationWellCells(sim_well_request).data
def status(self, timestep):
sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case_id,
well_name=self.name,
timestep=timestep)
return self._simulation_well_stub.GetSimulationWellStatus(sim_well_request)
def cells(self, timestep):
sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case_id,
well_name=self.name,
timestep=timestep)
return self._simulation_well_stub.GetSimulationWellCells(sim_well_request).data
@add_method(SimulationWell)
def case(self):
return self.ancestor(rips.case.Case)

View File

@ -20,7 +20,7 @@ def test_EmptyProject(rips_instance, initialize_test):
def test_OneCase(rips_instance, initialize_test):
case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
assert(case.name == "TEST10K_FLT_LGR_NNC")
assert(case.case_id == 0)
assert(case.id == 0)
cases = rips_instance.project.cases()
assert(len(cases) is 1)
@ -120,11 +120,9 @@ def test_10k(rips_instance, initialize_test):
def test_PdmObject(rips_instance, initialize_test):
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
case = rips_instance.project.load_case(path=case_path)
assert(case.case_id == 0)
assert(case.id == 0)
assert(case.address() is not 0)
assert(case.class_keyword() == "EclipseCase")
case_id = case.get_value('CaseId')
assert(case_id == case.case_id)
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
def test_brugge_0010(rips_instance, initialize_test):
@ -146,21 +144,21 @@ def test_replaceCase(rips_instance, initialize_test):
case = project.case(case_id=0)
assert(case is not None)
assert(case.name == "TEST10K_FLT_LGR_NNC")
assert(case.case_id == 0)
assert(case.id == 0)
cases = rips_instance.project.cases()
assert(len(cases) is 1)
case.replace(new_grid_file=case_path)
# Check that the case object has been changed
assert(case.name == "Real0--BRUGGE_0000.EGRID")
assert(case.case_id == 0)
assert(case.id == 0)
cases = rips_instance.project.cases()
assert(len(cases) is 1)
# Check that retrieving the case object again will yield the changed object
case = project.case(case_id=0)
assert(case.name == "Real0--BRUGGE_0000.EGRID")
assert(case.case_id == 0)
assert(case.id == 0)
def test_loadNonExistingCase(rips_instance, initialize_test):
case_path = "Nonsense/Nonsense/Nonsense"

View File

@ -14,7 +14,7 @@ def test_loadProject(rips_instance, initialize_test):
case = project.cases()[0]
assert(case is not None)
assert(case.name == "TEST10K_FLT_LGR_NNC")
assert(case.case_id == 0)
assert(case.id == 0)
cases = rips_instance.project.cases()
assert(len(cases) is 1)
@ -23,15 +23,17 @@ def test_well_log_plots(rips_instance, initialize_test):
plots = project.plots()
well_log_plots = []
for plot in plots:
well_log_plot = rips.WellLogPlot.from_pdm_object(plot)
well_log_plot = plot.cast(rips.WellLogPlot)
if well_log_plot is not None:
assert(well_log_plot.depth_type() == "MEASURED_DEPTH")
well_log_plot.print_object_info()
assert(well_log_plot.depth_type == "MEASURED_DEPTH")
well_log_plots.append(well_log_plot)
assert(len(well_log_plots) == 2)
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
for well_log_plot in well_log_plots:
well_log_plot.set_depth_type("TRUE_VERTICAL_DEPTH_RKB")
well_log_plot.depth_type = "TRUE_VERTICAL_DEPTH_RKB"
well_log_plot.update()
if rips_instance.is_gui():
well_log_plot.export_snapshot(tmpdirname)
well_log_plot.export_data_as_las(tmpdirname)
@ -44,9 +46,9 @@ def test_well_log_plots(rips_instance, initialize_test):
plots2 = project.plots()
for plot2 in plots2:
well_log_plot2 = rips.WellLogPlot.from_pdm_object(plot)
well_log_plot2 = plot2.cast(rips.WellLogPlot)
if well_log_plot2 is not None:
assert(well_log_plot2.depth_type() == "TRUE_VERTICAL_DEPTH_RKB")
assert(well_log_plot2.depth_type == "TRUE_VERTICAL_DEPTH_RKB")
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
def test_loadGridCaseGroup(rips_instance, initialize_test):

View File

@ -12,8 +12,8 @@ def test_10k(rips_instance, initialize_test):
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()
well_path_names = rips_instance.project.import_well_paths(well_path_files)
wells = rips_instance.project.well_paths()
assert(len(wells) == 2)
assert(wells[0].name == "Well Path A")
assert(wells[1].name == "Well Path B")

View File

@ -1,217 +1,201 @@
"""
ResInsight 3d view module
"""
import builtins
import rips.generated.Commands_pb2 as Cmd
import rips.case # Circular import of Case, which already imports View. Use full name.
from rips.pdmobject import PdmObject
from rips.pdmobject import add_method
from rips.generated.pdm_objects import View, ViewWindow, ReservoirView, GeoMechView
@add_method(View)
def is_eclipse_view(self):
return isinstance(self, ReservoirView)
class View(PdmObject):
"""ResInsight view class
@add_method(View)
def is_geomech_view(self):
return isinstance(self, GeoMechView)
Attributes:
view_id(int): View Id corresponding to the View Id in ResInsight project.
@add_method(View)
def cell_result(self):
"""Retrieve the current cell results"""
return self.children("GridCellResult")[0]
@add_method(View)
def apply_cell_result(self, result_type, result_variable):
"""Apply a regular cell result
Arguments:
result_type (str): String representing the result category. The valid values are
- DYNAMIC_NATIVE
- STATIC_NATIVE
- SOURSIMRL
- GENERATED
- INPUT_PROPERTY
- FORMATION_NAMES
- FLOW_DIAGNOSTICS
- INJECTION_FLOODING
result_variable (str): String representing the result variable.
"""
cell_result = self.cell_result()
cell_result.result_type = result_type
cell_result.result_variable = result_variable
cell_result.update()
@add_method(View)
def apply_flow_diagnostics_cell_result(
self,
result_variable='TOF',
selection_mode='FLOW_TR_BY_SELECTION',
injectors=None,
producers=None):
"""Apply a flow diagnostics cell result
Parameter | Description | Type
------------------- | ------------------------------------------------------ | -----
result_variable | String representing the result value | String
selection_mode | String specifying which tracers to select | String
injectors | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List
producers | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List
##### Enum compdat_export
Option | Description
------------------------| ------------
"TOF" | Time of flight
"Fraction" | Fraction
"MaxFractionTracer" | Max Fraction Tracer
"Communication" | Communication
"""
def __init__(self, pdm_object, project):
PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), project)
self.view_id = pdm_object.get_value("ViewId")
if injectors is None:
injectors = []
if producers is None:
producers = []
cell_result = self.cell_result()
cell_result.result_type = "FLOW_DIAGNOSTICS"
cell_result.result_variable = result_variable
cell_result.flow_tracer_selection_mode = selection_mode
if selection_mode == 'FLOW_TR_BY_SELECTION':
cell_result.selected_injector_tracers = injectors
cell_result.selected_producer_tracers = producers
cell_result.update()
def is_eclipse_view(self):
return self.class_keyword() == "ReservoirView"
@add_method(View)
def clone(self):
"""Clone the current view"""
view_id = self._execute_command(cloneView=Cmd.CloneViewRequest(
viewId=self.id)).createViewResult.viewId
return self.case().view(view_id)
def is_geomech_view(self):
return self.class_keyword() == "GeoMechView"
@add_method(View)
def set_time_step(self, time_step):
"""Set the time step for current view"""
case_id = self.case().id
return self._execute_command(setTimeStep=Cmd.SetTimeStepParams(
caseId=case_id, viewId=self.id, timeStep=time_step))
def show_grid_box(self):
"""Check if the grid box is meant to be shown in the view"""
return self.get_value("ShowGridBox")
@add_method(View)
def export_sim_well_fracture_completions(self, time_step,
simulation_well_names, file_split,
compdat_export):
"""Export fracture completions for simulation wells
def set_show_grid_box(self, value):
"""Set if the grid box is meant to be shown in the view"""
self.set_value("ShowGridBox", value)
Parameter | Description | Type
----------------------------| ------------------------------------------------ | -----
time_step | Time step to export for | Integer
simulation_well_names | List of simulation well names | List
file_split | Controls how export data is split into files | String enum
compdat_export | Compdat export type | String enum
def background_color(self):
"""Get the current background color in the view"""
return self.get_value("ViewBackgroundColor")
##### Enum file_split
def set_background_color(self, bgcolor):
"""Set the background color in the view"""
self.set_value("ViewBackgroundColor", bgcolor)
Option | Description
----------------------------------- | ------------
"UNIFIED_FILE" <b>Default Option</b>| A single file with all transmissibilities
"SPLIT_ON_WELL" | One file for each well transmissibilities
"SPLIT_ON_WELL_AND_COMPLETION_TYPE" | One file for each completion type for each well
def set_cell_result(self):
"""Retrieve the current cell results"""
return self.children("GridCellResult")[0]
##### Enum compdat_export
def apply_cell_result(self, result_type, result_variable):
"""Apply a regular cell result
Option | Description
-----------------------------------------| ------------
"TRANSMISSIBILITIES"<b>Default Option</b>| Direct export of transmissibilities
"WPIMULT_AND_DEFAULT_CONNECTION_FACTORS" | Include export of WPIMULT
Arguments:
result_type (str): String representing the result category. The valid values are
- DYNAMIC_NATIVE
- STATIC_NATIVE
- SOURSIMRL
- GENERATED
- INPUT_PROPERTY
- FORMATION_NAMES
- FLOW_DIAGNOSTICS
- INJECTION_FLOODING
result_variable (str): String representing the result variable.
"""
cell_result = self.set_cell_result()
cell_result.set_value("ResultType", result_type)
cell_result.set_value("ResultVariable", result_variable)
cell_result.update()
"""
if isinstance(simulation_well_names, str):
simulation_well_names = [simulation_well_names]
def apply_flow_diagnostics_cell_result(
self,
result_variable='TOF',
selection_mode='FLOW_TR_BY_SELECTION',
injectors=None,
producers=None):
"""Apply a flow diagnostics cell result
case_id = self.case().id
return self._execute_command(
exportSimWellFractureCompletions=Cmd.ExportSimWellPathFracRequest(
caseId=case_id,
viewId=self.id,
timeStep=time_step,
simulationWellNames=simulation_well_names,
fileSplit=file_split,
compdatExport=compdat_export))
Parameter | Description | Type
------------------- | ------------------------------------------------------ | -----
result_variable | String representing the result value | String
selection_mode | String specifying which tracers to select | String
injectors | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List
producers | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List
@add_method(View)
def export_visible_cells(self,
export_keyword='FLUXNUM',
visible_active_cells_value=1,
hidden_active_cells_value=0,
inactive_cells_value=0):
"""Export special properties for all visible cells.
##### Enum compdat_export
Arguments:
export_keyword (string): The keyword to export.
Choices: 'FLUXNUM' or 'MULTNUM'. Default: 'FLUXNUM'
visible_active_cells_value (int): Value to export forvisible active cells. Default: 1
hidden_active_cells_value (int): Value to export for hidden active cells. Default: 0
inactive_cells_value (int): Value to export for inactive cells. Default: 0
"""
case_id = self.case().id
return self._execute_command(
exportVisibleCells=Cmd.ExportVisibleCellsRequest(
caseId=case_id,
viewId=self.id,
exportKeyword=export_keyword,
visibleActiveCellsValue=visible_active_cells_value,
hiddenActiveCellsValue=hidden_active_cells_value,
inactiveCellsValue=inactive_cells_value))
Option | Description
------------------------| ------------
"TOF" | Time of flight
"Fraction" | Fraction
"MaxFractionTracer" | Max Fraction Tracer
"Communication" | Communication
@add_method(View)
def export_property(self, undefined_value=0.0):
""" Export the current Eclipse property from the view
"""
if injectors is None:
injectors = []
if producers is None:
producers = []
cell_result = self.set_cell_result()
cell_result.set_value("ResultType", "FLOW_DIAGNOSTICS")
cell_result.set_value("ResultVariable", result_variable)
cell_result.set_value("FlowTracerSelectionMode", selection_mode)
if selection_mode == 'FLOW_TR_BY_SELECTION':
cell_result.set_value("SelectedInjectorTracers", injectors)
cell_result.set_value("SelectedProducerTracers", producers)
cell_result.update()
Arguments:
undefined_value (double): Value to use for undefined values. Defaults to 0.0
"""
case_id = self.case().id
return self._execute_command(
exportPropertyInViews=Cmd.ExportPropertyInViewsRequest(
caseId=case_id,
viewIds=[self.id],
undefinedValue=undefined_value))
def case(self):
"""Get the case the view belongs to"""
pdm_case = self.ancestor("EclipseCase")
if pdm_case is None:
pdm_case = self.ancestor("ResInsightGeoMechCase")
if pdm_case is None:
return None
return rips.case.Case(self._channel, pdm_case.get_value("CaseId"), self._project)
@add_method(ViewWindow)
def case(self):
"""Get the case the view belongs to"""
mycase = self.ancestor(rips.case.Case)
assert(mycase is not None)
return mycase
def clone(self):
"""Clone the current view"""
view_id = self._execute_command(cloneView=Cmd.CloneViewRequest(
viewId=self.view_id)).createViewResult.viewId
return self.case().view(view_id)
def set_time_step(self, time_step):
"""Set the time step for current view"""
case_id = self.case().case_id
return self._execute_command(setTimeStep=Cmd.SetTimeStepParams(
caseId=case_id, viewId=self.view_id, timeStep=time_step))
def export_sim_well_fracture_completions(self, time_step,
simulation_well_names, file_split,
compdat_export):
"""Export fracture completions for simulation wells
Parameter | Description | Type
----------------------------| ------------------------------------------------ | -----
time_step | Time step to export for | Integer
simulation_well_names | List of simulation well names | List
file_split | Controls how export data is split into files | String enum
compdat_export | Compdat export type | String enum
##### Enum file_split
Option | Description
----------------------------------- | ------------
"UNIFIED_FILE" <b>Default Option</b>| A single file with all transmissibilities
"SPLIT_ON_WELL" | One file for each well transmissibilities
"SPLIT_ON_WELL_AND_COMPLETION_TYPE" | One file for each completion type for each well
##### Enum compdat_export
Option | Description
-----------------------------------------| ------------
"TRANSMISSIBILITIES"<b>Default Option</b>| Direct export of transmissibilities
"WPIMULT_AND_DEFAULT_CONNECTION_FACTORS" | Include export of WPIMULT
"""
if isinstance(simulation_well_names, str):
simulation_well_names = [simulation_well_names]
case_id = self.case().case_id
return self._execute_command(
exportSimWellFractureCompletions=Cmd.ExportSimWellPathFracRequest(
caseId=case_id,
viewId=self.view_id,
timeStep=time_step,
simulationWellNames=simulation_well_names,
fileSplit=file_split,
compdatExport=compdat_export))
def export_visible_cells(self,
export_keyword='FLUXNUM',
visible_active_cells_value=1,
hidden_active_cells_value=0,
inactive_cells_value=0):
"""Export special properties for all visible cells.
Arguments:
export_keyword (string): The keyword to export.
Choices: 'FLUXNUM' or 'MULTNUM'. Default: 'FLUXNUM'
visible_active_cells_value (int): Value to export forvisible active cells. Default: 1
hidden_active_cells_value (int): Value to export for hidden active cells. Default: 0
inactive_cells_value (int): Value to export for inactive cells. Default: 0
"""
case_id = self.case().case_id
return self._execute_command(
exportVisibleCells=Cmd.ExportVisibleCellsRequest(
caseId=case_id,
viewId=self.view_id,
exportKeyword=export_keyword,
visibleActiveCellsValue=visible_active_cells_value,
hiddenActiveCellsValue=hidden_active_cells_value,
inactiveCellsValue=inactive_cells_value))
def export_property(self, undefined_value=0.0):
""" Export the current Eclipse property from the view
Arguments:
undefined_value (double): Value to use for undefined values. Defaults to 0.0
"""
case_id = self.case().case_id
return self._execute_command(
exportPropertyInViews=Cmd.ExportPropertyInViewsRequest(
caseId=case_id,
viewIds=[self.view_id],
undefinedValue=undefined_value))
def export_snapshot(self, prefix='', export_folder=''):
""" Export snapshot for the current view
@add_method(ViewWindow)
def export_snapshot(self, prefix='', export_folder=''):
""" Export snapshot for the current view
Arguments:
prefix (str): Exported file name prefix
export_folder(str): The path to export to. By default will use the global export folder
"""
case_id = self.case().case_id
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='VIEWS',
prefix=prefix,
caseId=case_id,
viewId=self.view_id,
exportFolder=export_folder))
Arguments:
prefix (str): Exported file name prefix
export_folder(str): The path to export to. By default will use the global export folder
"""
case_id = self.case().id
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='VIEWS',
prefix=prefix,
caseId=case_id,
viewId=self.id,
exportFolder=export_folder))

View File

@ -1,17 +0,0 @@
"""
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

View File

@ -2,124 +2,44 @@
ResInsight Well Bore Stability Plot module
"""
from rips.pdmobject import PdmObject
from rips.pdmobject import PdmObject, add_method
from rips.well_log_plot import WellLogPlot
from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters
class WbsParameters:
"""Well Bore Stability parameters
Note that any parameter sources left at "UNDEFINED" will get ResInsight defaults
which depends on the available data.
@add_method(WbsParameters)
def __custom_init__(self, pb2_object=None, channel=None):
self.pore_pressure_reservoir_source = "UNDEFINED"
self.pore_pressure_non_reservoir_source = "UNDEFINED"
self.poisson_ratio_source = "UNDEFINED"
self.ucs_source = "UNDEFINED"
self.obg0_source = "UNDEFINED"
self.df_source = "UNDEFINED"
self.k0sh_source = "UNDEFINED"
self.fg_shale_source = "UNDEFINED"
self.k0fg_source = "UNDEFINED"
Attributes:
pore_pressure_in_reservoir_source(enum string): can be "GRID", "LAS_FILE" and "ELEMENT_PROPERTY_TABLE".
pore_pressure_outside_reservoir_source(enum string): can be "HYDROSTATIC" and "USER_DEFINED".
poisson_ratio_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED".
ucs_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED".
obg0_source(enum string): can be "GRID" or "LAS_FILE".
df_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED".
fg_shale_source(enum string): can be "DERIVED_FROM_K0FG" or "PROPORTIONAL_TO_SH".
k0fg_source(enum string): can be "LAS_FILE" or "USER_DEFINED"". Only relevant if fg_shale_source is "DERIVED_FROM_K0FG".
self.user_pp_non_reservoir = 1.05
self.user_poission_ratio = 0.35
self.user_ucs = 100
self.user_df = 0.7
self.user_k0sh = 0.65
self.fg_multiplier = 1.05
self.user_k0fg = 0.75
user_pp_outside_reservoir(double): Used if pore_pressure_outside_reservoir_source is "USED_DEFINED". Default 1.05.
user_poission_ratio(double): Used if poisson_ratio_source is "USER_DEFINED", default 0.35.
user_ucs(double): Used if ucs_soruce is "USER_DEFINED", default 100.
user_df(double): Used if df is "USER_DEFINED", default 0.7.
user_k0sh(double): Used if k0sh_source is "USER_DEFINED", default 0.65.
fg_shale_sh_multiplier(double): Used if fg_shale_source is "PROPORTIONAL_TO_SH", default 1.05.
user_k0fg(double): Used if fg_shale_source is "DERIVED_FROM_K0FG" and k0fg_source is "USER_DEFINED", default 0.75.
"""
@add_method(WellBoreStabilityPlot)
def parameters(self):
"""Retrieve the parameters of the Plot
"""
children = self.children("WbsParameters", WbsParameters)
if len(children) == 1:
child = children[0]
return child
return None
def __init__(self):
self.pore_pressure_in_reservoir_source = "UNDEFINED"
self.pore_pressure_outside_reservoir_source = "UNDEFINED"
self.poisson_ratio_source = "UNDEFINED"
self.ucs_source = "UNDEFINED"
self.obg0_source = "UNDEFINED"
self.df_source = "UNDEFINED"
self.k0sh_source = "UNDEFINED"
self.fg_shale_source = "UNDEFINED"
self.k0fg_source = "UNDEFINED"
self.user_pp_outside_reservoir = 1.05
self.user_poission_ratio = 0.35
self.user_ucs = 100
self.user_df = 0.7
self.user_k0sh = 0.65
self.fg_shale_multiplier = 1.05
self.user_k0fg = 0.75
@classmethod
def from_pdm_object(cls, pdm_object):
params = cls()
params.pore_pressure_in_reservoir_source = pdm_object.get_value("PorePressureReservoirSource")
params.pore_pressure_outside_reservoir_source = pdm_object.get_value("PorePressureNonReservoirSource")
params.poisson_ratio_source = pdm_object.get_value("PoissonRatioSource")
params.ucs_source = pdm_object.get_value("UcsSource")
params.obg0_source = pdm_object.get_value("OBG0Source")
params.df_source = pdm_object.get_value("DFSource")
params.k0sh_source = pdm_object.get_value("K0SHSource")
params.fg_shale_source = pdm_object.get_value("FGShaleSource")
params.k0fg_source = pdm_object.get_value("K0FGSource")
params.user_pp_outside_reservoir = pdm_object.get_value("UserPPNonReservoir")
params.user_poisson_ratio = pdm_object.get_value("UserPoissonRatio")
params.user_ucs = pdm_object.get_value("UserUcs")
params.user_df = pdm_object.get_value("UserDF")
params.user_k0fg = pdm_object.get_value("UserK0FG")
params.user_k0sh = pdm_object.get_value("UserK0SH")
params.user_fg_shale = pdm_object.get_value("FGMultiplier")
return params
def to_pdm_object(self, pdm_object):
pdm_object.set_value("PorePressureReservoirSource", self.pore_pressure_in_reservoir_source)
pdm_object.set_value("PorePressureNonReservoirSource", self.pore_pressure_outside_reservoir_source)
pdm_object.set_value("UserPPNonReservoir", self.user_pp_outside_reservoir)
pdm_object.set_value("PoissonRatioSource", self.poisson_ratio_source)
pdm_object.set_value("UcsSource", self.ucs_source)
pdm_object.set_value("OBG0Source", self.obg0_source)
pdm_object.set_value("DFSource", self.df_source)
pdm_object.set_value("K0SHSource", self.k0sh_source)
pdm_object.set_value("FGShaleSource", self.fg_shale_source)
pdm_object.set_value("K0FGSource", self.k0fg_source)
pdm_object.set_value("UserPoissonRatio", self.user_poisson_ratio)
pdm_object.set_value("UserUcs", self.user_ucs)
pdm_object.set_value("UserDF", self.user_df)
pdm_object.set_value("UserK0FG", self.user_k0fg)
pdm_object.set_value("UserK0SH", self.user_k0sh)
pdm_object.set_value("FGMultiplier", self.user_fg_shale)
class WellBoreStabilityPlot(WellLogPlot):
"""ResInsight Well Bore Stability Plot
"""
def __init__(self, pdm_object):
WellLogPlot.__init__(self, pdm_object)
@classmethod
def from_pdm_object(cls, pdm_object):
if isinstance(pdm_object, PdmObject):
if pdm_object.class_keyword() == "WellBoreStabilityPlot":
return cls(pdm_object)
return None
def parameters(self):
"""Retrieve the parameters of the Plot
"""
children = self.children("WbsParameters")
if len(children) == 1:
child = children[0]
return WbsParameters.from_pdm_object(child)
return None
def set_parameters(self, wbs_parameters):
children = self.children("WbsParameters")
if len(children) == 1:
pdm_params = children[0]
wbs_parameters.to_pdm_object(pdm_params)
pdm_params.update()
@add_method(WellBoreStabilityPlot)
def set_parameters(self, wbs_parameters):
children = self.children("WbsParameters", WbsParameters)
if len(children) == 1:
pdm_params = children[0]
pdm_params.copy_from(wbs_parameters)

View File

@ -6,115 +6,50 @@ import rips.generated.Commands_pb2 as Cmd
from rips.plot import Plot
from rips.pdmobject import PdmObject
from rips.generated.pdm_objects import WellLogPlot
from rips.pdmobject import add_method
class WellLogPlot(Plot):
"""ResInsight well log plot class
@add_method(WellLogPlot)
def export_data_as_las(self, export_folder, file_prefix='', export_tvdrkb=False, capitalize_file_names=False, resample_interval=0.0, convert_to_standard_units=False):
""" Export LAS file(s) for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
file_prefix (str): Exported file name prefix
export_tvdrkb(bool): Export in TVD-RKB format
capitalize_file_names(bool): Make all file names upper case
resample_interval(double): if > 0.0 the files will be resampled
Returns:
A list of files exported
"""
res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='LAS',
viewId=self.id,
exportFolder=export_folder,
filePrefix=file_prefix,
exportTvdRkb=export_tvdrkb,
capitalizeFileNames=capitalize_file_names,
resampleInterval=resample_interval,
convertCurveUnits=convert_to_standard_units))
return res.exportWellLogPlotDataResult.exportedFiles
@add_method(WellLogPlot)
def export_data_as_ascii(self, export_folder, file_prefix='', capitalize_file_names=False):
""" Export LAS file(s) for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
file_prefix (str): Exported file name prefix
capitalize_file_names(bool): Make all file names upper case
Returns:
A list of files exported
"""
def __init__(self, pdm_object):
Plot.__init__(self, pdm_object)
@classmethod
def from_pdm_object(cls, pdm_object):
if isinstance(pdm_object, PdmObject):
if pdm_object.class_keyword() == "WellLogPlot":
return cls(pdm_object)
return None
def export_data_as_las(self, export_folder, file_prefix='', export_tvdrkb=False, capitalize_file_names=False, resample_interval=0.0, convert_to_standard_units=False):
""" Export LAS file(s) for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
file_prefix (str): Exported file name prefix
export_tvdrkb(bool): Export in TVD-RKB format
capitalize_file_names(bool): Make all file names upper case
resample_interval(double): if > 0.0 the files will be resampled
Returns:
A list of files exported
"""
res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='LAS',
viewId=self.view_id,
exportFolder=export_folder,
filePrefix=file_prefix,
exportTvdRkb=export_tvdrkb,
capitalizeFileNames=capitalize_file_names,
resampleInterval=resample_interval,
convertCurveUnits=convert_to_standard_units))
return res.exportWellLogPlotDataResult.exportedFiles
def export_data_as_ascii(self, export_folder, file_prefix='', capitalize_file_names=False):
""" Export LAS file(s) for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
file_prefix (str): Exported file name prefix
capitalize_file_names(bool): Make all file names upper case
Returns:
A list of files exported
"""
res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='ASCII',
viewId=self.view_id,
exportFolder=export_folder,
filePrefix=file_prefix,
exportTvdRkb=False,
capitalizeFileNames=capitalize_file_names,
resampleInterval=0.0))
return res.exportWellLogPlotDataResult.exportedFiles
def depth_range(self):
"""Get the depth range of the Plot
"""
return self.get_value("MinimumDepth"), self.get_value("MaximumDepth")
def set_depth_range(self, min_depth, max_depth, update=True):
""" Set the visible depth range minimum
Arguments:
min_depth(double): The new minimum depth
max_depth(double): The new maximum depth
update(bool, optional): Update the plot after setting the value?
"""
self.set_value("MinimumDepth", min_depth)
self.set_value("MaximumDepth", max_depth)
self.set_value("AutoScaleDepthEnabled", False)
if update:
self.update()
def depth_type(self):
"""Get the plot depth type
Returns: an enum string. Can be "MEASURED_DEPTH", "TRUE_VERTICAL_DEPTH" or "TRUE_VERTICAL_DEPTH_RKB".
"""
return self.get_value("DepthType")
def set_depth_type(self, depth_type, update=True):
"""Set the depth type
Arguments:
depth_type(enum string): can be "MEASURED_DEPTH", "TRUE_VERTICAL_DEPTH" or "TRUE_VERTICAL_DEPTH_RKB".
update(bool, optional): Update the plot after setting the value?
"""
self.set_value("DepthType", depth_type)
if update:
self.update()
def depth_unit(self):
"""Get the plot depth units
Returns: an enum string. Can be "UNIT_METER", "UNIT_FEET" or "UNIT_NONE".
"""
def set_depth_unit(self, depth_unit, update=True):
"""Set the depth unit
Arguments:
depth_unit(enum string): can be "UNIT_METER", "UNIT_FEET" or "UNIT_NONE".
update(bool, optional): Update the plot after setting the value?
"""
self.set_value("DepthUnit", depth_unit)
if update:
self.update()
res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='ASCII',
viewId=self.id,
exportFolder=export_folder,
filePrefix=file_prefix,
exportTvdRkb=False,
capitalizeFileNames=capitalize_file_names,
resampleInterval=0.0))
return res.exportWellLogPlotDataResult.exportedFiles

View File

@ -0,0 +1,6 @@
"""
ResInsight Well
"""
import rips.generated.Commands_pb2 as Cmd
from rips.generated.pdm_objects import WellPathBase

View File

@ -74,7 +74,7 @@ void caf::AppEnum<Rim3dView::SurfaceModeType>::setUp()
} // End namespace caf
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( Rim3dView, "GenericView" ); // Do not use. Abstract class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( Rim3dView, "View", "GenericView" ); // Do not use. Abstract class
//--------------------------------------------------------------------------------------------------
///
@ -86,7 +86,10 @@ Rim3dView::Rim3dView( void )
RiaPreferences* preferences = app->preferences();
CVF_ASSERT( preferences );
RICF_InitField( &m_id, "ViewId", -1, "View ID", "", "", "" );
CAF_PDM_InitObject( "3d View", "", "", "" );
RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" );
m_id.xmlCapability()->registerKeywordAlias( "ViewId" );
m_id.uiCapability()->setUiReadOnly( true );
m_id.uiCapability()->setUiHidden( true );
m_id.capability<RicfFieldHandle>()->setIOWriteable( false );
@ -104,20 +107,21 @@ Rim3dView::Rim3dView( void )
CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "" );
m_cameraPointOfInterest.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" );
RICF_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" );
double defaultScaleFactor = preferences->defaultScaleFactorZ();
CAF_PDM_InitField( &scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "" );
RICF_InitField( &scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "" );
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
RICF_InitField( &m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", "" );
RICF_InitField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background", "", "", "" );
m_backgroundColor.xmlCapability()->registerKeywordAlias( "ViewBackgroundColor" );
CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", "" );
maximumFrameRate.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", "" );
hasUserRequestedAnimation.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "" );
RICF_InitField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "" );
m_currentTimeStep.uiCapability()->setUiHidden( true );
caf::AppEnum<RiaDefines::MeshModeType> defaultMeshType = preferences->defaultMeshModeType();
@ -126,15 +130,15 @@ Rim3dView::Rim3dView( void )
RICF_InitField( &m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "" );
CAF_PDM_InitField( &m_disableLighting,
"DisableLighting",
false,
"Disable Results Lighting",
"",
"Disable light model for scalar result colors",
"" );
RICF_InitField( &m_disableLighting,
"DisableLighting",
false,
"Disable Results Lighting",
"",
"Disable light model for scalar result colors",
"" );
CAF_PDM_InitField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "" );
RICF_InitField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_comparisonView, "ComparisonView", "Comparison View", "", "", "" );
@ -880,8 +884,11 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const
}
else if ( changedField == &m_showZScaleLabel )
{
m_viewer->showZScaleLabel( m_showZScaleLabel() );
m_viewer->update();
if ( m_viewer )
{
m_viewer->showZScaleLabel( m_showZScaleLabel() );
m_viewer->update();
}
}
else if ( changedField == &m_comparisonView )
{

View File

@ -110,7 +110,7 @@
#include <climits>
CAF_PDM_SOURCE_INIT( RimEclipseView, "ReservoirView" );
CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT( RimEclipseView, "ReservoirView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -120,7 +120,7 @@ RimEclipseView::RimEclipseView()
RiaPreferences* preferences = app->preferences();
CVF_ASSERT( preferences );
CAF_PDM_InitObject( "Reservoir View", ":/3DView16x16.png", "", "" );
CAF_PDM_InitObject( "Reservoir View", ":/3DView16x16.png", "", "The Eclipse 3d Reservoir View" );
CAF_PDM_InitFieldNoDefault( &m_cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", "" );
m_cellResult = new RimEclipseCellColors();

View File

@ -5,7 +5,7 @@
#include "RimTools.h"
#include "cafUtils.h"
CAF_PDM_SOURCE_INIT( RimFileWellPath, "WellPath" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimFileWellPath, "WellPath" );
//--------------------------------------------------------------------------------------------------
///

View File

@ -77,7 +77,7 @@
#include <QMessageBox>
CAF_PDM_SOURCE_INIT( RimGeoMechView, "GeoMechView" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimGeoMechView, "GeoMechView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -87,7 +87,7 @@ RimGeoMechView::RimGeoMechView( void )
RiaPreferences* preferences = app->preferences();
CVF_ASSERT( preferences );
CAF_PDM_InitObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "" );
CAF_PDM_InitObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" );
CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "" );
cellResult = new RimGeoMechCellColors();

View File

@ -48,7 +48,7 @@
#include <QDir>
#include <QMessageBox>
CAF_PDM_SOURCE_INIT( RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimIdenticalGridCaseGroup, "GridCaseGroup", "RimIdenticalGridCaseGroup" );
//--------------------------------------------------------------------------------------------------
///

View File

@ -32,7 +32,7 @@
#include "RimWellPathFractureCollection.h"
#include "cafPdmUiTreeOrdering.h"
CAF_PDM_SOURCE_INIT( RimModeledWellPath, "ModeledWellPath" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimModeledWellPath, "ModeledWellPath" );
//--------------------------------------------------------------------------------------------------
///

View File

@ -25,7 +25,7 @@ void RimPlot::RowOrColSpanEnum::setUp()
}
} // namespace caf
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "Plot", "RimPlot" ); // Do not use. Abstract class
//--------------------------------------------------------------------------------------------------
///

View File

@ -30,7 +30,7 @@
#include <QPainter>
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "RimPlotWindow" ); // Do not use. Abstract class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "PlotWindow", "RimPlotWindow" ); // Do not use. Abstract class
//--------------------------------------------------------------------------------------------------
///
@ -39,7 +39,8 @@ RimPlotWindow::RimPlotWindow()
{
CAF_PDM_InitObject( "PlotWindow", "", "", "" );
RICF_InitField( &m_id, "ViewId", -1, "View ID", "", "", "" );
RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" );
m_id.xmlCapability()->registerKeywordAlias( "ViewId" );
m_id.uiCapability()->setUiReadOnly( true );
m_id.uiCapability()->setUiHidden( true );
m_id.capability<RicfFieldHandle>()->setIOWriteable( false );

View File

@ -101,7 +101,7 @@
#include <QMenu>
#include <algorithm>
CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimProject, "Project", "ResInsightProject" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -55,16 +55,17 @@
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* corresponding2dIntersectionView( RimSimWellInView* simWellInView );
CAF_PDM_SOURCE_INIT( RimSimWellInView, "Well" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimSimWellInView, "SimulationWell", "Well" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSimWellInView::RimSimWellInView()
{
CAF_PDM_InitObject( "Well", ":/Well.png", "", "" );
CAF_PDM_InitObject( "Simulation Well", ":/Well.png", "", "" );
RICF_InitFieldNoDefault( &name, "WellName", "Name", "", "", "" );
RICF_InitFieldNoDefault( &name, "Name", "Name", "", "", "" );
name.xmlCapability()->registerKeywordAlias( "WellName" );
CAF_PDM_InitField( &showWell, "ShowWell", true, "Show well ", "", "", "" );

View File

@ -26,7 +26,7 @@
#include "RimWellLogFile.h"
#include "RimWellPath.h"
CAF_PDM_SOURCE_INIT( RimWbsParameters, "WbsParameters" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWbsParameters, "WbsParameters" );
//--------------------------------------------------------------------------------------------------
///

View File

@ -33,7 +33,7 @@
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiGroup.h"
CAF_PDM_SOURCE_INIT( RimWellBoreStabilityPlot, "WellBoreStabilityPlot" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellBoreStabilityPlot, "WellBoreStabilityPlot" );
//--------------------------------------------------------------------------------------------------
///

View File

@ -64,14 +64,17 @@ void RimWellLogPlot::AxisGridEnum::setUp()
} // End namespace caf
CAF_PDM_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlot::RimWellLogPlot()
{
CAF_PDM_InitObject( "Well Log Plot", ":/WellLogPlot16x16.png", "", "" );
CAF_PDM_InitObject( "Well Log Plot",
":/WellLogPlot16x16.png",
"",
"A Well Log Plot With a shared Depth Axis and Multiple Tracks" );
CAF_PDM_InitFieldNoDefault( &m_commonDataSource,
"CommonDataSource",

View File

@ -61,7 +61,7 @@
#include <regex>
CAF_PDM_SOURCE_INIT( RimWellPath, "WellPathBase" );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellPath, "WellPathBase" );
//--------------------------------------------------------------------------------------------------
///
@ -75,7 +75,8 @@ RimWellPath::RimWellPath()
{
CAF_PDM_InitObject( "WellPath", ":/Well.png", "", "" );
RICF_InitFieldNoDefault( &m_name, "WellPathName", "Name", "", "", "" );
RICF_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" );
m_name.xmlCapability()->registerKeywordAlias( "WellPathName" );
m_name.uiCapability()->setUiReadOnly( true );
m_name.uiCapability()->setUiHidden( true );
m_name.xmlCapability()->disableIO();