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

View File

@@ -14,10 +14,10 @@ if resinsight is not None:
print ("Got " + str(len(cases)) + " cases: ") print ("Got " + str(len(cases)) + " cases: ")
for case in 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 name: " + case.name)
print("Case type: " + case.type) 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()) print("Case reservoir bounding box:", case.reservoir_boundingbox())
timesteps = case.time_steps() timesteps = case.time_steps()

View File

@@ -13,7 +13,7 @@ if resinsight is not None:
cases = resinsight.project.cases() cases = resinsight.project.cases()
for case in 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 name: " + case.name)
timesteps = case.time_steps() timesteps = case.time_steps()

View File

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

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ print("Exporting to: " + export_folder)
for plot in plots: for plot in plots:
plot.export_snapshot(export_folder=export_folder) plot.export_snapshot(export_folder=export_folder)
plot.export_snapshot(export_folder=export_folder, output_format='PDF') 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: if well_log_plot is not None:
well_log_plot.export_data_as_las(export_folder=export_folder) 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") print ("Looping through cases")
for case in cases: for case in cases:
print("Case name: ", case.name) print("Case name: ", case.name)
print("Case id: ", case.case_id) print("Case id: ", case.id)
# Get grid path and its folder name # Get grid path and its folder name
case_path = case.grid_path() case_path = case.file_path
folder_name = os.path.dirname(case_path) folder_name = os.path.dirname(case_path)
# create a folder to hold the snapshots # create a folder to hold the snapshots

View File

@@ -3,24 +3,24 @@ import rips
# Connect to ResInsight instance # Connect to ResInsight instance
resInsight = rips.Instance.find() 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(): if resInsight.project.has_warnings():
for warning in resInsight.project.warnings(): for warning in resInsight.project.warnings():
print(warning) print(warning)
for well_path_name in well_path_names: for well_path in well_paths:
print("Imported from folder: " + well_path_name) 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']) 'D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/C-1H.json'])
if resInsight.project.has_warnings(): if resInsight.project.has_warnings():
for warning in resInsight.project.warnings(): for warning in resInsight.project.warnings():
print(warning) print(warning)
for well_path_name in well_path_names: for well_path in well_paths:
print("Imported from indivdual files: " + well_path_name) 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') 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() views = case.views()
for view in views: for view in views:
# Set some parameters for the view # Set some parameters for the view
view.set_show_grid_box(not view.show_grid_box()) view.show_grid_box = not view.show_grid_box
view.set_background_color("#3388AA") view.background_color = "#3388AA"
# Update the view in ResInsight # Update the view in ResInsight
view.update() view.update()
# Clone the first view # Clone the first view
new_view = views[0].clone() new_view = views[0].clone()
view.set_show_grid_box(False) new_view.background_color = "#FFAA33"
new_view.set_background_color("#FFAA33")
new_view.update() new_view.update()
view.show_grid_box = False
view.set_visible(False) view.set_visible(False)
view.update() view.update()

View File

@@ -10,7 +10,9 @@ from rips.instance import Instance
from rips.pdmobject import PdmObject from rips.pdmobject import PdmObject
from rips.view import View from rips.view import View
from rips.project import Project 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.contour_map import ContourMap, ContourMapType
from rips.well_log_plot import WellLogPlot from rips.well_log_plot import WellLogPlot
from rips.well_bore_stability_plot import WellBoreStabilityPlot, WbsParameters 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. view_id(int): View Id corresponding to the View Id in ResInsight project.
""" """
def __init__(self, pdm_object, project, map_type): def __init__(self, pdm_object, map_type):
View.__init__(self, pdm_object, project) View.__init__(self, pdm_object)
self.view_id = pdm_object.get_value("ViewId")
self.map_type = map_type self.map_type = map_type
@@ -48,4 +47,4 @@ class ContourMap(View):
exportLocalCoordinates=export_local_coordinates, exportLocalCoordinates=export_local_coordinates,
undefinedValueLabel=undefined_value_label, undefinedValueLabel=undefined_value_label,
excludeUndefinedValues=exclude_undefined_values, excludeUndefinedValues=exclude_undefined_values,
viewId=self.view_id)) viewId=self.id))

View File

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

View File

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

View File

@@ -3,210 +3,322 @@
ResInsight caf::PdmObject connection module ResInsight caf::PdmObject connection module
""" """
from functools import partial, wraps
import grpc 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 as PdmObject_pb2
import rips.generated.PdmObject_pb2_grpc as PdmObject_pb2_grpc import rips.generated.PdmObject_pb2_grpc as PdmObject_pb2_grpc
import rips.generated.Commands_pb2 as Cmd import rips.generated.Commands_pb2 as Cmd
import rips.generated.Commands_pb2_grpc as CmdRpc import rips.generated.Commands_pb2_grpc as CmdRpc
from rips.generated.pdm_objects import PdmObject
class PdmObject: def camel_to_snake(name):
""" s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
Generic ResInsight object. Corresponds to items in the Project Tree return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
"""
def _execute_command(self, **command_params): def add_method(cls):
self.__warnings = [] def decorator(func):
response, call = self._commands.Execute.with_call(Cmd.CommandParams(**command_params)) setattr(cls, func.__name__, func)
for key, value in call.trailing_metadata(): return func # returning func means func can still be used normally
value = value.replace(';;', '\n') return decorator
if key == 'warning':
self.__warnings.append(value)
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._pb2_object = pb2_object
self._channel = channel else:
self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self._channel) self._pb2_object = PdmObject_pb2.PdmObject(class_keyword=self.__class__.__name__)
self._commands = CmdRpc.CommandsStub(channel)
self._project = project
self.__warnings = []
@classmethod self._channel = channel
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
def keywords(self): if self.pb2_object() is not None and self.channel() is not None:
"""Get a list of all parameter keywords available in the object""" if self.channel() is not None:
list_of_keywords = [] self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self.channel())
for keyword in self._pb2_object.parameters: self._commands = CmdRpc.CommandsStub(self.channel())
list_of_keywords.append(keyword)
return list_of_keywords 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): @add_method(PdmObject)
"""Print the structure and data content of the PdmObject""" def copy_from(self, object):
print("Class Keyword: " + self.class_keyword()) """Copy attribute values from object to self
for keyword in self.keywords(): """
print(keyword + " [" + type(self.get_value(keyword)).__name__ + for attribute in dir(object):
"]: " + str(self.get_value(keyword))) if not attribute.startswith('__'):
value = getattr(object, attribute)
if not callable(value):
setattr(self, attribute, value)
def __to_value(self, value): @add_method(PdmObject)
if value.lower() == 'false': def cast(self, class_definition):
return False if class_definition.__name__ == self.class_keyword() or class_definition.__name__ in self._superclasses:
if value.lower() == 'true': new_object = class_definition(self.pb2_object(), self.channel())
return True 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: try:
int_val = int(value) float_val = float(value)
return int_val return float_val
except ValueError: except ValueError:
try: # We may have a string. Strip internal start and end quotes
float_val = float(value) value = value.strip('\"')
return float_val if self.__islist(value):
except ValueError: return self.__makelist(value)
# We may have a string. Strip internal start and end quotes return value
value = value.strip('\"')
if self.__islist(value):
return self.__makelist(value)
return value
def __from_value(self, value): @add_method(PdmObject)
if isinstance(value, bool): def __convert_to_grpc_value(self, value):
if value: if isinstance(value, bool):
return "true" if value:
return "false" return "true"
if isinstance(value, list): return "false"
list_of_strings = [] if isinstance(value, list):
for val in value: list_of_strings = []
list_of_strings.append(self.__from_value('\"' + val + '\"')) for val in value:
return "[" + ", ".join(list_of_strings) + "]" list_of_strings.append(self.__convert_to_grpc_value('\"' + val + '\"'))
return str(value) return "[" + ", ".join(list_of_strings) + "]"
return str(value)
def get_value(self, keyword): @add_method(PdmObject)
"""Get the value associated with the provided keyword def __get_grpc_value(self, camel_keyword):
Arguments: return self.__convert_from_grpc_value(self._pb2_object.parameters[camel_keyword])
keyword(str): A string containing the parameter keyword
Returns: @add_method(PdmObject)
The value of the parameter. Can be int, str or list. def __set_grpc_value(self, camel_keyword, value):
""" self._pb2_object.parameters[camel_keyword] = self.__convert_to_grpc_value(value)
value = self._pb2_object.parameters[keyword]
return self.__to_value(value)
def __islist(self, value): @add_method(PdmObject)
return value.startswith("[") and value.endswith("]") 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): @add_method(PdmObject)
list_string = list_string.lstrip("[") def __islist(self, value):
list_string = list_string.rstrip("]") return value.startswith("[") and value.endswith("]")
strings = list_string.split(", ")
values = []
for string in strings:
values.append(self.__to_value(string))
return values
def set_value(self, keyword, value): @add_method(PdmObject)
"""Set the value associated with the provided keyword def __makelist(self, list_string):
Arguments: list_string = list_string.lstrip("[")
keyword(str): A string containing the parameter keyword list_string = list_string.rstrip("]")
value(varying): A value matching the type of the parameter. strings = list_string.split(", ")
See keyword documentation and/or print_object_info() to find values = []
the correct data type. for string in strings:
""" values.append(self.__convert_from_grpc_value(string))
self._pb2_object.parameters[keyword] = self.__from_value(value) return values
def descendants(self, class_keyword): @add_method(PdmObject)
"""Get a list of all project tree descendants matching the class keyword def descendants(self, class_keyword_or_class):
Arguments: """Get a list of all project tree descendants matching the class keyword
class_keyword[str]: A class keyword matching the type of class wanted Arguments:
class_keyword_or_class[str/Class]: A class keyword matching the type of class wanted or a Class definition
Returns: Returns:
A list of PdmObjects matching the keyword provided A list of PdmObjects matching the keyword provided
""" """
request = PdmObject_pb2.PdmDescendantObjectRequest( class_definition = PdmObject
object=self._pb2_object, child_keyword=class_keyword) class_keyword = ""
object_list = self._pdm_object_stub.GetDescendantPdmObjects( if isinstance(class_keyword_or_class, str):
request).objects 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 = [] child_list = []
for pdm_object in object_list: for pb2_object in object_list:
child_list.append(PdmObject(pdm_object, self._channel, self._project)) 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 return child_list
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND:
return []
raise e
def children(self, child_field): @add_method(PdmObject)
"""Get a list of all direct project tree children inside the provided child_field def ancestor(self, class_keyword_or_class):
Arguments: """Find the first ancestor that matches the provided class_keyword
child_field[str]: A field name Arguments:
Returns: class_keyword_or_class[str/Class]: A class keyword matching the type of class wanted or a Class definition
A list of PdmObjects inside the child_field """
""" class_definition = PdmObject
request = PdmObject_pb2.PdmChildObjectRequest(object=self._pb2_object, class_keyword = ""
child_field=child_field) if isinstance(class_keyword_or_class, str):
try: class_keyword = class_keyword_or_class
object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects else:
child_list = [] assert(inspect.isclass(class_keyword_or_class))
for pdm_object in object_list: class_keyword = class_keyword_or_class.__name__
child_list.append(PdmObject(pdm_object, self._channel, self._project)) class_definition = class_keyword_or_class
return child_list
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND:
return []
raise e
def ancestor(self, class_keyword): request = PdmObject_pb2.PdmParentObjectRequest(
"""Find the first ancestor that matches the provided class_keyword object=self._pb2_object, parent_keyword=class_keyword)
Arguments: try:
class_keyword[str]: A class keyword matching the type of class wanted pb2_object = self._pdm_object_stub.GetAncestorPdmObject(request)
""" pdm_object = PdmObject(pb2_object=pb2_object,
request = PdmObject_pb2.PdmParentObjectRequest( channel=self._channel)
object=self._pb2_object, parent_keyword=class_keyword) if class_definition.__name__ == PdmObject.__name__:
try: return pdm_object
return PdmObject(self._pdm_object_stub.GetAncestorPdmObject(request), else:
self._channel, self._project) return pdm_object.cast(class_definition)
except grpc.RpcError as e: except grpc.RpcError as e:
if e.code() == grpc.StatusCode.NOT_FOUND: if e.code() == grpc.StatusCode.NOT_FOUND:
return None return None
raise e 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) 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 import rips.generated.Commands_pb2 as Cmd
from rips.pdmobject import PdmObject from rips.pdmobject import PdmObject
from rips.generated.pdm_objects import PlotWindow, Plot
from rips.pdmobject import add_method
class Plot(PdmObject): @add_method(PlotWindow)
"""ResInsight plot class def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG'):
""" Export snapshot for the current plot
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
Arguments: Arguments:
export_folder(str): The path to export to. By default will use the global export folder export_folder(str): The path to export to. By default will use the global export folder
prefix (str): Exported file name prefix prefix (str): Exported file name prefix
output_format(str): Enum string. Can be 'PNG' or 'PDF'. output_format(str): Enum string. Can be 'PNG' or 'PDF'.
""" """
return self._execute_command( return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS', exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS',
prefix=file_prefix, prefix=file_prefix,
viewId=self.view_id, viewId=self.id,
exportFolder=export_folder, exportFolder=export_folder,
plotOutputFormat=output_format)) plotOutputFormat=output_format))

View File

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

View File

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

View File

@@ -14,7 +14,7 @@ def test_loadProject(rips_instance, initialize_test):
case = project.cases()[0] case = project.cases()[0]
assert(case is not None) assert(case is not None)
assert(case.name == "TEST10K_FLT_LGR_NNC") assert(case.name == "TEST10K_FLT_LGR_NNC")
assert(case.case_id == 0) assert(case.id == 0)
cases = rips_instance.project.cases() cases = rips_instance.project.cases()
assert(len(cases) is 1) assert(len(cases) is 1)
@@ -23,15 +23,17 @@ def test_well_log_plots(rips_instance, initialize_test):
plots = project.plots() plots = project.plots()
well_log_plots = [] well_log_plots = []
for plot in 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: 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) well_log_plots.append(well_log_plot)
assert(len(well_log_plots) == 2) assert(len(well_log_plots) == 2)
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname: with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
for well_log_plot in well_log_plots: 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(): if rips_instance.is_gui():
well_log_plot.export_snapshot(tmpdirname) well_log_plot.export_snapshot(tmpdirname)
well_log_plot.export_data_as_las(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() plots2 = project.plots()
for plot2 in plots2: 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: 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") @pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
def test_loadGridCaseGroup(rips_instance, initialize_test): 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) case = rips_instance.project.load_case(path=case_path)
assert(len(case.grids()) == 2) assert(len(case.grids()) == 2)
well_path_files = [case_root_path + "/wellpath_a.dev", case_root_path + "/wellpath_b.dev"] 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) well_path_names = rips_instance.project.import_well_paths(well_path_files)
wells = rips_instance.project.wells() wells = rips_instance.project.well_paths()
assert(len(wells) == 2) assert(len(wells) == 2)
assert(wells[0].name == "Well Path A") assert(wells[0].name == "Well Path A")
assert(wells[1].name == "Well Path B") assert(wells[1].name == "Well Path B")

View File

@@ -1,217 +1,201 @@
""" """
ResInsight 3d view module ResInsight 3d view module
""" """
import builtins
import rips.generated.Commands_pb2 as Cmd import rips.generated.Commands_pb2 as Cmd
import rips.case # Circular import of Case, which already imports View. Use full name. 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): @add_method(View)
"""ResInsight view class def is_geomech_view(self):
return isinstance(self, GeoMechView)
Attributes: @add_method(View)
view_id(int): View Id corresponding to the View Id in ResInsight project. 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): if injectors is None:
PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), project) injectors = []
self.view_id = pdm_object.get_value("ViewId") 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): @add_method(View)
return self.class_keyword() == "ReservoirView" 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): @add_method(View)
return self.class_keyword() == "GeoMechView" 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): @add_method(View)
"""Check if the grid box is meant to be shown in the view""" def export_sim_well_fracture_completions(self, time_step,
return self.get_value("ShowGridBox") simulation_well_names, file_split,
compdat_export):
"""Export fracture completions for simulation wells
def set_show_grid_box(self, value): Parameter | Description | Type
"""Set if the grid box is meant to be shown in the view""" ----------------------------| ------------------------------------------------ | -----
self.set_value("ShowGridBox", value) 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): ##### Enum file_split
"""Get the current background color in the view"""
return self.get_value("ViewBackgroundColor")
def set_background_color(self, bgcolor): Option | Description
"""Set the background color in the view""" ----------------------------------- | ------------
self.set_value("ViewBackgroundColor", bgcolor) "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): ##### Enum compdat_export
"""Retrieve the current cell results"""
return self.children("GridCellResult")[0]
def apply_cell_result(self, result_type, result_variable): Option | Description
"""Apply a regular cell result -----------------------------------------| ------------
"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 if isinstance(simulation_well_names, str):
- DYNAMIC_NATIVE simulation_well_names = [simulation_well_names]
- 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()
def apply_flow_diagnostics_cell_result( case_id = self.case().id
self, return self._execute_command(
result_variable='TOF', exportSimWellFractureCompletions=Cmd.ExportSimWellPathFracRequest(
selection_mode='FLOW_TR_BY_SELECTION', caseId=case_id,
injectors=None, viewId=self.id,
producers=None): timeStep=time_step,
"""Apply a flow diagnostics cell result simulationWellNames=simulation_well_names,
fileSplit=file_split,
compdatExport=compdat_export))
Parameter | Description | Type @add_method(View)
------------------- | ------------------------------------------------------ | ----- def export_visible_cells(self,
result_variable | String representing the result value | String export_keyword='FLUXNUM',
selection_mode | String specifying which tracers to select | String visible_active_cells_value=1,
injectors | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List hidden_active_cells_value=0,
producers | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List 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 @add_method(View)
------------------------| ------------ def export_property(self, undefined_value=0.0):
"TOF" | Time of flight """ Export the current Eclipse property from the view
"Fraction" | Fraction
"MaxFractionTracer" | Max Fraction Tracer
"Communication" | Communication
""" Arguments:
if injectors is None: undefined_value (double): Value to use for undefined values. Defaults to 0.0
injectors = [] """
if producers is None: case_id = self.case().id
producers = [] return self._execute_command(
cell_result = self.set_cell_result() exportPropertyInViews=Cmd.ExportPropertyInViewsRequest(
cell_result.set_value("ResultType", "FLOW_DIAGNOSTICS") caseId=case_id,
cell_result.set_value("ResultVariable", result_variable) viewIds=[self.id],
cell_result.set_value("FlowTracerSelectionMode", selection_mode) undefinedValue=undefined_value))
if selection_mode == 'FLOW_TR_BY_SELECTION':
cell_result.set_value("SelectedInjectorTracers", injectors)
cell_result.set_value("SelectedProducerTracers", producers)
cell_result.update()
def case(self): @add_method(ViewWindow)
"""Get the case the view belongs to""" def case(self):
pdm_case = self.ancestor("EclipseCase") """Get the case the view belongs to"""
if pdm_case is None: mycase = self.ancestor(rips.case.Case)
pdm_case = self.ancestor("ResInsightGeoMechCase") assert(mycase is not None)
if pdm_case is None: return mycase
return None
return rips.case.Case(self._channel, pdm_case.get_value("CaseId"), self._project)
def clone(self): @add_method(ViewWindow)
"""Clone the current view""" def export_snapshot(self, prefix='', export_folder=''):
view_id = self._execute_command(cloneView=Cmd.CloneViewRequest( """ Export snapshot for the current view
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
Arguments: Arguments:
prefix (str): Exported file name prefix prefix (str): Exported file name prefix
export_folder(str): The path to export to. By default will use the global export folder export_folder(str): The path to export to. By default will use the global export folder
""" """
case_id = self.case().case_id case_id = self.case().id
return self._execute_command( return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='VIEWS', exportSnapshots=Cmd.ExportSnapshotsRequest(type='VIEWS',
prefix=prefix, prefix=prefix,
caseId=case_id, caseId=case_id,
viewId=self.view_id, viewId=self.id,
exportFolder=export_folder)) 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 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.well_log_plot import WellLogPlot
from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters
class WbsParameters: @add_method(WbsParameters)
"""Well Bore Stability parameters def __custom_init__(self, pb2_object=None, channel=None):
self.pore_pressure_reservoir_source = "UNDEFINED"
Note that any parameter sources left at "UNDEFINED" will get ResInsight defaults self.pore_pressure_non_reservoir_source = "UNDEFINED"
which depends on the available data.
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: self.user_pp_non_reservoir = 1.05
pore_pressure_in_reservoir_source(enum string): can be "GRID", "LAS_FILE" and "ELEMENT_PROPERTY_TABLE". self.user_poission_ratio = 0.35
pore_pressure_outside_reservoir_source(enum string): can be "HYDROSTATIC" and "USER_DEFINED". self.user_ucs = 100
poisson_ratio_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED". self.user_df = 0.7
ucs_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED". self.user_k0sh = 0.65
obg0_source(enum string): can be "GRID" or "LAS_FILE". self.fg_multiplier = 1.05
df_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED". self.user_k0fg = 0.75
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".
user_pp_outside_reservoir(double): Used if pore_pressure_outside_reservoir_source is "USED_DEFINED". Default 1.05. @add_method(WellBoreStabilityPlot)
user_poission_ratio(double): Used if poisson_ratio_source is "USER_DEFINED", default 0.35. def parameters(self):
user_ucs(double): Used if ucs_soruce is "USER_DEFINED", default 100. """Retrieve the parameters of the Plot
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. children = self.children("WbsParameters", WbsParameters)
fg_shale_sh_multiplier(double): Used if fg_shale_source is "PROPORTIONAL_TO_SH", default 1.05. if len(children) == 1:
user_k0fg(double): Used if fg_shale_source is "DERIVED_FROM_K0FG" and k0fg_source is "USER_DEFINED", default 0.75. child = children[0]
return child
""" return None
def __init__(self): @add_method(WellBoreStabilityPlot)
self.pore_pressure_in_reservoir_source = "UNDEFINED" def set_parameters(self, wbs_parameters):
self.pore_pressure_outside_reservoir_source = "UNDEFINED" children = self.children("WbsParameters", WbsParameters)
if len(children) == 1:
self.poisson_ratio_source = "UNDEFINED" pdm_params = children[0]
self.ucs_source = "UNDEFINED" pdm_params.copy_from(wbs_parameters)
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()

View File

@@ -6,115 +6,50 @@ import rips.generated.Commands_pb2 as Cmd
from rips.plot import Plot from rips.plot import Plot
from rips.pdmobject import PdmObject from rips.pdmobject import PdmObject
from rips.generated.pdm_objects import WellLogPlot
from rips.pdmobject import add_method
class WellLogPlot(Plot): @add_method(WellLogPlot)
"""ResInsight well log plot class 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
""" """
res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='ASCII',
def __init__(self, pdm_object): viewId=self.id,
Plot.__init__(self, pdm_object) exportFolder=export_folder,
filePrefix=file_prefix,
@classmethod exportTvdRkb=False,
def from_pdm_object(cls, pdm_object): capitalizeFileNames=capitalize_file_names,
if isinstance(pdm_object, PdmObject): resampleInterval=0.0))
if pdm_object.class_keyword() == "WellLogPlot": return res.exportWellLogPlotDataResult.exportedFiles
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()

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 } // 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(); RiaPreferences* preferences = app->preferences();
CVF_ASSERT( 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()->setUiReadOnly( true );
m_id.uiCapability()->setUiHidden( true ); m_id.uiCapability()->setUiHidden( true );
m_id.capability<RicfFieldHandle>()->setIOWriteable( false ); m_id.capability<RicfFieldHandle>()->setIOWriteable( false );
@@ -104,20 +107,21 @@ Rim3dView::Rim3dView( void )
CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "" ); CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "" );
m_cameraPointOfInterest.uiCapability()->setUiHidden( true ); m_cameraPointOfInterest.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" ); RICF_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" );
double defaultScaleFactor = preferences->defaultScaleFactorZ(); 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(); 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", "", "", "" ); CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", "" );
maximumFrameRate.uiCapability()->setUiHidden( true ); maximumFrameRate.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", "" ); CAF_PDM_InitField( &hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", "" );
hasUserRequestedAnimation.uiCapability()->setUiHidden( true ); 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 ); m_currentTimeStep.uiCapability()->setUiHidden( true );
caf::AppEnum<RiaDefines::MeshModeType> defaultMeshType = preferences->defaultMeshModeType(); caf::AppEnum<RiaDefines::MeshModeType> defaultMeshType = preferences->defaultMeshModeType();
@@ -126,15 +130,15 @@ Rim3dView::Rim3dView( void )
RICF_InitField( &m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "" ); RICF_InitField( &m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "" );
CAF_PDM_InitField( &m_disableLighting, RICF_InitField( &m_disableLighting,
"DisableLighting", "DisableLighting",
false, false,
"Disable Results Lighting", "Disable Results Lighting",
"", "",
"Disable light model for scalar result colors", "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", "", "", "" ); 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 ) else if ( changedField == &m_showZScaleLabel )
{ {
m_viewer->showZScaleLabel( m_showZScaleLabel() ); if ( m_viewer )
m_viewer->update(); {
m_viewer->showZScaleLabel( m_showZScaleLabel() );
m_viewer->update();
}
} }
else if ( changedField == &m_comparisonView ) else if ( changedField == &m_comparisonView )
{ {

View File

@@ -110,7 +110,7 @@
#include <climits> #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(); RiaPreferences* preferences = app->preferences();
CVF_ASSERT( 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", "", "" ); CAF_PDM_InitFieldNoDefault( &m_cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", "" );
m_cellResult = new RimEclipseCellColors(); m_cellResult = new RimEclipseCellColors();

View File

@@ -5,7 +5,7 @@
#include "RimTools.h" #include "RimTools.h"
#include "cafUtils.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> #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(); RiaPreferences* preferences = app->preferences();
CVF_ASSERT( 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", "", "" ); CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "" );
cellResult = new RimGeoMechCellColors(); cellResult = new RimGeoMechCellColors();

View File

@@ -48,7 +48,7 @@
#include <QDir> #include <QDir>
#include <QMessageBox> #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 "RimWellPathFractureCollection.h"
#include "cafPdmUiTreeOrdering.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 } // 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> #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", "", "", "" ); 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()->setUiReadOnly( true );
m_id.uiCapability()->setUiHidden( true ); m_id.uiCapability()->setUiHidden( true );
m_id.capability<RicfFieldHandle>()->setIOWriteable( false ); m_id.capability<RicfFieldHandle>()->setIOWriteable( false );

View File

@@ -101,7 +101,7 @@
#include <QMenu> #include <QMenu>
#include <algorithm> #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 ); Rim2dIntersectionView* corresponding2dIntersectionView( RimSimWellInView* simWellInView );
CAF_PDM_SOURCE_INIT( RimSimWellInView, "Well" ); CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimSimWellInView, "SimulationWell", "Well" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSimWellInView::RimSimWellInView() 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 ", "", "", "" ); CAF_PDM_InitField( &showWell, "ShowWell", true, "Show well ", "", "", "" );

View File

@@ -26,7 +26,7 @@
#include "RimWellLogFile.h" #include "RimWellLogFile.h"
#include "RimWellPath.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 "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiGroup.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 } // End namespace caf
CAF_PDM_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" ); CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellLogPlot::RimWellLogPlot() 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, CAF_PDM_InitFieldNoDefault( &m_commonDataSource,
"CommonDataSource", "CommonDataSource",

View File

@@ -61,7 +61,7 @@
#include <regex> #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", "", "" ); 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()->setUiReadOnly( true );
m_name.uiCapability()->setUiHidden( true ); m_name.uiCapability()->setUiHidden( true );
m_name.xmlCapability()->disableIO(); m_name.xmlCapability()->disableIO();