From 1f6e9513de60517f005f42032eba45b6295acf01 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 21 Feb 2020 12:10:02 +0100 Subject: [PATCH] Make Python code use the new generated skeleton and rename ResInsight parameters to fit --- .../GrpcInterface/CMakeLists.cmake | 5 + .../Python/rips/PythonExamples/all_cases.py | 4 +- .../PythonExamples/all_simulation_wells.py | 2 +- .../Python/rips/PythonExamples/all_wells.py | 2 +- .../rips/PythonExamples/case_grid_group.py | 10 +- .../rips/PythonExamples/create_wbs_plot.py | 15 +- .../rips/PythonExamples/export_plots.py | 4 +- .../rips/PythonExamples/export_snapshots.py | 4 +- .../import_well_paths_and_logs.py | 12 +- .../rips/PythonExamples/view_example.py | 8 +- .../GrpcInterface/Python/rips/__init__.py | 4 +- .../GrpcInterface/Python/rips/case.py | 2050 +++++++++-------- .../GrpcInterface/Python/rips/contour_map.py | 7 +- .../GrpcInterface/Python/rips/grid.py | 6 +- .../Python/rips/gridcasegroup.py | 107 +- .../GrpcInterface/Python/rips/instance.py | 2 +- .../GrpcInterface/Python/rips/pdmobject.py | 464 ++-- .../GrpcInterface/Python/rips/plot.py | 40 +- .../GrpcInterface/Python/rips/project.py | 567 ++--- .../Python/rips/simulation_well.py | 43 +- .../Python/rips/tests/test_cases.py | 12 +- .../Python/rips/tests/test_project.py | 14 +- .../Python/rips/tests/test_wells.py | 4 +- .../GrpcInterface/Python/rips/view.py | 362 ++- .../GrpcInterface/Python/rips/well.py | 17 - .../Python/rips/well_bore_stability_plot.py | 152 +- .../Python/rips/well_log_plot.py | 155 +- .../GrpcInterface/Python/rips/wellpath.py | 6 + .../ProjectDataModel/Rim3dView.cpp | 39 +- .../ProjectDataModel/RimEclipseView.cpp | 4 +- .../ProjectDataModel/RimFileWellPath.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 4 +- .../RimIdenticalGridCaseGroup.cpp | 2 +- .../ProjectDataModel/RimModeledWellPath.cpp | 2 +- ApplicationCode/ProjectDataModel/RimPlot.cpp | 2 +- .../ProjectDataModel/RimPlotWindow.cpp | 5 +- .../ProjectDataModel/RimProject.cpp | 2 +- .../ProjectDataModel/RimSimWellInView.cpp | 7 +- .../ProjectDataModel/RimWbsParameters.cpp | 2 +- .../RimWellBoreStabilityPlot.cpp | 2 +- .../ProjectDataModel/RimWellLogPlot.cpp | 7 +- .../ProjectDataModel/RimWellPath.cpp | 5 +- 42 files changed, 2078 insertions(+), 2085 deletions(-) delete mode 100644 ApplicationCode/GrpcInterface/Python/rips/well.py create mode 100644 ApplicationCode/GrpcInterface/Python/rips/wellpath.py diff --git a/ApplicationCode/GrpcInterface/CMakeLists.cmake b/ApplicationCode/GrpcInterface/CMakeLists.cmake index ecee06a030..c67309029a 100644 --- a/ApplicationCode/GrpcInterface/CMakeLists.cmake +++ b/ApplicationCode/GrpcInterface/CMakeLists.cmake @@ -178,7 +178,9 @@ if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE) "rips/instance.py" "rips/pdmobject.py" "rips/plot.py" + "rips/simulation_well.py" "rips/view.py" + "rips/wellpath.py" "rips/well_log_plot.py" "rips/well_bore_stability_plot.py" "rips/PythonExamples/instance_example.py" @@ -209,6 +211,9 @@ if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE) "rips/tests/test_project.py" "rips/tests/conftest.py" "rips/tests/dataroot.py" + "rips/tests/test_nnc_properties.py" + "rips/tests/test_simulation_wells.py" + "rips/tests/test_wells.py" "requirements.txt" "setup.py" "README.md" diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_cases.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_cases.py index b76b2021a3..307a6fcd0f 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_cases.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_cases.py @@ -14,10 +14,10 @@ if resinsight is not None: print ("Got " + str(len(cases)) + " cases: ") for case in cases: - print("Case id: " + str(case.case_id)) + print("Case id: " + str(case.id)) print("Case name: " + case.name) print("Case type: " + case.type) - print("Case grid path: " + case.grid_path()) + print("Case file name: " + case.file_path) print("Case reservoir bounding box:", case.reservoir_boundingbox()) timesteps = case.time_steps() diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_simulation_wells.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_simulation_wells.py index 9dc1778553..509a38b160 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_simulation_wells.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_simulation_wells.py @@ -13,7 +13,7 @@ if resinsight is not None: cases = resinsight.project.cases() for case in cases: - print("Case id: " + str(case.case_id)) + print("Case id: " + str(case.id)) print("Case name: " + case.name) timesteps = case.time_steps() diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py index ae8ecc7e57..e0062161d6 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py @@ -10,7 +10,7 @@ import rips resinsight = rips.Instance.find() if resinsight is not None: # Get a list of all wells - wells = resinsight.project.wells() + wells = resinsight.project.well_paths() print ("Got " + str(len(wells)) + " wells: ") for well in wells: diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py index 1e136c8916..acc0a3faaf 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py @@ -16,14 +16,12 @@ case_group.print_object_info() #stat_cases = caseGroup.statistics_cases() #case_ids = [] #for stat_case in stat_cases: -# stat_case.set_value("DynamicPropertiesToCalculate", ["SWAT"]) -# stat_case.update() -# case_ids.append(stat_case.get_value("CaseId")) +# stat_case.set_dynamic_properties_to_calculate(["SWAT"]) +# case_ids.append(stat_case.id) case_group.compute_statistics() view = case_group.views()[0] -cell_result = view.set_cell_result() -cell_result.set_value("ResultVariable", "PRESSURE_DEV") -cell_result.update() +cell_result = view.cell_result() +cell_result.set_result_variable("PRESSURE_DEV") \ No newline at end of file diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/create_wbs_plot.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/create_wbs_plot.py index 8d79eafb11..a430292de4 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/create_wbs_plot.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/create_wbs_plot.py @@ -33,8 +33,8 @@ for case in cases: if case.type == "GeoMechCase": min_res_depth, max_res_depth = case.reservoir_depth_range() - print (case.case_id) - case_path = case.grid_path() + print (case.id) + case_path = case.file_path folder_name = os.path.dirname(case_path) case.import_formation_names(formation_files=['D:/Projects/ResInsight-regression-test/ModelData/norne/Norne_ATW2013.lyr']) @@ -45,16 +45,19 @@ for case in cases: for well_path in well_paths: try: # Create plot with parameters - wbsplot = case.create_well_bore_stability_plot(well_path=well_path, time_step=0, wbs_parameters=wbs_parameters) + wbsplot = case.create_well_bore_stability_plot(well_path=well_path.name, time_step=0, wbs_parameters=wbs_parameters) # Example of setting parameters for existing plots replace_params = wbsplot.parameters() replace_params.user_poisson_ratio = 0.654321 replace_params.user_fg_shale = 1.0321 wbsplot.set_parameters(replace_params) # Demonstrate altering general well log plot settings - min_depth, max_depth = wbsplot.depth_range() - wbsplot.set_depth_range(max(min_depth, min_res_depth), min(max_depth, max_res_depth)) - #wbsplot.set_depth_type("TRUE_VERTICAL_DEPTH_RKB") + min_depth = max(wbsplot.minimum_depth, min_res_depth) + max_depth = min(wbsplot.maximum_depth, max_res_depth) + wbsplot.minimum_depth = min_depth + wbsplot.maximum_depth = max_depth + wbsplot.update() + #wbsplot.depth_type = "TRUE_VERTICAL_DEPTH_RKB" wbsplot.export_snapshot(export_folder=dirname) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_plots.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_plots.py index 475e92503c..0bab47bf9c 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_plots.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_plots.py @@ -15,7 +15,7 @@ print("Exporting to: " + export_folder) for plot in plots: plot.export_snapshot(export_folder=export_folder) plot.export_snapshot(export_folder=export_folder, output_format='PDF') - well_log_plot = rips.WellLogPlot.from_pdm_object(plot) + well_log_plot = plot.cast(rips.WellLogPlot) if well_log_plot is not None: well_log_plot.export_data_as_las(export_folder=export_folder) - well_log_plot.export_data_as_ascii(export_folder=export_folder) \ No newline at end of file + well_log_plot.export_data_as_ascii(export_folder=export_folder) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_snapshots.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_snapshots.py index 7f3a6f1854..16b9ec2c5b 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_snapshots.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/export_snapshots.py @@ -18,9 +18,9 @@ property_list = ['SOIL', 'PRESSURE'] # list of parameter for snapshot print ("Looping through cases") for case in cases: print("Case name: ", case.name) - print("Case id: ", case.case_id) + print("Case id: ", case.id) # Get grid path and its folder name - case_path = case.grid_path() + case_path = case.file_path folder_name = os.path.dirname(case_path) # create a folder to hold the snapshots diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/import_well_paths_and_logs.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/import_well_paths_and_logs.py index 7d1da3798e..ba4af54fa4 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/import_well_paths_and_logs.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/import_well_paths_and_logs.py @@ -3,24 +3,24 @@ import rips # Connect to ResInsight instance resInsight = rips.Instance.find() -well_path_names = resInsight.project.import_well_paths(well_path_folder='D:/Projects/ResInsight-regression-test/ModelData/norne/wellpaths') +well_paths = resInsight.project.import_well_paths(well_path_folder='D:/Projects/ResInsight-regression-test/ModelData/norne/wellpaths') if resInsight.project.has_warnings(): for warning in resInsight.project.warnings(): print(warning) -for well_path_name in well_path_names: - print("Imported from folder: " + well_path_name) +for well_path in well_paths: + print("Imported from folder: " + well_path.name) -well_path_names = resInsight.project.import_well_paths(well_path_files=['D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/E-3H.json', +well_paths = resInsight.project.import_well_paths(well_path_files=['D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/E-3H.json', 'D:/Projects/ResInsight-regression-test/ModelData/Norne_WellPaths/C-1H.json']) if resInsight.project.has_warnings(): for warning in resInsight.project.warnings(): print(warning) -for well_path_name in well_path_names: - print("Imported from indivdual files: " + well_path_name) +for well_path in well_paths: + print("Imported from individual files: " + well_path.name) well_path_names = resInsight.project.import_well_log_files(well_log_folder='D:/Projects/ResInsight-regression-test/ModelData/Norne_PLT_LAS') diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/view_example.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/view_example.py index d75a44ffa0..de703b2810 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/view_example.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/view_example.py @@ -16,14 +16,14 @@ if resinsight is not None: views = case.views() for view in views: # Set some parameters for the view - view.set_show_grid_box(not view.show_grid_box()) - view.set_background_color("#3388AA") + view.show_grid_box = not view.show_grid_box + view.background_color = "#3388AA" # Update the view in ResInsight view.update() # Clone the first view new_view = views[0].clone() - view.set_show_grid_box(False) - new_view.set_background_color("#FFAA33") + new_view.background_color = "#FFAA33" new_view.update() + view.show_grid_box = False view.set_visible(False) view.update() diff --git a/ApplicationCode/GrpcInterface/Python/rips/__init__.py b/ApplicationCode/GrpcInterface/Python/rips/__init__.py index e8505f762a..c76860233d 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/__init__.py +++ b/ApplicationCode/GrpcInterface/Python/rips/__init__.py @@ -10,7 +10,9 @@ from rips.instance import Instance from rips.pdmobject import PdmObject from rips.view import View from rips.project import Project -from rips.plot import Plot +from rips.plot import Plot, PlotWindow from rips.contour_map import ContourMap, ContourMapType from rips.well_log_plot import WellLogPlot from rips.well_bore_stability_plot import WellBoreStabilityPlot, WbsParameters +from rips.simulation_well import SimulationWell +from rips.wellpath import WellPathBase \ No newline at end of file diff --git a/ApplicationCode/GrpcInterface/Python/rips/case.py b/ApplicationCode/GrpcInterface/Python/rips/case.py index aa3ecb90c2..0dad0df109 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/case.py +++ b/ApplicationCode/GrpcInterface/Python/rips/case.py @@ -7,6 +7,7 @@ Module containing the Case class """ +import builtins import grpc import rips.generated.Case_pb2 as Case_pb2 @@ -16,1078 +17,1105 @@ import rips.generated.PdmObject_pb2 as PdmObject_pb2 import rips.generated.Properties_pb2 as Properties_pb2 import rips.generated.Properties_pb2_grpc as Properties_pb2_grpc - import rips.generated.NNCProperties_pb2 as NNCProperties_pb2 import rips.generated.NNCProperties_pb2_grpc as NNCProperties_pb2_grpc +from rips.generated.pdm_objects import Case + +import rips.project from rips.grid import Grid -from rips.pdmobject import PdmObject +from rips.pdmobject import add_method, PdmObject from rips.view import View from rips.contour_map import ContourMap, ContourMapType from rips.well_bore_stability_plot import WellBoreStabilityPlot, WbsParameters from rips.simulation_well import SimulationWell -class Case(PdmObject): - """ResInsight case class +"""ResInsight case class - Operate on a ResInsight case specified by a Case Id integer. - Not meant to be constructed separately but created by one of the following - methods in Project: loadCase, case, allCases, selectedCases +Operate on a ResInsight case specified by a Case Id integer. +Not meant to be constructed separately but created by one of the following +methods in Project: loadCase, case, allCases, selectedCases - Attributes: - id (int): Case Id corresponding to case Id in ResInsight project. - name (str): Case name - group_id (int): Case Group id - chunkSize(int): The size of each chunk during value streaming. - A good chunk size is 64KiB = 65536B. - Meaning the ideal number of doubles would be 8192. - However we need overhead space, so the default is 8160. - This leaves 256B for overhead. - """ - def __init__(self, channel, case_id, project): - # Private properties - self.__channel = channel - self.__case_stub = Case_pb2_grpc.CaseStub(channel) - self.__request = Case_pb2.CaseRequest(id=case_id) +Attributes: + id (int): Case Id corresponding to case Id in ResInsight project. + name (str): Case name + group_id (int): Case Group id + chunkSize(int): The size of each chunk during value streaming. + A good chunk size is 64KiB = 65536B. + Meaning the ideal number of doubles would be 8192. + However we need overhead space, so the default is 8160. + This leaves 256B for overhead. +""" +@add_method(Case) +def __custom_init__(self, pb2_object, channel): + self.__case_stub = Case_pb2_grpc.CaseStub(self._channel) + self.__request = Case_pb2.CaseRequest(id=self.id) - info = self.__case_stub.GetCaseInfo(self.__request) - self.__properties_stub = Properties_pb2_grpc.PropertiesStub( - self.__channel) - self.__nnc_properties_stub = NNCProperties_pb2_grpc.NNCPropertiesStub( - self.__channel) - PdmObject.__init__(self, self.__case_stub.GetPdmObject(self.__request), - self.__channel, project) + info = self.__case_stub.GetCaseInfo(self.__request) + self.__properties_stub = Properties_pb2_grpc.PropertiesStub(self._channel) + self.__nnc_properties_stub = NNCProperties_pb2_grpc.NNCPropertiesStub(self._channel) - # Public properties - self.case_id = case_id - self.group_id = info.group_id - self.name = info.name - self.type = info.type - self.chunk_size = 8160 + # Public properties + self.type = info.type + self.chunk_size = 8160 - def __grid_count(self): - """Get number of grids in the case""" - try: - return self.__case_stub.GetGridCount(self.__request).count - except grpc.RpcError as exception: - if exception.code() == grpc.StatusCode.NOT_FOUND: - return 0 - print("ERROR: ", exception) +@add_method(Case) +def __grid_count(self): + """Get number of grids in the case""" + try: + return self.__case_stub.GetGridCount(self.__request).count + except grpc.RpcError as exception: + if exception.code() == grpc.StatusCode.NOT_FOUND: return 0 + return 0 - def __generate_property_input_iterator(self, values_iterator, parameters): - chunk = Properties_pb2.PropertyInputChunk() - chunk.params.CopyFrom(parameters) +@add_method(Case) +def __generate_property_input_iterator(self, values_iterator, parameters): + chunk = Properties_pb2.PropertyInputChunk() + chunk.params.CopyFrom(parameters) + yield chunk + + for values in values_iterator: + valmsg = Properties_pb2.PropertyChunk(values=values) + chunk.values.CopyFrom(valmsg) yield chunk - for values in values_iterator: - valmsg = Properties_pb2.PropertyChunk(values=values) - chunk.values.CopyFrom(valmsg) - yield chunk - - def __generate_property_input_chunks(self, array, parameters): - index = -1 - while index < len(array): - chunk = Properties_pb2.PropertyInputChunk() - if index is -1: - chunk.params.CopyFrom(parameters) - index += 1 - else: - actual_chunk_size = min(len(array) - index + 1, self.chunk_size) - chunk.values.CopyFrom( - Properties_pb2.PropertyChunk(values=array[index:index + - actual_chunk_size])) - index += actual_chunk_size - - yield chunk - # Final empty message to signal completion +@add_method(Case) +def __generate_property_input_chunks(self, array, parameters): + index = -1 + while index < len(array): chunk = Properties_pb2.PropertyInputChunk() + if index is -1: + chunk.params.CopyFrom(parameters) + index += 1 + else: + actual_chunk_size = min(len(array) - index + 1, self.chunk_size) + chunk.values.CopyFrom( + Properties_pb2.PropertyChunk(values=array[index:index + + actual_chunk_size])) + index += actual_chunk_size + yield chunk - - def grid_path(self): - """Get path of the current grid case - - Returns: path string - """ - return self.get_value("CaseFileName") - - def grid(self, index): - """Get Grid of a given index. Returns a rips Grid object - - Arguments: - index (int): The grid index - - Returns: Grid object - """ - return Grid(index, self, self.__channel) - - def grids(self): - """Get a list of all rips Grid objects in the case""" - grid_list = [] - for i in range(0, self.__grid_count()): - grid_list.append(Grid(i, self, self.__channel)) - return grid_list - - def replace(self, new_grid_file): - """Replace the current case grid with a new grid loaded from file - - Arguments: - new_egrid_file (str): path to EGRID file - """ - self._execute_command(replaceCase=Cmd.ReplaceCaseRequest( - newGridFile=new_grid_file, caseId=self.case_id)) - self.__init__(self.__channel, self.case_id, self._project) - - def cell_count(self, porosity_model="MATRIX_MODEL"): - """Get a cell count object containing number of active cells and - total number of cells - - Arguments: - porosity_model (str): String representing an enum. - must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. - Returns: - Cell Count object with the following integer attributes: - active_cell_count: number of active cells - reservoir_cell_count: total number of reservoir cells - """ - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Case_pb2.CellInfoRequest(case_request=self.__request, - porosity_model=porosity_model_enum) - return self.__case_stub.GetCellCount(request) - - def cell_info_for_active_cells_async(self, porosity_model="MATRIX_MODEL"): - """Get Stream of cell info objects for current case - - Arguments: - porosity_model(str): String representing an enum. - must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. - - Returns: - Stream of **CellInfo** objects - - See cell_info_for_active_cells() for detalis on the **CellInfo** class. - """ - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Case_pb2.CellInfoRequest(case_request=self.__request, - porosity_model=porosity_model_enum) - return self.__case_stub.GetCellInfoForActiveCells(request) - - def cell_info_for_active_cells(self, porosity_model="MATRIX_MODEL"): - """Get list of cell info objects for current case - - Arguments: - porosity_model(str): String representing an enum. - must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. - - Returns: - List of **CellInfo** objects - - ### CellInfo class description - - Parameter | Description | Type - ------------------------- | --------------------------------------------- | ----- - grid_index | Index to grid | Integer - parent_grid_index | Index to parent grid | Integer - coarsening_box_index | Index to coarsening box | Integer - local_ijk | Cell index in IJK directions of local grid | Vec3i - parent_ijk | Cell index in IJK directions of parent grid | Vec3i - - ### Vec3i class description - - Parameter | Description | Type - ---------------- | -------------------------------------------- | ----- - i | I grid index | Integer - j | J grid index | Integer - k | K grid index | Integer - - """ - active_cell_info_chunks = self.cell_info_for_active_cells_async( - porosity_model=porosity_model) - received_active_cells = [] - for active_cell_chunk in active_cell_info_chunks: - for active_cell in active_cell_chunk.data: - received_active_cells.append(active_cell) - return received_active_cells - - def time_steps(self): - """Get a list containing all time steps - - The time steps are defined by the class **TimeStepDate** : - - Type | Name - --------- | ---------- - int | year - int | month - int | day - int | hour - int | minute - int | second - - - """ - return self.__case_stub.GetTimeSteps(self.__request).dates - - def reservoir_boundingbox(self): - """Get the reservoir bounding box - Returns: A class with six double members: min_x, max_x, min_y, max_y, min_z, max_z - """ - return self.__case_stub.GetReservoirBoundingBox(self.__request) - - def reservoir_depth_range(self): - """Get the reservoir depth range - Returns: A tuple with two members. The first is the minimum depth, the second is the maximum depth - """ - bbox = self.reservoir_boundingbox() - return -bbox.max_z, -bbox.min_z - - def days_since_start(self): - """Get a list of decimal values representing days since the start of the simulation""" - return self.__case_stub.GetDaysSinceStart(self.__request).day_decimals - - def views(self): - """Get a list of views belonging to a case""" - eclipse_pdm_objects = self.children("ReservoirViews") - geomech_pdm_objects = self.children("GeoMechViews") - - view_list = [] - for pdm_object in eclipse_pdm_objects: - view_list.append(View(pdm_object, self._project)) - for pdm_object in geomech_pdm_objects: - view_list.append(View(pdm_object, self._project)) - - return view_list - - def view(self, view_id): - """Get a particular view belonging to a case by providing view id - Arguments: - view_id(int): view id - - Returns: a view object - - """ - views = self.views() - for view_object in views: - if view_object.view_id == view_id: - return view_object - return None - - def create_view(self): - """Create a new view in the current case""" - return self.view( - self._execute_command(createView=Cmd.CreateViewRequest( - caseId=self.case_id)).createViewResult.viewId) - - def contour_maps(self, map_type=ContourMapType.ECLIPSE): - """ Get a list of all contour maps belonging to a project - - Arguments: - map_type (enum): ContourMapType.ECLIPSE or ContourMapType.GEO_MECH - - """ - - pdm_objects = self.descendants(ContourMapType.get_identifier(map_type)) - contour_maps = [] - for pdm_object in pdm_objects: - contour_maps.append(ContourMap(pdm_object, self._project, map_type)) - return contour_maps - - def export_snapshots_of_all_views(self, prefix="", export_folder=""): - """ Export snapshots for all views in the case - - Arguments: - prefix (str): Exported file name prefix - export_folder(str): The path to export to. By default will use the global export folder - - """ - return self._execute_command( - exportSnapshots=Cmd.ExportSnapshotsRequest( - type="VIEWS", prefix=prefix, caseId=self.case_id, viewId=-1, exportFolder=export_folder)) - - def export_well_path_completions( - self, - time_step, - well_path_names, - file_split, - compdat_export="TRANSMISSIBILITIES", - include_perforations=True, - include_fishbones=True, - fishbones_exclude_main_bore=True, - combination_mode="INDIVIDUALLY", - ): - """ - Export well path completions for the current case to file - - Parameter | Description | Type - ----------------------------| ------------------------------------------------ | ----- - time_step | Time step to export for | Integer - well_path_names | List of well path names | List - file_split | Controls how export data is split into files | String enum - compdat_export | Compdat export type | String enum - include_perforations | Export perforations? | bool - include_fishbones | Export fishbones? | bool - fishbones_exclude_main_bore | Exclude main bore when exporting fishbones? | bool - combination_mode | Settings for multiple completions in same cell | String Enum - - ##### Enum file_split - - Option | Description - ----------------------------------- | ------------ - "UNIFIED_FILE" | A single file with all combined transmissibilities - "SPLIT_ON_WELL" | One file for each well with combined transmissibilities - "SPLIT_ON_WELL_AND_COMPLETION_TYPE" | One file for each completion type for each well - - ##### Enum compdat_export - - Option | Description - ------------------------------------------- | ------------ - "TRANSMISSIBILITIES" | Direct export of transmissibilities - "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS" | Include WPIMULT in addition to transmissibilities - - ##### Enum combination_mode - - Option | Description - ------------------- | ------------ - "INDIVIDUALLY" | Exports the different completion types into separate sections - "COMBINED" | Export one combined transmissibility for each cell - - """ - if isinstance(well_path_names, str): - well_path_names = [well_path_names] - return self._execute_command( - exportWellPathCompletions=Cmd.ExportWellPathCompRequest( - caseId=self.case_id, - timeStep=time_step, - wellPathNames=well_path_names, - fileSplit=file_split, - compdatExport=compdat_export, - includePerforations=include_perforations, - includeFishbones=include_fishbones, - excludeMainBoreForFishbones=fishbones_exclude_main_bore, - combinationMode=combination_mode, - )) - - def export_msw(self, well_path): - """ - Export Eclipse Multi-segment-well model to file - - Arguments: - well_path(str): Well path name - """ - return self._execute_command(exportMsw=Cmd.ExportMswRequest( - caseId=self.case_id, wellPath=well_path)) - - def create_multiple_fractures( - self, - template_id, - well_path_names, - min_dist_from_well_td, - max_fractures_per_well, - top_layer, - base_layer, - spacing, - action, - ): - """ - Create Multiple Fractures in one go - - Parameter | Description | Type - -----------------------| ----------------------------------------- | ----- - template_id | Id of the template | Integer - well_path_names | List of well path names | List of Strings - min_dist_from_well_td | Minimum distance from well TD | Double - max_fractures_per_well | Max number of fractures per well | Integer - top_layer | Top grid k-level for fractures | Integer - base_layer | Base grid k-level for fractures | Integer - spacing | Spacing between fractures | Double - action | 'APPEND_FRACTURES' or 'REPLACE_FRACTURES' | String enum - """ - if isinstance(well_path_names, str): - well_path_names = [well_path_names] - return self._execute_command( - createMultipleFractures=Cmd.MultipleFracRequest( - caseId=self.case_id, - templateId=template_id, - wellPathNames=well_path_names, - minDistFromWellTd=min_dist_from_well_td, - maxFracturesPerWell=max_fractures_per_well, - topLayer=top_layer, - baseLayer=base_layer, - spacing=spacing, - action=action, - )) - - def create_lgr_for_completion( - self, - time_step, - well_path_names, - refinement_i, - refinement_j, - refinement_k, - split_type, - ): - """ - Create a local grid refinement for the completions on the given well paths - - Parameter | Description | Type - --------------- | -------------------------------------- | ----- - time_steps | Time step index | Integer - well_path_names | List of well path names | List of Strings - refinement_i | Refinment in x-direction | Integer - refinement_j | Refinment in y-direction | Integer - refinement_k | Refinment in z-direction | Integer - split_type | Defines how to split LGRS | String enum - - ##### Enum split_type - - Option | Description - ------------------------| ------------ - "LGR_PER_CELL" | One LGR for each completed cell - "LGR_PER_COMPLETION" | One LGR for each completion (fracture, perforation, ...) - "LGR_PER_WELL" | One LGR for each well - - """ - if isinstance(well_path_names, str): - well_path_names = [well_path_names] - return self._execute_command( - createLgrForCompletions=Cmd.CreateLgrForCompRequest( - caseId=self.case_id, - timeStep=time_step, - wellPathNames=well_path_names, - refinementI=refinement_i, - refinementJ=refinement_j, - refinementK=refinement_k, - splitType=split_type, - )) - - def create_saturation_pressure_plots(self): - """ - Create saturation pressure plots for the current case - """ - case_ids = [self.case_id] - return self._execute_command( - createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest( - caseIds=case_ids)) - - def export_flow_characteristics( - self, - time_steps, - injectors, - producers, - file_name, - minimum_communication=0.0, - aquifer_cell_threshold=0.1, - ): - """ Export Flow Characteristics data to text file in CSV format - - Parameter | Description | Type - ------------------------- | --------------------------------------------- | ----- - time_steps | Time step indices | List of Integer - injectors | Injector names | List of Strings - producers | Producer names | List of Strings - file_name | Export file name | Integer - minimum_communication | Minimum Communication, defaults to 0.0 | Integer - aquifer_cell_threshold | Aquifer Cell Threshold, defaults to 0.1 | Integer - - """ - if isinstance(time_steps, int): - time_steps = [time_steps] - if isinstance(injectors, str): - injectors = [injectors] - if isinstance(producers, str): - producers = [producers] - return self._execute_command( - exportFlowCharacteristics=Cmd.ExportFlowInfoRequest( - caseId=self.case_id, - timeSteps=time_steps, - injectors=injectors, - producers=producers, - fileName=file_name, - minimumCommunication=minimum_communication, - aquiferCellThreshold=aquifer_cell_threshold, - )) - - def available_properties(self, - property_type, - porosity_model="MATRIX_MODEL"): - """Get a list of available properties - - Arguments: - property_type (str): string corresponding to property_type enum. Choices: - - DYNAMIC_NATIVE - - STATIC_NATIVE - - SOURSIMRL - - GENERATED - - INPUT_PROPERTY - - FORMATION_NAMES - - FLOW_DIAGNOSTICS - - INJECTION_FLOODING - - porosity_model(str): 'MATRIX_MODEL' or 'FRACTURE_MODEL'. - """ - - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.AvailablePropertiesRequest( - case_request=self.__request, - property_type=property_type_enum, - porosity_model=porosity_model_enum, - ) - return self.__properties_stub.GetAvailableProperties( - request).property_names - - def active_cell_property_async(self, - property_type, - property_name, - time_step, - porosity_model="MATRIX_MODEL"): - """Get a cell property for all active cells. Async, so returns an iterator - - Arguments: - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - porosity_model(str): string enum. See available() - - Returns: - An iterator to a chunk object containing an array of double values - Loop through the chunks and then the values within the chunk to get all values. - """ - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.PropertyRequest( - case_request=self.__request, - property_type=property_type_enum, - property_name=property_name, - time_step=time_step, - porosity_model=porosity_model_enum, - ) - for chunk in self.__properties_stub.GetActiveCellProperty(request): - yield chunk - - def active_cell_property(self, - property_type, - property_name, - time_step, - porosity_model="MATRIX_MODEL"): - """Get a cell property for all active cells. Sync, so returns a list - - Arguments: - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - porosity_model(str): string enum. See available() - - Returns: - A list containing double values - Loop through the chunks and then the values within the chunk to get all values. - """ - all_values = [] - generator = self.active_cell_property_async(property_type, - property_name, time_step, - porosity_model) - for chunk in generator: - for value in chunk.values: - all_values.append(value) - return all_values - - def selected_cell_property_async(self, - property_type, - property_name, - time_step, - porosity_model="MATRIX_MODEL"): - """Get a cell property for all selected cells. Async, so returns an iterator - - Arguments: - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - porosity_model(str): string enum. See available() - - Returns: - An iterator to a chunk object containing an array of double values - Loop through the chunks and then the values within the chunk to get all values. - """ - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.PropertyRequest( - case_request=self.__request, - property_type=property_type_enum, - property_name=property_name, - time_step=time_step, - porosity_model=porosity_model_enum, - ) - for chunk in self.__properties_stub.GetSelectedCellProperty(request): - yield chunk - - def selected_cell_property(self, - property_type, - property_name, - time_step, - porosity_model="MATRIX_MODEL"): - """Get a cell property for all selected cells. Sync, so returns a list - - Arguments: - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - porosity_model(str): string enum. See available() - - Returns: - A list containing double values - Loop through the chunks and then the values within the chunk to get all values. - """ - all_values = [] - generator = self.selected_cell_property_async(property_type, - property_name, time_step, - porosity_model) - for chunk in generator: - for value in chunk.values: - all_values.append(value) - return all_values - - def grid_property_async( - self, - property_type, - property_name, - time_step, - grid_index=0, - porosity_model="MATRIX_MODEL", - ): - """Get a cell property for all grid cells. Async, so returns an iterator - - Arguments: - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - gridIndex(int): index to the grid we're getting values for - porosity_model(str): string enum. See available() - - Returns: - An iterator to a chunk object containing an array of double values - Loop through the chunks and then the values within the chunk to get all values. - """ - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.PropertyRequest( - case_request=self.__request, - property_type=property_type_enum, - property_name=property_name, - time_step=time_step, - grid_index=grid_index, - porosity_model=porosity_model_enum, - ) - for chunk in self.__properties_stub.GetGridProperty(request): - yield chunk - - def grid_property( - self, - property_type, - property_name, - time_step, - grid_index=0, - porosity_model="MATRIX_MODEL", - ): - """Get a cell property for all grid cells. Synchronous, so returns a list - - Arguments: - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - grid_index(int): index to the grid we're getting values for - porosity_model(str): string enum. See available() - - Returns: - A list of double values - """ - all_values = [] - generator = self.grid_property_async(property_type, property_name, - time_step, grid_index, - porosity_model) - for chunk in generator: - for value in chunk.values: - all_values.append(value) - return all_values - - def set_active_cell_property_async( - self, - values_iterator, - property_type, - property_name, - time_step, - porosity_model="MATRIX_MODEL", - ): - """Set cell property for all active cells Async. Takes an iterator to the input values - - Arguments: - values_iterator(iterator): an iterator to the properties to be set - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - porosity_model(str): string enum. See available() - """ - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.PropertyRequest( - case_request=self.__request, - property_type=property_type_enum, - property_name=property_name, - time_step=time_step, - porosity_model=porosity_model_enum, - ) - - request_iterator = self.__generate_property_input_iterator( - values_iterator, request) - self.__properties_stub.SetActiveCellProperty(request_iterator) - - def set_active_cell_property( - self, - values, - property_type, - property_name, - time_step, - porosity_model="MATRIX_MODEL", - ): - """Set a cell property for all active cells. - - Arguments: - values(list): a list of double precision floating point numbers - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - porosity_model(str): string enum. See available() - """ - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.PropertyRequest( - case_request=self.__request, - property_type=property_type_enum, - property_name=property_name, - time_step=time_step, - porosity_model=porosity_model_enum, - ) - request_iterator = self.__generate_property_input_chunks( - values, request) - reply = self.__properties_stub.SetActiveCellProperty(request_iterator) - if reply.accepted_value_count < len(values): - raise IndexError - - def set_grid_property( - self, - values, - property_type, - property_name, - time_step, - grid_index=0, - porosity_model="MATRIX_MODEL", - ): - """Set a cell property for all grid cells. - - Arguments: - values(list): a list of double precision floating point numbers - property_type(str): string enum. See available() - property_name(str): name of an Eclipse property - time_step(int): the time step for which to get the property for - grid_index(int): index to the grid we're setting values for - porosity_model(str): string enum. See available() - """ - property_type_enum = Properties_pb2.PropertyType.Value(property_type) - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Properties_pb2.PropertyRequest( - case_request=self.__request, - property_type=property_type_enum, - property_name=property_name, - time_step=time_step, - grid_index=grid_index, - porosity_model=porosity_model_enum, - ) - request_iterator = self.__generate_property_input_chunks( - values, request) - reply = self.__properties_stub.SetGridProperty(request_iterator) - if reply.accepted_value_count < len(values): - raise IndexError - - def export_property( - self, - time_step, - property_name, - eclipse_keyword=property, - undefined_value=0.0, - export_file=property, - ): - """ Export an Eclipse property - - Arguments: - time_step (int): time step index - property_name (str): property to export - eclipse_keyword (str): Keyword used in export header. Defaults: value of property - undefined_value (double): Value to use for undefined values. Defaults to 0.0 - export_file (str): File name for export. Defaults to the value of property parameter - """ - return self._execute_command(exportProperty=Cmd.ExportPropertyRequest( - caseId=self.case_id, + # Final empty message to signal completion + chunk = Properties_pb2.PropertyInputChunk() + yield chunk + +@add_method(Case) +def grid(self, index): + """Get Grid of a given index. Returns a rips Grid object + + Arguments: + index (int): The grid index + + Returns: Grid object + """ + return Grid(index, self, self.channel()) + +@add_method(Case) +def grids(self): + """Get a list of all rips Grid objects in the case""" + grid_list = [] + for i in range(0, self.__grid_count()): + grid_list.append(Grid(i, self, self.channel())) + return grid_list + +@add_method(Case) +def replace(self, new_grid_file): + """Replace the current case grid with a new grid loaded from file + + Arguments: + new_egrid_file (str): path to EGRID file + """ + project = self.ancestor(rips.project.Project) + self._execute_command(replaceCase=Cmd.ReplaceCaseRequest( + newGridFile=new_grid_file, caseId=self.id)) + new_case = project.case(self.id) + self.copy_from(new_case) + +@add_method(Case) +def cell_count(self, porosity_model="MATRIX_MODEL"): + """Get a cell count object containing number of active cells and + total number of cells + + Arguments: + porosity_model (str): String representing an enum. + must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. + Returns: + Cell Count object with the following integer attributes: + active_cell_count: number of active cells + reservoir_cell_count: total number of reservoir cells + """ + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Case_pb2.CellInfoRequest(case_request=self.__request, + porosity_model=porosity_model_enum) + return self.__case_stub.GetCellCount(request) + +@add_method(Case) +def cell_info_for_active_cells_async(self, porosity_model="MATRIX_MODEL"): + """Get Stream of cell info objects for current case + + Arguments: + porosity_model(str): String representing an enum. + must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. + + Returns: + Stream of **CellInfo** objects + + See cell_info_for_active_cells() for detalis on the **CellInfo** class. + """ + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Case_pb2.CellInfoRequest(case_request=self.__request, + porosity_model=porosity_model_enum) + return self.__case_stub.GetCellInfoForActiveCells(request) + +@add_method(Case) +def cell_info_for_active_cells(self, porosity_model="MATRIX_MODEL"): + """Get list of cell info objects for current case + + Arguments: + porosity_model(str): String representing an enum. + must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. + + Returns: + List of **CellInfo** objects + + ### CellInfo class description + + Parameter | Description | Type + ------------------------- | --------------------------------------------- | ----- + grid_index | Index to grid | Integer + parent_grid_index | Index to parent grid | Integer + coarsening_box_index | Index to coarsening box | Integer + local_ijk | Cell index in IJK directions of local grid | Vec3i + parent_ijk | Cell index in IJK directions of parent grid | Vec3i + + ### Vec3i class description + + Parameter | Description | Type + ---------------- | -------------------------------------------- | ----- + i | I grid index | Integer + j | J grid index | Integer + k | K grid index | Integer + + """ + active_cell_info_chunks = self.cell_info_for_active_cells_async( + porosity_model=porosity_model) + received_active_cells = [] + for active_cell_chunk in active_cell_info_chunks: + for active_cell in active_cell_chunk.data: + received_active_cells.append(active_cell) + return received_active_cells + +@add_method(Case) +def time_steps(self): + """Get a list containing all time steps + + The time steps are defined by the class **TimeStepDate** : + + Type | Name + --------- | ---------- + int | year + int | month + int | day + int | hour + int | minute + int | second + + + """ + return self.__case_stub.GetTimeSteps(self.__request).dates + +@add_method(Case) +def reservoir_boundingbox(self): + """Get the reservoir bounding box + Returns: A class with six double members: min_x, max_x, min_y, max_y, min_z, max_z + """ + return self.__case_stub.GetReservoirBoundingBox(self.__request) + +@add_method(Case) +def reservoir_depth_range(self): + """Get the reservoir depth range + Returns: A tuple with two members. The first is the minimum depth, the second is the maximum depth + """ + bbox = self.reservoir_boundingbox() + return -bbox.max_z, -bbox.min_z + +@add_method(Case) +def days_since_start(self): + """Get a list of decimal values representing days since the start of the simulation""" + return self.__case_stub.GetDaysSinceStart(self.__request).day_decimals + +@add_method(Case) +def views(self): + """Get a list of views belonging to a case""" + pdm_objects = self.descendants("View") + + view_list = [] + for pdm_object in pdm_objects: + view_object = pdm_object.cast(View) + view_list.append(view_object) + + return view_list + +@add_method(Case) +def view(self, view_id): + """Get a particular view belonging to a case by providing view id + Arguments: + view_id(int): view id + + Returns: a view object + + """ + views = self.views() + for view_object in views: + if view_object.id == view_id: + return view_object + return None + +@add_method(Case) +def create_view(self): + """Create a new view in the current case""" + return self.view( + self._execute_command(createView=Cmd.CreateViewRequest( + caseId=self.id)).createViewResult.viewId) + +@add_method(Case) +def contour_maps(self, map_type=ContourMapType.ECLIPSE): + """ Get a list of all contour maps belonging to a project + + Arguments: + map_type (enum): ContourMapType.ECLIPSE or ContourMapType.GEO_MECH + + """ + + pdm_objects = self.descendants(ContourMapType.get_identifier(map_type)) + contour_maps = [] + for pdm_object in pdm_objects: + contour_maps.append(ContourMap(pdm_object, map_type)) + return contour_maps + +@add_method(Case) +def export_snapshots_of_all_views(self, prefix="", export_folder=""): + """ Export snapshots for all views in the case + + Arguments: + prefix (str): Exported file name prefix + export_folder(str): The path to export to. By default will use the global export folder + + """ + return self._execute_command( + exportSnapshots=Cmd.ExportSnapshotsRequest( + type="VIEWS", prefix=prefix, caseId=self.id, viewId=-1, exportFolder=export_folder)) + +@add_method(Case) +def export_well_path_completions( + self, + time_step, + well_path_names, + file_split, + compdat_export="TRANSMISSIBILITIES", + include_perforations=True, + include_fishbones=True, + fishbones_exclude_main_bore=True, + combination_mode="INDIVIDUALLY", +): + """ + Export well path completions for the current case to file + + Parameter | Description | Type + ----------------------------| ------------------------------------------------ | ----- + time_step | Time step to export for | Integer + well_path_names | List of well path names | List + file_split | Controls how export data is split into files | String enum + compdat_export | Compdat export type | String enum + include_perforations | Export perforations? | bool + include_fishbones | Export fishbones? | bool + fishbones_exclude_main_bore | Exclude main bore when exporting fishbones? | bool + combination_mode | Settings for multiple completions in same cell | String Enum + + ##### Enum file_split + + Option | Description + ----------------------------------- | ------------ + "UNIFIED_FILE" | A single file with all combined transmissibilities + "SPLIT_ON_WELL" | One file for each well with combined transmissibilities + "SPLIT_ON_WELL_AND_COMPLETION_TYPE" | One file for each completion type for each well + + ##### Enum compdat_export + + Option | Description + ------------------------------------------- | ------------ + "TRANSMISSIBILITIES" | Direct export of transmissibilities + "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS" | Include WPIMULT in addition to transmissibilities + + ##### Enum combination_mode + + Option | Description + ------------------- | ------------ + "INDIVIDUALLY" | Exports the different completion types into separate sections + "COMBINED" | Export one combined transmissibility for each cell + + """ + if isinstance(well_path_names, str): + well_path_names = [well_path_names] + return self._execute_command( + exportWellPathCompletions=Cmd.ExportWellPathCompRequest( + caseId=self.id, timeStep=time_step, - property=property_name, - eclipseKeyword=eclipse_keyword, - undefinedValue=undefined_value, - exportFile=export_file, + wellPathNames=well_path_names, + fileSplit=file_split, + compdatExport=compdat_export, + includePerforations=include_perforations, + includeFishbones=include_fishbones, + excludeMainBoreForFishbones=fishbones_exclude_main_bore, + combinationMode=combination_mode, )) - def create_well_bore_stability_plot(self, well_path, time_step, wbs_parameters=None): - """ Create a new well bore stability plot +@add_method(Case) +def export_msw(self, well_path): + """ + Export Eclipse Multi-segment-well model to file + + Arguments: + well_path(str): Well path name + """ + return self._execute_command(exportMsw=Cmd.ExportMswRequest( + caseId=self.id, wellPath=well_path)) + +@add_method(Case) +def create_multiple_fractures( + self, + template_id, + well_path_names, + min_dist_from_well_td, + max_fractures_per_well, + top_layer, + base_layer, + spacing, + action, +): + """ + Create Multiple Fractures in one go + + Parameter | Description | Type + -----------------------| ----------------------------------------- | ----- + template_id | Id of the template | Integer + well_path_names | List of well path names | List of Strings + min_dist_from_well_td | Minimum distance from well TD | Double + max_fractures_per_well | Max number of fractures per well | Integer + top_layer | Top grid k-level for fractures | Integer + base_layer | Base grid k-level for fractures | Integer + spacing | Spacing between fractures | Double + action | 'APPEND_FRACTURES' or 'REPLACE_FRACTURES' | String enum + """ + if isinstance(well_path_names, str): + well_path_names = [well_path_names] + return self._execute_command( + createMultipleFractures=Cmd.MultipleFracRequest( + caseId=self.id, + templateId=template_id, + wellPathNames=well_path_names, + minDistFromWellTd=min_dist_from_well_td, + maxFracturesPerWell=max_fractures_per_well, + topLayer=top_layer, + baseLayer=base_layer, + spacing=spacing, + action=action, + )) + +@add_method(Case) +def create_lgr_for_completion( + self, + time_step, + well_path_names, + refinement_i, + refinement_j, + refinement_k, + split_type, +): + """ + Create a local grid refinement for the completions on the given well paths + + Parameter | Description | Type + --------------- | -------------------------------------- | ----- + time_steps | Time step index | Integer + well_path_names | List of well path names | List of Strings + refinement_i | Refinment in x-direction | Integer + refinement_j | Refinment in y-direction | Integer + refinement_k | Refinment in z-direction | Integer + split_type | Defines how to split LGRS | String enum + + ##### Enum split_type + + Option | Description + ------------------------| ------------ + "LGR_PER_CELL" | One LGR for each completed cell + "LGR_PER_COMPLETION" | One LGR for each completion (fracture, perforation, ...) + "LGR_PER_WELL" | One LGR for each well + + """ + if isinstance(well_path_names, str): + well_path_names = [well_path_names] + return self._execute_command( + createLgrForCompletions=Cmd.CreateLgrForCompRequest( + caseId=self.id, + timeStep=time_step, + wellPathNames=well_path_names, + refinementI=refinement_i, + refinementJ=refinement_j, + refinementK=refinement_k, + splitType=split_type, + )) + +@add_method(Case) +def create_saturation_pressure_plots(self): + """ + Create saturation pressure plots for the current case + """ + case_ids = [self.id] + return self._execute_command( + createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest( + caseIds=case_ids)) + +@add_method(Case) +def export_flow_characteristics( + self, + time_steps, + injectors, + producers, + file_name, + minimum_communication=0.0, + aquifer_cell_threshold=0.1, +): + """ Export Flow Characteristics data to text file in CSV format + + Parameter | Description | Type + ------------------------- | --------------------------------------------- | ----- + time_steps | Time step indices | List of Integer + injectors | Injector names | List of Strings + producers | Producer names | List of Strings + file_name | Export file name | Integer + minimum_communication | Minimum Communication, defaults to 0.0 | Integer + aquifer_cell_threshold | Aquifer Cell Threshold, defaults to 0.1 | Integer + + """ + if isinstance(time_steps, int): + time_steps = [time_steps] + if isinstance(injectors, str): + injectors = [injectors] + if isinstance(producers, str): + producers = [producers] + return self._execute_command( + exportFlowCharacteristics=Cmd.ExportFlowInfoRequest( + caseId=self.id, + timeSteps=time_steps, + injectors=injectors, + producers=producers, + fileName=file_name, + minimumCommunication=minimum_communication, + aquiferCellThreshold=aquifer_cell_threshold, + )) + +@add_method(Case) +def available_properties(self, + property_type, + porosity_model="MATRIX_MODEL"): + """Get a list of available properties + + Arguments: + property_type (str): string corresponding to property_type enum. Choices: + - DYNAMIC_NATIVE + - STATIC_NATIVE + - SOURSIMRL + - GENERATED + - INPUT_PROPERTY + - FORMATION_NAMES + - FLOW_DIAGNOSTICS + - INJECTION_FLOODING + + porosity_model(str): 'MATRIX_MODEL' or 'FRACTURE_MODEL'. + """ + + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.AvailablePropertiesRequest( + case_request=self.__request, + property_type=property_type_enum, + porosity_model=porosity_model_enum, + ) + return self.__properties_stub.GetAvailableProperties( + request).property_names + +@add_method(Case) +def active_cell_property_async(self, + property_type, + property_name, + time_step, + porosity_model="MATRIX_MODEL"): + """Get a cell property for all active cells. Async, so returns an iterator Arguments: - well_path(str): well path name - time_step(int): time step + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + porosity_model(str): string enum. See available() Returns: - A new plot object - """ - pdm_parameters = None - if wbs_parameters is not None: - assert(isinstance(wbs_parameters, WbsParameters)) - pdm_parameters = PdmObject.create("WbsParameters", self.__channel, self._project) - wbs_parameters.to_pdm_object(pdm_parameters) + An iterator to a chunk object containing an array of double values + Loop through the chunks and then the values within the chunk to get all values. + """ + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.PropertyRequest( + case_request=self.__request, + property_type=property_type_enum, + property_name=property_name, + time_step=time_step, + porosity_model=porosity_model_enum, + ) + for chunk in self.__properties_stub.GetActiveCellProperty(request): + yield chunk - plot_result = self._execute_command(createWellBoreStabilityPlot=Cmd.CreateWbsPlotRequest(caseId=self.case_id, - wellPath=well_path, - timeStep=time_step, - wbsParameters=pdm_parameters.pb2_object())) - return WellBoreStabilityPlot(self._project.plot(view_id=plot_result.createWbsPlotResult.viewId)) - - def import_formation_names(self, formation_files=None): - """ Import formation names into project and apply it to the current case +@add_method(Case) +def active_cell_property(self, + property_type, + property_name, + time_step, + porosity_model="MATRIX_MODEL"): + """Get a cell property for all active cells. Sync, so returns a list Arguments: - formation_files(list): list of files to import - - """ - 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=self.case_id)) - - def simulation_wells(self): - """Get a list of all simulation wells for a case + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + porosity_model(str): string enum. See available() Returns: - A list of rips SimulationWell objects - """ - pdm_objects = self.descendants("Well") - wells = [] - for pdm_object in pdm_objects: - wells.append(SimulationWell(pdm_object.get_value("WellName"), self.case_id, pdm_object)) - return wells + A list containing double values + Loop through the chunks and then the values within the chunk to get all values. + """ + all_values = [] + generator = self.active_cell_property_async(property_type, + property_name, time_step, + porosity_model) + for chunk in generator: + for value in chunk.values: + all_values.append(value) + return all_values +@add_method(Case) +def selected_cell_property_async(self, + property_type, + property_name, + time_step, + porosity_model="MATRIX_MODEL"): + """Get a cell property for all selected cells. Async, so returns an iterator - def active_cell_centers_async( - self, - porosity_model="MATRIX_MODEL", - ): - """Get a cell centers for all active cells. Async, so returns an iterator + Arguments: + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + porosity_model(str): string enum. See available() - Arguments: - porosity_model(str): string enum. See available() + Returns: + An iterator to a chunk object containing an array of double values + Loop through the chunks and then the values within the chunk to get all values. + """ + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.PropertyRequest( + case_request=self.__request, + property_type=property_type_enum, + property_name=property_name, + time_step=time_step, + porosity_model=porosity_model_enum, + ) + for chunk in self.__properties_stub.GetSelectedCellProperty(request): + yield chunk - Returns: - An iterator to a chunk object containing an array of Vec3d values. - Loop through the chunks and then the values within the chunk to get all values. - """ - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Case_pb2.CellInfoRequest(case_request=self.__request, - porosity_model=porosity_model_enum) - return self.__case_stub.GetCellCenterForActiveCells(request) +@add_method(Case) +def selected_cell_property(self, + property_type, + property_name, + time_step, + porosity_model="MATRIX_MODEL"): + """Get a cell property for all selected cells. Sync, so returns a list - def active_cell_centers( - self, - porosity_model="MATRIX_MODEL", - ): - """Get a cell centers for all active cells. Synchronous, so returns a list. + Arguments: + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + porosity_model(str): string enum. See available() - Arguments: - porosity_model(str): string enum. See available() + Returns: + A list containing double values + Loop through the chunks and then the values within the chunk to get all values. + """ + all_values = [] + generator = self.selected_cell_property_async(property_type, + property_name, time_step, + porosity_model) + for chunk in generator: + for value in chunk.values: + all_values.append(value) + return all_values - Returns: - A list of Vec3d - """ - cell_centers = [] - generator = self.active_cell_centers_async(porosity_model) - for chunk in generator: - for value in chunk.centers: - cell_centers.append(value) - return cell_centers +@add_method(Case) +def grid_property_async( + self, + property_type, + property_name, + time_step, + grid_index=0, + porosity_model="MATRIX_MODEL"): + """Get a cell property for all grid cells. Async, so returns an iterator - def active_cell_corners_async( - self, - porosity_model="MATRIX_MODEL", - ): - """Get a cell corners for all active cells. Async, so returns an iterator + Arguments: + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + gridIndex(int): index to the grid we're getting values for + porosity_model(str): string enum. See available() - Arguments: - porosity_model(str): string enum. See available() + Returns: + An iterator to a chunk object containing an array of double values + Loop through the chunks and then the values within the chunk to get all values. + """ + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.PropertyRequest( + case_request=self.__request, + property_type=property_type_enum, + property_name=property_name, + time_step=time_step, + grid_index=grid_index, + porosity_model=porosity_model_enum, + ) + for chunk in self.__properties_stub.GetGridProperty(request): + yield chunk - Returns: - An iterator to a chunk object containing an array of CellCorners (which is eight Vec3d values). - Loop through the chunks and then the values within the chunk to get all values. - """ - porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) - request = Case_pb2.CellInfoRequest(case_request=self.__request, - porosity_model=porosity_model_enum) - return self.__case_stub.GetCellCornersForActiveCells(request) +@add_method(Case) +def grid_property( + self, + property_type, + property_name, + time_step, + grid_index=0, + porosity_model="MATRIX_MODEL"): + """Get a cell property for all grid cells. Synchronous, so returns a list - def active_cell_corners( - self, - porosity_model="MATRIX_MODEL", - ): - """Get a cell corners for all active cells. Synchronous, so returns a list. + Arguments: + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + grid_index(int): index to the grid we're getting values for + porosity_model(str): string enum. See available() - Arguments: - porosity_model(str): string enum. See available() + Returns: + A list of double values + """ + all_values = [] + generator = self.grid_property_async(property_type, property_name, + time_step, grid_index, + porosity_model) + for chunk in generator: + for value in chunk.values: + all_values.append(value) + return all_values - Returns: - A list of CellCorners - """ - cell_corners = [] - generator = self.active_cell_corners_async(porosity_model) - for chunk in generator: - for value in chunk.cells: - cell_corners.append(value) - return cell_corners +@add_method(Case) +def set_active_cell_property_async( + self, + values_iterator, + property_type, + property_name, + time_step, + porosity_model="MATRIX_MODEL"): + """Set cell property for all active cells Async. Takes an iterator to the input values - def selected_cells_async(self): - """Get the selected cells. Async, so returns an iterator. - Returns: - An iterator to a chunk object containing an array of cells. - Loop through the chunks and then the cells within the chunk to get all cells. - """ - return self.__case_stub.GetSelectedCells(self.__request) + Arguments: + values_iterator(iterator): an iterator to the properties to be set + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + porosity_model(str): string enum. See available() + """ + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.PropertyRequest( + case_request=self.__request, + property_type=property_type_enum, + property_name=property_name, + time_step=time_step, + porosity_model=porosity_model_enum, + ) - def selected_cells(self): - """Get the selected cells. Synchronous, so returns a list. + request_iterator = self.__generate_property_input_iterator( + values_iterator, request) + self.__properties_stub.SetActiveCellProperty(request_iterator) - Returns: - A list of Cells. - """ - cells = [] - generator = self.selected_cells_async() - for chunk in generator: - for value in chunk.cells: - cells.append(value) - return cells +@add_method(Case) +def set_active_cell_property( + self, + values, + property_type, + property_name, + time_step, + porosity_model="MATRIX_MODEL"): + """Set a cell property for all active cells. - def coarsening_info(self): - """Get a coarsening information for all grids in the case. + Arguments: + values(list): a list of double precision floating point numbers + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + porosity_model(str): string enum. See available() + """ + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.PropertyRequest( + case_request=self.__request, + property_type=property_type_enum, + property_name=property_name, + time_step=time_step, + porosity_model=porosity_model_enum, + ) + request_iterator = self.__generate_property_input_chunks( + values, request) + reply = self.__properties_stub.SetActiveCellProperty(request_iterator) + if reply.accepted_value_count < len(values): + raise IndexError - Returns: - A list of CoarseningInfo objects with two Vec3i min and max objects - for each entry. - """ - return self.__case_stub.GetCoarseningInfoArray(self.__request).data +@add_method(Case) +def set_grid_property( + self, + values, + property_type, + property_name, + time_step, + grid_index=0, + porosity_model="MATRIX_MODEL"): + """Set a cell property for all grid cells. + Arguments: + values(list): a list of double precision floating point numbers + property_type(str): string enum. See available() + property_name(str): name of an Eclipse property + time_step(int): the time step for which to get the property for + grid_index(int): index to the grid we're setting values for + porosity_model(str): string enum. See available() + """ + property_type_enum = Properties_pb2.PropertyType.Value(property_type) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Properties_pb2.PropertyRequest( + case_request=self.__request, + property_type=property_type_enum, + property_name=property_name, + time_step=time_step, + grid_index=grid_index, + porosity_model=porosity_model_enum, + ) + request_iterator = self.__generate_property_input_chunks( + values, request) + reply = self.__properties_stub.SetGridProperty(request_iterator) + if reply.accepted_value_count < len(values): + raise IndexError - def available_nnc_properties(self): - """Get a list of available NNC properties - """ - return self.__nnc_properties_stub.GetAvailableNNCProperties(self.__request).properties +@add_method(Case) +def export_property( + self, + time_step, + property_name, + eclipse_keyword=property, + undefined_value=0.0, + export_file=property): + """ Export an Eclipse property + Arguments: + time_step (int): time step index + property_name (str): property to export + eclipse_keyword (str): Keyword used in export header. Defaults: value of property + undefined_value (double): Value to use for undefined values. Defaults to 0.0 + export_file (str): File name for export. Defaults to the value of property parameter + """ + return self._execute_command(exportProperty=Cmd.ExportPropertyRequest( + caseId=self.id, + timeStep=time_step, + property=property_name, + eclipseKeyword=eclipse_keyword, + undefinedValue=undefined_value, + exportFile=export_file, + )) - def nnc_connections_async(self): - """Get the NNC connections. Async, so returns an iterator. - Returns: - An iterator to a chunk object containing an array NNCConnection objects. - Loop through the chunks and then the connection within the chunk to get all connections. - """ - return self.__nnc_properties_stub.GetNNCConnections(self.__request) +@add_method(Case) +def create_well_bore_stability_plot(self, well_path, time_step, wbs_parameters=None): + """ Create a new well bore stability plot - def nnc_connections(self): - """Get the NNC connection. Synchronous, so returns a list. + Arguments: + well_path(str): well path name + time_step(int): time step - Returns: - A list of NNCConnection objects. - """ - connections = [] - generator = self.nnc_connections_async() - for chunk in generator: - for value in chunk.connections: - connections.append(value) - return connections + Returns: + A new plot object + """ + pb2_parameters = None + if wbs_parameters is not None: + assert(isinstance(wbs_parameters, WbsParameters)) + pb2_parameters = wbs_parameters.pb2_object() - def __nnc_connections_values_async(self, property_name, property_type, time_step): - request = NNCProperties_pb2.NNCValuesRequest(case_id=self.case_id, - property_name=property_name, - property_type=property_type, - time_step=time_step) - return self.__nnc_properties_stub.GetNNCValues(request) + plot_result = self._execute_command(createWellBoreStabilityPlot=Cmd.CreateWbsPlotRequest(caseId=self.id, + wellPath=well_path, + timeStep=time_step, + wbsParameters=pb2_parameters)) + project = self.ancestor(rips.project.Project) + plot = project.plot(view_id=plot_result.createWbsPlotResult.viewId) + assert(plot) + return plot.cast(WellBoreStabilityPlot) - def __nnc_values_generator_to_list(self, generator): - """Converts a NNC values generator to a list.""" - vals = [] - for chunk in generator: - for value in chunk.values: - vals.append(value) - return vals +@add_method(Case) +def import_formation_names(self, formation_files=None): + """ Import formation names into project and apply it to the current case - def nnc_connections_static_values_async(self, property_name): - """Get the static NNC values. Async, so returns an iterator. - Returns: - An iterator to a chunk object containing an list of doubles. - Loop through the chunks and then the values within the chunk to get values - for all the connections. The order of the list matches the list from - nnc_connections, i.e. the nth object of nnc_connections() refers to nth - value in this list. - """ - return self.__nnc_connections_values_async(property_name, NNCProperties_pb2.NNC_STATIC, 0) + Arguments: + formation_files(list): list of files to import - def nnc_connections_static_values(self, property_name): - """Get the static NNC values. - Returns: - A list of doubles. The order of the list matches the list from - nnc_connections, i.e. the nth object of nnc_connections() refers to nth - value in this list. - """ - generator = self.nnc_connections_static_values_async(property_name) - return self.__nnc_values_generator_to_list(generator) + """ + if formation_files is None: + formation_files = [] + elif isinstance(formation_files, str): + formation_files = [formation_files] - def nnc_connections_dynamic_values_async(self, property_name, time_step): - """Get the dynamic NNC values. Async, so returns an iterator. - Returns: - An iterator to a chunk object containing an list of doubles. - Loop through the chunks and then the values within the chunk to get values - for all the connections. The order of the list matches the list from - nnc_connections, i.e. the nth object of nnc_connections() refers to nth - value in this list. - """ - return self.__nnc_connections_values_async(property_name, NNCProperties_pb2.NNC_DYNAMIC, time_step) + res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files, + applyToCaseId=self.id)) - def nnc_connections_dynamic_values(self, property_name, time_step): - """Get the dynamic NNC values. - Returns: - A list of doubles. The order of the list matches the list from - nnc_connections, i.e. the nth object of nnc_connections() refers to nth - value in this list. - """ - generator = self.nnc_connections_dynamic_values_async(property_name, time_step) - return self.__nnc_values_generator_to_list(generator) +@add_method(Case) +def simulation_wells(self): + """Get a list of all simulation wells for a case - def nnc_connections_generated_values_async(self, property_name, time_step): - """Get the generated NNC values. Async, so returns an iterator. - Returns: - An iterator to a chunk object containing an list of doubles. - Loop through the chunks and then the values within the chunk to get values - for all the connections. The order of the list matches the list from - nnc_connections, i.e. the nth object of nnc_connections() refers to nth - value in this list. - """ - return self.__nnc_connections_values_async(property_name, NNCProperties_pb2.NNC_GENERATED, time_step) + Returns: + A list of rips SimulationWell objects + """ + wells = self.descendants(SimulationWell) + return wells - def nnc_connections_generated_values(self, property_name, time_step): - """Get the generated NNC values. - Returns: - A list of doubles. The order of the list matches the list from - nnc_connections, i.e. the nth object of nnc_connections() refers to nth - value in this list. - """ - generator = self.nnc_connections_generated_values_async(property_name, time_step) - return self.__nnc_values_generator_to_list(generator) +@add_method(Case) +def active_cell_centers_async( + self, + porosity_model="MATRIX_MODEL"): + """Get a cell centers for all active cells. Async, so returns an iterator + + Arguments: + porosity_model(str): string enum. See available() + + Returns: + An iterator to a chunk object containing an array of Vec3d values. + Loop through the chunks and then the values within the chunk to get all values. + """ + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Case_pb2.CellInfoRequest(case_request=self.__request, + porosity_model=porosity_model_enum) + return self.__case_stub.GetCellCenterForActiveCells(request) + +@add_method(Case) +def active_cell_centers( + self, + porosity_model="MATRIX_MODEL"): + """Get a cell centers for all active cells. Synchronous, so returns a list. + + Arguments: + porosity_model(str): string enum. See available() + + Returns: + A list of Vec3d + """ + cell_centers = [] + generator = self.active_cell_centers_async(porosity_model) + for chunk in generator: + for value in chunk.centers: + cell_centers.append(value) + return cell_centers + +@add_method(Case) +def active_cell_corners_async( + self, + porosity_model="MATRIX_MODEL"): + """Get a cell corners for all active cells. Async, so returns an iterator + + Arguments: + porosity_model(str): string enum. See available() + + Returns: + An iterator to a chunk object containing an array of CellCorners (which is eight Vec3d values). + Loop through the chunks and then the values within the chunk to get all values. + """ + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) + request = Case_pb2.CellInfoRequest(case_request=self.__request, + porosity_model=porosity_model_enum) + return self.__case_stub.GetCellCornersForActiveCells(request) + +@add_method(Case) +def active_cell_corners( + self, + porosity_model="MATRIX_MODEL"): + """Get a cell corners for all active cells. Synchronous, so returns a list. + + Arguments: + porosity_model(str): string enum. See available() + + Returns: + A list of CellCorners + """ + cell_corners = [] + generator = self.active_cell_corners_async(porosity_model) + for chunk in generator: + for value in chunk.cells: + cell_corners.append(value) + return cell_corners + +@add_method(Case) +def selected_cells_async(self): + """Get the selected cells. Async, so returns an iterator. + Returns: + An iterator to a chunk object containing an array of cells. + Loop through the chunks and then the cells within the chunk to get all cells. + """ + return self.__case_stub.GetSelectedCells(self.__request) + +@add_method(Case) +def selected_cells(self): + """Get the selected cells. Synchronous, so returns a list. + + Returns: + A list of Cells. + """ + cells = [] + generator = self.selected_cells_async() + for chunk in generator: + for value in chunk.cells: + cells.append(value) + return cells + +@add_method(Case) +def coarsening_info(self): + """Get a coarsening information for all grids in the case. + + Returns: + A list of CoarseningInfo objects with two Vec3i min and max objects + for each entry. + """ + return self.__case_stub.GetCoarseningInfoArray(self.__request).data + +@add_method(Case) +def available_nnc_properties(self): + """Get a list of available NNC properties + """ + return self.__nnc_properties_stub.GetAvailableNNCProperties(self.__request).properties + +@add_method(Case) +def nnc_connections_async(self): + """Get the NNC connections. Async, so returns an iterator. + Returns: + An iterator to a chunk object containing an array NNCConnection objects. + Loop through the chunks and then the connection within the chunk to get all connections. + """ + return self.__nnc_properties_stub.GetNNCConnections(self.__request) + +@add_method(Case) +def nnc_connections(self): + """Get the NNC connection. Synchronous, so returns a list. + + Returns: + A list of NNCConnection objects. + """ + connections = [] + generator = self.nnc_connections_async() + for chunk in generator: + for value in chunk.connections: + connections.append(value) + return connections + +@add_method(Case) +def __nnc_connections_values_async(self, property_name, property_type, time_step): + request = NNCProperties_pb2.NNCValuesRequest(case_id=self.id, + property_name=property_name, + property_type=property_type, + time_step=time_step) + return self.__nnc_properties_stub.GetNNCValues(request) + +@add_method(Case) +def __nnc_values_generator_to_list(self, generator): + """Converts a NNC values generator to a list.""" + vals = [] + for chunk in generator: + for value in chunk.values: + vals.append(value) + return vals + +@add_method(Case) +def nnc_connections_static_values_async(self, property_name): + """Get the static NNC values. Async, so returns an iterator. + Returns: + An iterator to a chunk object containing an list of doubles. + Loop through the chunks and then the values within the chunk to get values + for all the connections. The order of the list matches the list from + nnc_connections, i.e. the nth object of nnc_connections() refers to nth + value in this list. + """ + return self.__nnc_connections_values_async(property_name, NNCProperties_pb2.NNC_STATIC, 0) + +@add_method(Case) +def nnc_connections_static_values(self, property_name): + """Get the static NNC values. + Returns: + A list of doubles. The order of the list matches the list from + nnc_connections, i.e. the nth object of nnc_connections() refers to nth + value in this list. + """ + generator = self.nnc_connections_static_values_async(property_name) + return self.__nnc_values_generator_to_list(generator) + +@add_method(Case) +def nnc_connections_dynamic_values_async(self, property_name, time_step): + """Get the dynamic NNC values. Async, so returns an iterator. + Returns: + An iterator to a chunk object containing an list of doubles. + Loop through the chunks and then the values within the chunk to get values + for all the connections. The order of the list matches the list from + nnc_connections, i.e. the nth object of nnc_connections() refers to nth + value in this list. + """ + return self.__nnc_connections_values_async(property_name, NNCProperties_pb2.NNC_DYNAMIC, time_step) + +@add_method(Case) +def nnc_connections_dynamic_values(self, property_name, time_step): + """Get the dynamic NNC values. + Returns: + A list of doubles. The order of the list matches the list from + nnc_connections, i.e. the nth object of nnc_connections() refers to nth + value in this list. + """ + generator = self.nnc_connections_dynamic_values_async(property_name, time_step) + return self.__nnc_values_generator_to_list(generator) + +@add_method(Case) +def nnc_connections_generated_values_async(self, property_name, time_step): + """Get the generated NNC values. Async, so returns an iterator. + Returns: + An iterator to a chunk object containing an list of doubles. + Loop through the chunks and then the values within the chunk to get values + for all the connections. The order of the list matches the list from + nnc_connections, i.e. the nth object of nnc_connections() refers to nth + value in this list. + """ + return self.__nnc_connections_values_async(property_name, NNCProperties_pb2.NNC_GENERATED, time_step) + +@add_method(Case) +def nnc_connections_generated_values(self, property_name, time_step): + """Get the generated NNC values. + Returns: + A list of doubles. The order of the list matches the list from + nnc_connections, i.e. the nth object of nnc_connections() refers to nth + value in this list. + """ + generator = self.nnc_connections_generated_values_async(property_name, time_step) + return self.__nnc_values_generator_to_list(generator) \ No newline at end of file diff --git a/ApplicationCode/GrpcInterface/Python/rips/contour_map.py b/ApplicationCode/GrpcInterface/Python/rips/contour_map.py index 6190784d24..297bbf8372 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/contour_map.py +++ b/ApplicationCode/GrpcInterface/Python/rips/contour_map.py @@ -27,9 +27,8 @@ class ContourMap(View): view_id(int): View Id corresponding to the View Id in ResInsight project. """ - def __init__(self, pdm_object, project, map_type): - View.__init__(self, pdm_object, project) - self.view_id = pdm_object.get_value("ViewId") + def __init__(self, pdm_object, map_type): + View.__init__(self, pdm_object) self.map_type = map_type @@ -48,4 +47,4 @@ class ContourMap(View): exportLocalCoordinates=export_local_coordinates, undefinedValueLabel=undefined_value_label, excludeUndefinedValues=exclude_undefined_values, - viewId=self.view_id)) + viewId=self.id)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/grid.py b/ApplicationCode/GrpcInterface/Python/rips/grid.py index ead51903e4..c80c725ca3 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/grid.py +++ b/ApplicationCode/GrpcInterface/Python/rips/grid.py @@ -28,7 +28,7 @@ class Grid: Returns: Vec3i: class with integer attributes i, j, k giving extent in all three dimensions. """ - case_request = Case_pb2.CaseRequest(id=self.case.case_id) + case_request = Case_pb2.CaseRequest(id=self.case.id) return self.__stub.GetDimensions( Grid_pb2.GridRequest(case_request=case_request, grid_index=self.index)).dimensions @@ -40,7 +40,7 @@ class Grid: Returns: Iterator to a list of Vec3d: class with double attributes x, y, x giving cell centers """ - case_request = Case_pb2.CaseRequest(id=self.case.case_id) + case_request = Case_pb2.CaseRequest(id=self.case.id) chunks = self.__stub.GetCellCenters( Grid_pb2.GridRequest(case_request=case_request, grid_index=self.index)) @@ -66,7 +66,7 @@ class Grid: Returns: iterator to a list of CellCorners: a class with Vec3d for each corner (c0, c1.., c7) """ - case_request = Case_pb2.CaseRequest(id=self.case.case_id) + case_request = Case_pb2.CaseRequest(id=self.case.id) chunks = self.__stub.GetCellCorners( Grid_pb2.GridRequest(case_request=case_request, grid_index=self.index)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/gridcasegroup.py b/ApplicationCode/GrpcInterface/Python/rips/gridcasegroup.py index dbc98ebf42..ef9572c27a 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/gridcasegroup.py +++ b/ApplicationCode/GrpcInterface/Python/rips/gridcasegroup.py @@ -2,74 +2,67 @@ Grid Case Group statistics module """ -from rips.pdmobject import PdmObject +from rips.pdmobject import PdmObject, add_method from rips.view import View from rips.case import Case import rips.generated.Commands_pb2 as Cmd +from rips.generated.pdm_objects import GridCaseGroup - -class GridCaseGroup(PdmObject): - """ResInsight Grid Case Group class - - Operate on a ResInsight case group specified by a Case Group Id integer. - - Attributes: - group_id (int): Grid Case Group Id corresponding to case group Id in ResInsight project. +@add_method(GridCaseGroup) +def create_statistics_case(self): + """Create a Statistics case in the Grid Case Group + + Returns: + A new Case """ - def __init__(self, pdm_object): - self.group_id = pdm_object.get_value("GroupId") - PdmObject.__init__(self, pdm_object._pb2_object, pdm_object._channel, pdm_object._project) + command_reply = self._execute_command( + createStatisticsCase=Cmd.CreateStatisticsCaseRequest( + caseGroupId=self.group_id)) + return Case(self.channel, + command_reply.createStatisticsCaseResult.caseId) - def create_statistics_case(self): - """Create a Statistics case in the Grid Case Group +@add_method(GridCaseGroup) +def statistics_cases(self): + """Get a list of all statistics cases in the Grid Case Group""" + stat_case_collection = self.children("StatisticsCaseCollection")[0] + return stat_case_collection.children("Reservoirs") - Returns: - A new Case - """ - command_reply = self._execute_command( - createStatisticsCase=Cmd.CreateStatisticsCaseRequest( - caseGroupId=self.group_id)) - return Case(self.channel, - command_reply.createStatisticsCaseResult.caseId) +@add_method(GridCaseGroup) +def views(self): + """Get a list of views belonging to a grid case group""" + pdm_objects = self.descendants(EclipseView) + view_list = [] + for pdm_object in pdm_objects: + view_list.append(pdm_object) + return view_list - def statistics_cases(self): - """Get a list of all statistics cases in the Grid Case Group""" - stat_case_collection = self.children("StatisticsCaseCollection")[0] - return stat_case_collection.children("Reservoirs") +@add_method(GridCaseGroup) +def view(self, view_id): + """Get a particular view belonging to a case group by providing view id + Arguments: + id(int): view id - def views(self): - """Get a list of views belonging to a grid case group""" - pdm_objects = self.descendants("ReservoirView") - view_list = [] - for pdm_object in pdm_objects: - view_list.append(View(pdm_object)) - return view_list + Returns: a view object - def view(self, view_id): - """Get a particular view belonging to a case group by providing view id - Arguments: - id(int): view id + """ + views = self.views() + for view_object in views: + if view_object.id == view_id: + return view_object + return None - Returns: a view object +@add_method(GridCaseGroup) +def compute_statistics(self, case_ids=None): + """ Compute statistics for the given case ids - """ - views = self.views() - for view_object in views: - if view_object.id == view_id: - return view_object - return None + Arguments: + case_ids(list of integers): list of case ids. + If this is None all cases in group are included - def compute_statistics(self, case_ids=None): - """ Compute statistics for the given case ids - - Arguments: - case_ids(list of integers): list of case ids. - If this is None all cases in group are included - - """ - if case_ids is None: - case_ids = [] - return self._execute_command( - computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest( - caseIds=case_ids, caseGroupId=self.group_id)) + """ + if case_ids is None: + case_ids = [] + return self._execute_command( + computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest( + caseIds=case_ids, caseGroupId=self.group_id)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/instance.py b/ApplicationCode/GrpcInterface/Python/rips/instance.py index 23a8010cba..1c85198985 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/instance.py +++ b/ApplicationCode/GrpcInterface/Python/rips/instance.py @@ -204,7 +204,7 @@ class Instance: self.client_version_string()) # Service packages - self.project = Project(self.channel) + self.project = Project.create(self.channel) path = os.getcwd() self.set_start_dir(path=path) diff --git a/ApplicationCode/GrpcInterface/Python/rips/pdmobject.py b/ApplicationCode/GrpcInterface/Python/rips/pdmobject.py index b129773b43..e364e614c9 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/pdmobject.py +++ b/ApplicationCode/GrpcInterface/Python/rips/pdmobject.py @@ -3,210 +3,322 @@ ResInsight caf::PdmObject connection module """ +from functools import partial, wraps import grpc +import re +import builtins +import importlib +import inspect +import sys import rips.generated.PdmObject_pb2 as PdmObject_pb2 import rips.generated.PdmObject_pb2_grpc as PdmObject_pb2_grpc import rips.generated.Commands_pb2 as Cmd import rips.generated.Commands_pb2_grpc as CmdRpc +from rips.generated.pdm_objects import PdmObject -class PdmObject: - """ - Generic ResInsight object. Corresponds to items in the Project Tree - """ +def camel_to_snake(name): + s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) + return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() - def _execute_command(self, **command_params): - self.__warnings = [] - response, call = self._commands.Execute.with_call(Cmd.CommandParams(**command_params)) - for key, value in call.trailing_metadata(): - value = value.replace(';;', '\n') - if key == 'warning': - self.__warnings.append(value) +def add_method(cls): + def decorator(func): + setattr(cls, func.__name__, func) + return func # returning func means func can still be used normally + return decorator - return response +def add_static_method(cls): + def decorator(func): + @wraps(func) + def wrapper(*args, **kwargs): + return func(*args, **kwargs) + setattr(cls, func.__name__, wrapper) + # Note we are not binding func, but wrapper which accepts self but does exactly the same as func + return func # returning func means func can still be used normally + return decorator - def __init__(self, pb2_object, channel, project): +@add_method(PdmObject) +def _execute_command(self, **command_params): + self.__warnings = [] + response, call = self._commands.Execute.with_call(Cmd.CommandParams(**command_params)) + for key, value in call.trailing_metadata(): + value = value.replace(';;', '\n') + if key == 'warning': + self.__warnings.append(value) + + return response + +@add_method(PdmObject) +def __custom_init__(self, pb2_object, channel): + self.__warnings = [] + self.__keyword_translation = {} + + if pb2_object is not None: self._pb2_object = pb2_object - self._channel = channel - self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self._channel) - self._commands = CmdRpc.CommandsStub(channel) - self._project = project - self.__warnings = [] + else: + self._pb2_object = PdmObject_pb2.PdmObject(class_keyword=self.__class__.__name__) - @classmethod - def create(cls, class_keyword, channel, project): - pb2_object = PdmObject_pb2.PdmObject(class_keyword=class_keyword) - return cls(pb2_object, channel, project) - - def warnings(self): - return self.__warnings - - def has_warnings(self): - return len(self.__warnings) > 0 - - def pb2_object(self): - """ Private method""" - return self._pb2_object - - def channel(self): - """ Private method""" - return self._channel - - def project(self): - """ Private method""" - return self._project - - def address(self): - """Get the unique address of the PdmObject - - Returns: - A 64-bit unsigned integer address - """ - - return self._pb2_object.address - - def class_keyword(self): - """Get the class keyword in the ResInsight Data Model for the given PdmObject""" - return self._pb2_object.class_keyword - - def set_visible(self, visible): - """Set the visibility of the object in the ResInsight project tree""" - self._pb2_object.visible = visible - - def visible(self): - """Get the visibility of the object in the ResInsight project tree""" - return self._pb2_object.visible + self._channel = channel - def keywords(self): - """Get a list of all parameter keywords available in the object""" - list_of_keywords = [] - for keyword in self._pb2_object.parameters: - list_of_keywords.append(keyword) - return list_of_keywords + if self.pb2_object() is not None and self.channel() is not None: + if self.channel() is not None: + self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self.channel()) + self._commands = CmdRpc.CommandsStub(self.channel()) + + for camel_keyword in self._pb2_object.parameters: + snake_keyword = camel_to_snake(camel_keyword) + setattr(self, snake_keyword, self.__get_grpc_value(camel_keyword)) + self.__keyword_translation[snake_keyword] = camel_keyword + self._superclasses = self.superclasses() - def print_object_info(self): - """Print the structure and data content of the PdmObject""" - print("Class Keyword: " + self.class_keyword()) - for keyword in self.keywords(): - print(keyword + " [" + type(self.get_value(keyword)).__name__ + - "]: " + str(self.get_value(keyword))) +@add_method(PdmObject) +def copy_from(self, object): + """Copy attribute values from object to self + """ + for attribute in dir(object): + if not attribute.startswith('__'): + value = getattr(object, attribute) + if not callable(value): + setattr(self, attribute, value) - def __to_value(self, value): - if value.lower() == 'false': - return False - if value.lower() == 'true': - return True +@add_method(PdmObject) +def cast(self, class_definition): + if class_definition.__name__ == self.class_keyword() or class_definition.__name__ in self._superclasses: + new_object = class_definition(self.pb2_object(), self.channel()) + new_object.copy_from(self) + return new_object + return None + +@add_method(PdmObject) +def warnings(self): + return self.__warnings + +@add_method(PdmObject) + +def has_warnings(self): + return len(self.__warnings) > 0 + +@add_method(PdmObject) +def pb2_object(self): + """ Private method""" + return self._pb2_object + +@add_method(PdmObject) +def channel(self): + """ Private method""" + return self._channel + +@add_method(PdmObject) +def address(self): + """Get the unique address of the PdmObject + + Returns: + A 64-bit unsigned integer address + """ + + return self._pb2_object.address + +@add_method(PdmObject) +def class_keyword(self): + """Get the class keyword in the ResInsight Data Model for the given PdmObject""" + return self._pb2_object.class_keyword + +@add_method(PdmObject) +def set_visible(self, visible): + """Set the visibility of the object in the ResInsight project tree""" + self._pb2_object.visible = visible + +@add_method(PdmObject) +def visible(self): + """Get the visibility of the object in the ResInsight project tree""" + return self._pb2_object.visible + +@add_method(PdmObject) +def print_object_info(self): + """Print the structure and data content of the PdmObject""" + print("=========== " + self.class_keyword() + " =================") + print("Object Attributes: ") + for snake_kw, camel_kw in self.__keyword_translation.items(): + print(" " + snake_kw + " [" + type(getattr(self, snake_kw)).__name__ + + "]: " + str(getattr(self, snake_kw))) + print("Object Methods:") + for method in dir(self): + if not method.startswith("_") and callable(getattr(self, method)): + print (" " + method) + +@add_method(PdmObject) +def __convert_from_grpc_value(self, value): + if value.lower() == 'false': + return False + if value.lower() == 'true': + return True + try: + int_val = int(value) + return int_val + except ValueError: try: - int_val = int(value) - return int_val + float_val = float(value) + return float_val except ValueError: - try: - float_val = float(value) - return float_val - except ValueError: - # We may have a string. Strip internal start and end quotes - value = value.strip('\"') - if self.__islist(value): - return self.__makelist(value) - return value + # We may have a string. Strip internal start and end quotes + value = value.strip('\"') + if self.__islist(value): + return self.__makelist(value) + return value - def __from_value(self, value): - if isinstance(value, bool): - if value: - return "true" - return "false" - if isinstance(value, list): - list_of_strings = [] - for val in value: - list_of_strings.append(self.__from_value('\"' + val + '\"')) - return "[" + ", ".join(list_of_strings) + "]" - return str(value) +@add_method(PdmObject) +def __convert_to_grpc_value(self, value): + if isinstance(value, bool): + if value: + return "true" + return "false" + if isinstance(value, list): + list_of_strings = [] + for val in value: + list_of_strings.append(self.__convert_to_grpc_value('\"' + val + '\"')) + return "[" + ", ".join(list_of_strings) + "]" + return str(value) - def get_value(self, keyword): - """Get the value associated with the provided keyword - Arguments: - keyword(str): A string containing the parameter keyword +@add_method(PdmObject) +def __get_grpc_value(self, camel_keyword): + return self.__convert_from_grpc_value(self._pb2_object.parameters[camel_keyword]) - Returns: - The value of the parameter. Can be int, str or list. - """ - value = self._pb2_object.parameters[keyword] - return self.__to_value(value) +@add_method(PdmObject) +def __set_grpc_value(self, camel_keyword, value): + self._pb2_object.parameters[camel_keyword] = self.__convert_to_grpc_value(value) - def __islist(self, value): - return value.startswith("[") and value.endswith("]") +@add_method(PdmObject) +def set_value(self, snake_keyword, value): + """Set the value associated with the provided keyword and updates ResInsight + Arguments: + keyword(str): A string containing the parameter keyword + value(varying): A value matching the type of the parameter. + See keyword documentation and/or print_object_info() to find + the correct data type. + """ + setattr(self, snake_keyword, value) + self.update() - def __makelist(self, list_string): - list_string = list_string.lstrip("[") - list_string = list_string.rstrip("]") - strings = list_string.split(", ") - values = [] - for string in strings: - values.append(self.__to_value(string)) - return values +@add_method(PdmObject) +def __islist(self, value): + return value.startswith("[") and value.endswith("]") - def set_value(self, keyword, value): - """Set the value associated with the provided keyword - Arguments: - keyword(str): A string containing the parameter keyword - value(varying): A value matching the type of the parameter. - See keyword documentation and/or print_object_info() to find - the correct data type. - """ - self._pb2_object.parameters[keyword] = self.__from_value(value) +@add_method(PdmObject) +def __makelist(self, list_string): + list_string = list_string.lstrip("[") + list_string = list_string.rstrip("]") + strings = list_string.split(", ") + values = [] + for string in strings: + values.append(self.__convert_from_grpc_value(string)) + return values - def descendants(self, class_keyword): - """Get a list of all project tree descendants matching the class keyword - Arguments: - class_keyword[str]: A class keyword matching the type of class wanted +@add_method(PdmObject) +def descendants(self, class_keyword_or_class): + """Get a list of all project tree descendants matching the class keyword + Arguments: + class_keyword_or_class[str/Class]: A class keyword matching the type of class wanted or a Class definition - Returns: - A list of PdmObjects matching the keyword provided - """ - request = PdmObject_pb2.PdmDescendantObjectRequest( - object=self._pb2_object, child_keyword=class_keyword) - object_list = self._pdm_object_stub.GetDescendantPdmObjects( - request).objects + Returns: + A list of PdmObjects matching the keyword provided + """ + class_definition = PdmObject + class_keyword = "" + if isinstance(class_keyword_or_class, str): + class_keyword = class_keyword_or_class + else: + assert(inspect.isclass(class_keyword_or_class)) + class_keyword = class_keyword_or_class.__name__ + class_definition = class_keyword_or_class + + request = PdmObject_pb2.PdmDescendantObjectRequest( + object=self._pb2_object, child_keyword=class_keyword) + object_list = self._pdm_object_stub.GetDescendantPdmObjects( + request).objects + child_list = [] + for pb2_object in object_list: + pdm_object = PdmObject(pb2_object=pb2_object, channel=self.channel()) + if class_definition.__name__ == PdmObject.__name__: + child_list.append(pdm_object) + else: + casted_object = pdm_object.cast(class_definition) + if casted_object: + child_list.append(casted_object) + return child_list + +@add_method(PdmObject) +def children(self, child_field, class_definition=PdmObject): + """Get a list of all direct project tree children inside the provided child_field + Arguments: + child_field[str]: A field name + Returns: + A list of PdmObjects inside the child_field + """ + request = PdmObject_pb2.PdmChildObjectRequest(object=self._pb2_object, + child_field=child_field) + try: + object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects child_list = [] - for pdm_object in object_list: - child_list.append(PdmObject(pdm_object, self._channel, self._project)) + for pb2_object in object_list: + pdm_object = PdmObject(pb2_object=pb2_object, channel=self.channel()) + if class_definition.__name__ == PdmObject.__name__: + child_list.append(pdm_object) + else: + child_list.append(pdm_object.cast(class_definition)) return child_list + except grpc.RpcError as e: + if e.code() == grpc.StatusCode.NOT_FOUND: + return [] + raise e - def children(self, child_field): - """Get a list of all direct project tree children inside the provided child_field - Arguments: - child_field[str]: A field name - Returns: - A list of PdmObjects inside the child_field - """ - request = PdmObject_pb2.PdmChildObjectRequest(object=self._pb2_object, - child_field=child_field) - try: - object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects - child_list = [] - for pdm_object in object_list: - child_list.append(PdmObject(pdm_object, self._channel, self._project)) - return child_list - except grpc.RpcError as e: - if e.code() == grpc.StatusCode.NOT_FOUND: - return [] - raise e +@add_method(PdmObject) +def ancestor(self, class_keyword_or_class): + """Find the first ancestor that matches the provided class_keyword + Arguments: + class_keyword_or_class[str/Class]: A class keyword matching the type of class wanted or a Class definition + """ + class_definition = PdmObject + class_keyword = "" + if isinstance(class_keyword_or_class, str): + class_keyword = class_keyword_or_class + else: + assert(inspect.isclass(class_keyword_or_class)) + class_keyword = class_keyword_or_class.__name__ + class_definition = class_keyword_or_class - def ancestor(self, class_keyword): - """Find the first ancestor that matches the provided class_keyword - Arguments: - class_keyword[str]: A class keyword matching the type of class wanted - """ - request = PdmObject_pb2.PdmParentObjectRequest( - object=self._pb2_object, parent_keyword=class_keyword) - try: - return PdmObject(self._pdm_object_stub.GetAncestorPdmObject(request), - self._channel, self._project) - except grpc.RpcError as e: - if e.code() == grpc.StatusCode.NOT_FOUND: - return None - raise e + request = PdmObject_pb2.PdmParentObjectRequest( + object=self._pb2_object, parent_keyword=class_keyword) + try: + pb2_object = self._pdm_object_stub.GetAncestorPdmObject(request) + pdm_object = PdmObject(pb2_object=pb2_object, + channel=self._channel) + if class_definition.__name__ == PdmObject.__name__: + return pdm_object + else: + return pdm_object.cast(class_definition) + except grpc.RpcError as e: + if e.code() == grpc.StatusCode.NOT_FOUND: + return None + raise e + +@add_method(PdmObject) +def update(self): + """Sync all fields from the Python Object to ResInsight""" + if self._pdm_object_stub is not None and self._pb2_object is not None: + for snake_kw, camel_kw in self.__keyword_translation.items(): + self.__set_grpc_value(camel_kw, getattr(self, snake_kw)) - def update(self): - """Sync all fields from the Python Object to ResInsight""" self._pdm_object_stub.UpdateExistingPdmObject(self._pb2_object) + else: + raise Exception("Object is not connected to GRPC service so cannot update ResInsight") + +@add_method(PdmObject) +def superclasses(self): + names = [] + mod = importlib.import_module("rips.generated.pdm_objects") + for name, obj in inspect.getmembers(mod): + if (inspect.isclass(obj) and name == self.class_keyword()): + class_hierarchy = inspect.getmro(obj) + for cls in class_hierarchy: + names.append(cls.__name__) + return names diff --git a/ApplicationCode/GrpcInterface/Python/rips/plot.py b/ApplicationCode/GrpcInterface/Python/rips/plot.py index 8614603dd2..074c21466d 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/plot.py +++ b/ApplicationCode/GrpcInterface/Python/rips/plot.py @@ -4,32 +4,24 @@ ResInsight 2d plot module import rips.generated.Commands_pb2 as Cmd from rips.pdmobject import PdmObject +from rips.generated.pdm_objects import PlotWindow, Plot +from rips.pdmobject import add_method -class Plot(PdmObject): - """ResInsight plot class - - Attributes: - view_id(int): View Id corresponding to the View Id in ResInsight project. - - """ - def __init__(self, pdm_object): - PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project()) - self.view_id = pdm_object.get_value("ViewId") - - def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG'): - """ Export snapshot for the current plot +@add_method(PlotWindow) +def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG'): + """ Export snapshot for the current plot - Arguments: - export_folder(str): The path to export to. By default will use the global export folder - prefix (str): Exported file name prefix - output_format(str): Enum string. Can be 'PNG' or 'PDF'. + Arguments: + export_folder(str): The path to export to. By default will use the global export folder + prefix (str): Exported file name prefix + output_format(str): Enum string. Can be 'PNG' or 'PDF'. - """ - return self._execute_command( - exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS', - prefix=file_prefix, - viewId=self.view_id, - exportFolder=export_folder, - plotOutputFormat=output_format)) + """ + return self._execute_command( + exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS', + prefix=file_prefix, + viewId=self.id, + exportFolder=export_folder, + plotOutputFormat=output_format)) \ No newline at end of file diff --git a/ApplicationCode/GrpcInterface/Python/rips/project.py b/ApplicationCode/GrpcInterface/Python/rips/project.py index 7b4f45eb10..dcbd5bcf19 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/project.py +++ b/ApplicationCode/GrpcInterface/Python/rips/project.py @@ -3,343 +3,364 @@ """ The ResInsight project module """ +import builtins import grpc from rips.case import Case from rips.gridcasegroup import GridCaseGroup -from rips.pdmobject import PdmObject +from rips.pdmobject import PdmObject, add_method, add_static_method from rips.plot import Plot from rips.view import View -from rips.well import Well +from rips.wellpath import WellPathBase from rips.contour_map import ContourMap, ContourMapType import rips.generated.Commands_pb2 as Cmd from rips.generated.Definitions_pb2 import Empty import rips.generated.Project_pb2_grpc as Project_pb2_grpc +import rips.generated.Project_pb2 as Project_pb2 +import rips.generated.PdmObject_pb2 as PdmObject_pb2 +from rips.generated.pdm_objects import Project, PlotWindow -class Project(PdmObject): - """ResInsight project. Not intended to be created separately. +@add_method(Project) +def __custom_init__(self, pb2_object, channel): + self._project_stub = Project_pb2_grpc.ProjectStub(self._channel) + +@add_static_method(Project) +def create(channel): + project_stub = Project_pb2_grpc.ProjectStub(channel) + pb2_object = project_stub.GetPdmObject(Empty()) + return Project(pb2_object, channel) + +@add_method(Project) +def open(self, path): + """Open a new project from the given path + + Arguments: + path(str): path to project file - Automatically created and assigned to Instance. """ - def __init__(self, channel): - self._project_stub = Project_pb2_grpc.ProjectStub(channel) - PdmObject.__init__(self, self._project_stub.GetPdmObject(Empty()), - channel, self) - - def open(self, path): - """Open a new project from the given path - - Arguments: - path(str): path to project file - - """ - self._execute_command(openProject=Cmd.FilePathRequest(path=path)) - return self + self._execute_command(openProject=Cmd.FilePathRequest(path=path)) + return self - def save(self, path=""): - """Save the project to the existing project file, or to a new file - Arguments: - path(str): File path to the file to save the project to. If empty, saves to the active project file - """ - self._execute_command(saveProject=Cmd.SaveProjectRequest(filePath=path)) - return self +@add_method(Project) +def save(self, path=""): + """Save the project to the existing project file, or to a new file + Arguments: + path(str): File path to the file to save the project to. If empty, saves to the active project file + """ + self._execute_command(saveProject=Cmd.SaveProjectRequest(filePath=path)) + return self - def close(self): - """Close the current project (and open new blank project)""" - self._execute_command(closeProject=Empty()) +@add_method(Project) +def close(self): + """Close the current project (and open new blank project)""" + self._execute_command(closeProject=Empty()) - def load_case(self, path): - """Load a new case from the given file path +@add_method(Project) +def load_case(self, path): + """Load a new case from the given file path - Arguments: - path(str): file path to case - Returns: - A rips Case object - """ - command_reply = self._execute_command(loadCase=Cmd.FilePathRequest( - path=path)) - return Case(self._channel, command_reply.loadCaseResult.id, self) + Arguments: + path(str): file path to case + Returns: + A rips Case object + """ + command_reply = self._execute_command(loadCase=Cmd.FilePathRequest( + path=path)) + return self.case(command_reply.loadCaseResult.id) - def selected_cases(self): - """Get a list of all cases selected in the project tree +@add_method(Project) +def selected_cases(self): + """Get a list of all cases selected in the project tree - Returns: - A list of rips Case objects - """ - case_infos = self._project_stub.GetSelectedCases(Empty()) - cases = [] - for case_info in case_infos.data: - cases.append(Case(self._channel, case_info.id, self)) - return cases + Returns: + A list of rips Case objects + """ + case_infos = self._project_stub.GetSelectedCases(Empty()) + cases = [] + for case_info in case_infos.data: + cases.append(self.case(case_info.id)) + return cases - def cases(self): - """Get a list of all cases in the project +@add_method(Project) +def cases(self): + """Get a list of all cases in the project - Returns: - A list of rips Case objects - """ - try: - case_infos = self._project_stub.GetAllCases(Empty()) + Returns: + A list of rips Case objects + """ + pdm_objects = self.descendants(Case.__name__) - cases = [] - for case_info in case_infos.data: - cases.append(Case(self._channel, case_info.id, self)) - return cases - except grpc.RpcError as rpc_error: - if rpc_error.code() == grpc.StatusCode.NOT_FOUND: - return [] - print("ERROR: ", rpc_error) - return [] + cases = [] + for pdm_object in pdm_objects: + cases.append(pdm_object.cast(Case)) + return cases - def case(self, case_id): - """Get a specific case from the provided case Id +@add_method(Project) +def case(self, case_id): + """Get a specific case from the provided case Id - Arguments: - id(int): case id - Returns: - A rips Case object - """ - try: - case = Case(self._channel, case_id, self) + Arguments: + id(int): case id + Returns: + A rips Case object + """ + allCases = self.cases() + for case in allCases: + if case.id == case_id: return case - except grpc.RpcError: - return None + return None - def replace_source_cases(self, grid_list_file, case_group_id=0): - """Replace all source cases within a case group +@add_method(Project) +def replace_source_cases(self, grid_list_file, case_group_id=0): + """Replace all source cases within a case group - Arguments: - grid_list_file (str): path to file containing a list of cases - case_group_id (int): id of the case group to replace - """ - return self._execute_command( - replaceSourceCases=Cmd.ReplaceSourceCasesRequest( - gridListFile=grid_list_file, caseGroupId=case_group_id)) + Arguments: + grid_list_file (str): path to file containing a list of cases + case_group_id (int): id of the case group to replace + """ + return self._execute_command( + replaceSourceCases=Cmd.ReplaceSourceCasesRequest( + gridListFile=grid_list_file, caseGroupId=case_group_id)) - def create_grid_case_group(self, case_paths): - """Create a Grid Case Group from a list of cases +@add_method(Project) +def create_grid_case_group(self, case_paths): + """Create a Grid Case Group from a list of cases - Arguments: - case_paths (list): list of file path strings - Returns: - A case group id and name - """ - command_reply = self._execute_command( - createGridCaseGroup=Cmd.CreateGridCaseGroupRequest( - casePaths=case_paths)) - return self.grid_case_group( - command_reply.createGridCaseGroupResult.groupId) + Arguments: + case_paths (list): list of file path strings + Returns: + A case group id and name + """ + command_reply = self._execute_command( + createGridCaseGroup=Cmd.CreateGridCaseGroupRequest( + casePaths=case_paths)) + return self.grid_case_group( + command_reply.createGridCaseGroupResult.groupId) - def views(self): - """Get a list of views belonging to a project""" - pdm_objects = self.descendants("ReservoirView") - view_list = [] - for pdm_object in pdm_objects: - view_list.append(View(pdm_object, self._project)) - return view_list +@add_method(Project) +def views(self): + """Get a list of views belonging to a project""" + pdm_objects = self.descendants("ReservoirView") + view_list = [] + for pdm_object in pdm_objects: + view_list.append(View(pdm_object)) + return view_list - def view(self, view_id): - """Get a particular view belonging to a case by providing view id +@add_method(Project) +def view(self, view_id): + """Get a particular view belonging to a case by providing view id - Arguments: - view_id(int): view id - Returns: a view object - """ - views = self.views() - for view_object in views: - if view_object.view_id == view_id: - return view_object - return None + Arguments: + view_id(int): view id + Returns: a view object + """ + views = self.views() + for view_object in views: + if view_object.id == view_id: + return view_object + return None - def plots(self): - """Get a list of all plots belonging to a project""" - pdm_objects = self.descendants("RimPlotWindow") - plot_list = [] - for pdm_object in pdm_objects: - plot = Plot(pdm_object) - if plot.view_id != -1: - plot_list.append(plot) - return plot_list +@add_method(Project) +def plots(self): + """Get a list of all plots belonging to a project""" + pdm_objects = self.descendants(PlotWindow) + plot_list = [] + for pdm_object in pdm_objects: + if pdm_object.id != -1: + plot_list.append(pdm_object) + return plot_list - def plot(self, view_id): - """Get a particular plot by providing view id - Arguments: - view_id(int): view id - Returns: a plot object - """ - plots = self.plots() - for plot_object in plots: - if plot_object.view_id == view_id: - return plot_object - return None +@add_method(Project) +def plot(self, view_id): + """Get a particular plot by providing view id + Arguments: + view_id(int): view id + Returns: a plot object + """ + plots = self.plots() + for plot_object in plots: + if plot_object.id == view_id: + return plot_object + return None - def contour_maps(self, map_type=ContourMapType.ECLIPSE): - """Get a list of all contour maps belonging to a project""" +@add_method(Project) +def contour_maps(self, map_type=ContourMapType.ECLIPSE): + """Get a list of all contour maps belonging to a project""" - pdm_objects = self.descendants(ContourMapType.get_identifier(map_type)) - contour_maps = [] - for pdm_object in pdm_objects: - contour_maps.append(ContourMap(pdm_object, self._project, map_type)) - return contour_maps + pdm_objects = self.descendants(ContourMapType.get_identifier(map_type)) + contour_maps = [] + for pdm_object in pdm_objects: + contour_maps.append(ContourMap(pdm_object, map_type)) + return contour_maps - def well_paths(self): - """Get a list of all the well path names in the project""" - pdm_objects = self.descendants("WellPathBase") - well_path_list = [] - for pdm_object in pdm_objects: - well_path_list.append(pdm_object.get_value("WellPathName")) - return well_path_list +@add_method(Project) +def grid_case_groups(self): + """Get a list of all grid case groups in the project""" + case_groups = self.descendants(GridCaseGroup) + return case_groups - def grid_case_groups(self): - """Get a list of all grid case groups in the project""" - case_groups = self.descendants("RimIdenticalGridCaseGroup") - - case_group_list = [] - for pdm_group in case_groups: - case_group_list.append(GridCaseGroup(pdm_group)) - return case_group_list - - def grid_case_group(self, group_id): - """Get a particular grid case group belonging to a project +@add_method(Project) +def grid_case_group(self, group_id): + """Get a particular grid case group belonging to a project - Arguments: - groupId(int): group id + Arguments: + groupId(int): group id - Returns: a grid case group object - """ - case_groups = self.grid_case_groups() - for case_group in case_groups: - if case_group.group_id == group_id: - return case_group - return None + Returns: a grid case group object + """ + case_groups = self.grid_case_groups() + for case_group in case_groups: + if case_group.group_id == group_id: + return case_group + return None - def export_multi_case_snapshots(self, grid_list_file): - """Export snapshots for a set of cases +@add_method(Project) +def export_multi_case_snapshots(self, grid_list_file): + """Export snapshots for a set of cases - Arguments: - grid_list_file (str): Path to a file containing a list of grids to export snapshot for - """ - return self._execute_command( - exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest( - gridListFile=grid_list_file)) + Arguments: + grid_list_file (str): Path to a file containing a list of grids to export snapshot for + """ + return self._execute_command( + exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest( + gridListFile=grid_list_file)) - def export_snapshots(self, snapshot_type='ALL', prefix='', plot_format='PNG'): - """ Export all snapshots of a given type +@add_method(Project) +def export_snapshots(self, snapshot_type='ALL', prefix='', plot_format='PNG'): + """ Export all snapshots of a given type - Arguments: - snapshot_type (str): Enum string ('ALL', 'VIEWS' or 'PLOTS') - prefix (str): Exported file name prefix - plot_format(str): Enum string, 'PNG' or 'PDF' - """ - return self._execute_command( - exportSnapshots=Cmd.ExportSnapshotsRequest( - type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1, plotOutputFormat=plot_format)) + Arguments: + snapshot_type (str): Enum string ('ALL', 'VIEWS' or 'PLOTS') + prefix (str): Exported file name prefix + plot_format(str): Enum string, 'PNG' or 'PDF' + """ + return self._execute_command( + exportSnapshots=Cmd.ExportSnapshotsRequest( + type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1, plotOutputFormat=plot_format)) - def export_well_paths(self, well_paths=None, md_step_size=5.0): - """ Export a set of well paths +@add_method(Project) +def export_well_paths(self, well_paths=None, md_step_size=5.0): + """ Export a set of well paths - Arguments: - well_paths(list): List of strings of well paths. If none, export all. - md_step_size(double): resolution of the exported well path - """ - if well_paths is None: - well_paths = [] - elif isinstance(well_paths, str): - well_paths = [well_paths] - return self._execute_command(exportWellPaths=Cmd.ExportWellPathRequest( - wellPathNames=well_paths, mdStepSize=md_step_size)) + Arguments: + well_paths(list): List of strings of well paths. If none, export all. + md_step_size(double): resolution of the exported well path + """ + if well_paths is None: + well_paths = [] + elif isinstance(well_paths, str): + well_paths = [well_paths] + return self._execute_command(exportWellPaths=Cmd.ExportWellPathRequest( + wellPathNames=well_paths, mdStepSize=md_step_size)) - def scale_fracture_template(self, template_id, half_length, height, - d_factor, conductivity): - """ Scale fracture template parameters +@add_method(Project) +def scale_fracture_template(self, template_id, half_length, height, + d_factor, conductivity): + """ Scale fracture template parameters - Arguments: - template_id(int): ID of fracture template - half_length (double): Half Length scale factor - height (double): Height scale factor - d_factor (double): D-factor scale factor - conductivity (double): Conductivity scale factor - """ - return self._execute_command( - scaleFractureTemplate=Cmd.ScaleFractureTemplateRequest( - id=template_id, - halfLength=half_length, - height=height, - dFactor=d_factor, - conductivity=conductivity)) + Arguments: + template_id(int): ID of fracture template + half_length (double): Half Length scale factor + height (double): Height scale factor + d_factor (double): D-factor scale factor + conductivity (double): Conductivity scale factor + """ + return self._execute_command( + scaleFractureTemplate=Cmd.ScaleFractureTemplateRequest( + id=template_id, + halfLength=half_length, + height=height, + dFactor=d_factor, + conductivity=conductivity)) - def set_fracture_containment(self, template_id, top_layer, base_layer): - """ Set fracture template containment parameters +@add_method(Project) +def set_fracture_containment(self, template_id, top_layer, base_layer): + """ Set fracture template containment parameters - Arguments: - template_id(int): ID of fracture template - top_layer (int): Top layer containment - base_layer (int): Base layer containment - """ - return self._execute_command( - setFractureContainment=Cmd.SetFracContainmentRequest( - id=template_id, topLayer=top_layer, baseLayer=base_layer)) + Arguments: + template_id(int): ID of fracture template + top_layer (int): Top layer containment + base_layer (int): Base layer containment + """ + return self._execute_command( + setFractureContainment=Cmd.SetFracContainmentRequest( + id=template_id, topLayer=top_layer, baseLayer=base_layer)) - def import_well_paths(self, well_path_files=None, well_path_folder=''): - """ Import well paths into project +@add_method(Project) +def import_well_paths(self, well_path_files=None, well_path_folder=''): + """ Import well paths into project - Arguments: - well_path_files(list): List of file paths to import - well_path_folder(str): A folder path containing files to import + Arguments: + well_path_files(list): List of file paths to import + well_path_folder(str): A folder path containing files to import - Returns: - A list of well path names (strings) - """ - if well_path_files is None: - well_path_files = [] + Returns: + A list of WellPathBase objects + """ + if well_path_files is None: + well_path_files = [] - res = self._execute_command(importWellPaths=Cmd.ImportWellPathsRequest(wellPathFolder=well_path_folder, - wellPathFiles=well_path_files)) - return res.importWellPathsResult.wellPathNames + res = self._execute_command(importWellPaths=Cmd.ImportWellPathsRequest(wellPathFolder=well_path_folder, + wellPathFiles=well_path_files)) + well_paths = [] + for well_path_name in res.importWellPathsResult.wellPathNames: + well_paths.append(self.well_path_by_name(well_path_name)) + return well_paths - def wells(self): - """Get a list of all wells in the project +@add_method(Project) +def well_paths(self): + """Get a list of all well paths in the project - Returns: - A list of rips Well objects - """ - pdm_objects = self.descendants("WellPathBase") - wells = [] - for pdm_object in pdm_objects: - wells.append(Well(pdm_object.get_value("WellPathName"), pdm_object)) - return wells + Returns: + A list of rips WellPathBase objects + """ + return self.descendants(WellPathBase) +@add_method(Project) +def well_path_by_name(self, well_path_name): + """Get a specific well path by name from the project - def import_well_log_files(self, well_log_files=None, well_log_folder=''): - """ Import well log files into project + Returns: + A WellPathBase object + """ + all_well_paths = self.well_paths() + for well_path in all_well_paths: + if well_path.name == well_path_name: + return well_path + return None - Arguments: - well_log_files(list): List of file paths to import - well_log_folder(str): A folder path containing files to import +@add_method(Project) +def import_well_log_files(self, well_log_files=None, well_log_folder=''): + """ Import well log files into project - Returns: - A list of well path names (strings) that had logs imported - """ + Arguments: + well_log_files(list): List of file paths to import + well_log_folder(str): A folder path containing files to import - if well_log_files is None: - well_log_files = [] - res = self._execute_command(importWellLogFiles=Cmd.ImportWellLogFilesRequest(wellLogFolder=well_log_folder, - wellLogFiles=well_log_files)) - return res.importWellLogFilesResult.wellPathNames + Returns: + A list of well path names (strings) that had logs imported + """ - def import_formation_names(self, formation_files=None): - """ Import formation names into project + if well_log_files is None: + well_log_files = [] + res = self._execute_command(importWellLogFiles=Cmd.ImportWellLogFilesRequest(wellLogFolder=well_log_folder, + wellLogFiles=well_log_files)) + return res.importWellLogFilesResult.wellPathNames - Arguments: - formation_files(list): list of files to import +@add_method(Project) +def import_formation_names(self, formation_files=None): + """ Import formation names into project - """ - if formation_files is None: - formation_files = [] - elif isinstance(formation_files, str): - formation_files = [formation_files] + Arguments: + formation_files(list): list of files to import - res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files, - applyToCaseId=-1)) + """ + if formation_files is None: + formation_files = [] + elif isinstance(formation_files, str): + formation_files = [formation_files] + + res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files, + applyToCaseId=-1)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/simulation_well.py b/ApplicationCode/GrpcInterface/Python/rips/simulation_well.py index 27603c286f..b2b9773acd 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/simulation_well.py +++ b/ApplicationCode/GrpcInterface/Python/rips/simulation_well.py @@ -10,30 +10,29 @@ import rips.generated.Properties_pb2 as Properties_pb2 import rips.generated.Properties_pb2_grpc as Properties_pb2_grpc import rips.generated.Commands_pb2 as Cmd +from rips.generated.pdm_objects import SimulationWell -from rips.pdmobject import PdmObject +from rips.pdmobject import PdmObject, add_method +import rips.case -class SimulationWell(PdmObject): - """ResInsight simulation well class +@add_method(SimulationWell) +def __custom_init__(self, pb2_object, channel): + self._simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(channel) - Attributes: - name(string): Name of the well. +@add_method(SimulationWell) +def status(self, timestep): + sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case().id, + well_name=self.name, + timestep=timestep) + return self._simulation_well_stub.GetSimulationWellStatus(sim_well_request) - """ - def __init__(self, name, case_id, pdm_object): - PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project()) - self._simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(pdm_object.channel()) - self.name = name - self.case_id = case_id +@add_method(SimulationWell) +def cells(self, timestep): + sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case().id, + well_name=self.name, + timestep=timestep) + return self._simulation_well_stub.GetSimulationWellCells(sim_well_request).data - def status(self, timestep): - sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case_id, - well_name=self.name, - timestep=timestep) - return self._simulation_well_stub.GetSimulationWellStatus(sim_well_request) - - def cells(self, timestep): - sim_well_request = SimulationWell_pb2.SimulationWellRequest(case_id=self.case_id, - well_name=self.name, - timestep=timestep) - return self._simulation_well_stub.GetSimulationWellCells(sim_well_request).data +@add_method(SimulationWell) +def case(self): + return self.ancestor(rips.case.Case) diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py index 862bc32f72..0d2f3f1595 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py @@ -20,7 +20,7 @@ def test_EmptyProject(rips_instance, initialize_test): def test_OneCase(rips_instance, initialize_test): case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID") assert(case.name == "TEST10K_FLT_LGR_NNC") - assert(case.case_id == 0) + assert(case.id == 0) cases = rips_instance.project.cases() assert(len(cases) is 1) @@ -120,11 +120,9 @@ def test_10k(rips_instance, initialize_test): def test_PdmObject(rips_instance, initialize_test): case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.load_case(path=case_path) - assert(case.case_id == 0) + assert(case.id == 0) assert(case.address() is not 0) assert(case.class_keyword() == "EclipseCase") - case_id = case.get_value('CaseId') - assert(case_id == case.case_id) @pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux") def test_brugge_0010(rips_instance, initialize_test): @@ -146,21 +144,21 @@ def test_replaceCase(rips_instance, initialize_test): case = project.case(case_id=0) assert(case is not None) assert(case.name == "TEST10K_FLT_LGR_NNC") - assert(case.case_id == 0) + assert(case.id == 0) cases = rips_instance.project.cases() assert(len(cases) is 1) case.replace(new_grid_file=case_path) # Check that the case object has been changed assert(case.name == "Real0--BRUGGE_0000.EGRID") - assert(case.case_id == 0) + assert(case.id == 0) cases = rips_instance.project.cases() assert(len(cases) is 1) # Check that retrieving the case object again will yield the changed object case = project.case(case_id=0) assert(case.name == "Real0--BRUGGE_0000.EGRID") - assert(case.case_id == 0) + assert(case.id == 0) def test_loadNonExistingCase(rips_instance, initialize_test): case_path = "Nonsense/Nonsense/Nonsense" diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_project.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_project.py index 699000ed72..a147e34cc0 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_project.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_project.py @@ -14,7 +14,7 @@ def test_loadProject(rips_instance, initialize_test): case = project.cases()[0] assert(case is not None) assert(case.name == "TEST10K_FLT_LGR_NNC") - assert(case.case_id == 0) + assert(case.id == 0) cases = rips_instance.project.cases() assert(len(cases) is 1) @@ -23,15 +23,17 @@ def test_well_log_plots(rips_instance, initialize_test): plots = project.plots() well_log_plots = [] for plot in plots: - well_log_plot = rips.WellLogPlot.from_pdm_object(plot) + well_log_plot = plot.cast(rips.WellLogPlot) if well_log_plot is not None: - assert(well_log_plot.depth_type() == "MEASURED_DEPTH") + well_log_plot.print_object_info() + assert(well_log_plot.depth_type == "MEASURED_DEPTH") well_log_plots.append(well_log_plot) assert(len(well_log_plots) == 2) with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname: for well_log_plot in well_log_plots: - well_log_plot.set_depth_type("TRUE_VERTICAL_DEPTH_RKB") + well_log_plot.depth_type = "TRUE_VERTICAL_DEPTH_RKB" + well_log_plot.update() if rips_instance.is_gui(): well_log_plot.export_snapshot(tmpdirname) well_log_plot.export_data_as_las(tmpdirname) @@ -44,9 +46,9 @@ def test_well_log_plots(rips_instance, initialize_test): plots2 = project.plots() for plot2 in plots2: - well_log_plot2 = rips.WellLogPlot.from_pdm_object(plot) + well_log_plot2 = plot2.cast(rips.WellLogPlot) if well_log_plot2 is not None: - assert(well_log_plot2.depth_type() == "TRUE_VERTICAL_DEPTH_RKB") + assert(well_log_plot2.depth_type == "TRUE_VERTICAL_DEPTH_RKB") @pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux") def test_loadGridCaseGroup(rips_instance, initialize_test): diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py index 8475b8c3e7..0332b78834 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py @@ -12,8 +12,8 @@ def test_10k(rips_instance, initialize_test): case = rips_instance.project.load_case(path=case_path) assert(len(case.grids()) == 2) well_path_files = [case_root_path + "/wellpath_a.dev", case_root_path + "/wellpath_b.dev"] - well_paths = rips_instance.project.import_well_paths(well_path_files) - wells = rips_instance.project.wells() + well_path_names = rips_instance.project.import_well_paths(well_path_files) + wells = rips_instance.project.well_paths() assert(len(wells) == 2) assert(wells[0].name == "Well Path A") assert(wells[1].name == "Well Path B") diff --git a/ApplicationCode/GrpcInterface/Python/rips/view.py b/ApplicationCode/GrpcInterface/Python/rips/view.py index 77b6e402f5..9762595fb7 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/view.py +++ b/ApplicationCode/GrpcInterface/Python/rips/view.py @@ -1,217 +1,201 @@ """ ResInsight 3d view module """ + +import builtins import rips.generated.Commands_pb2 as Cmd import rips.case # Circular import of Case, which already imports View. Use full name. -from rips.pdmobject import PdmObject +from rips.pdmobject import add_method +from rips.generated.pdm_objects import View, ViewWindow, ReservoirView, GeoMechView +@add_method(View) +def is_eclipse_view(self): + return isinstance(self, ReservoirView) -class View(PdmObject): - """ResInsight view class +@add_method(View) +def is_geomech_view(self): + return isinstance(self, GeoMechView) - Attributes: - view_id(int): View Id corresponding to the View Id in ResInsight project. +@add_method(View) +def cell_result(self): + """Retrieve the current cell results""" + return self.children("GridCellResult")[0] + +@add_method(View) +def apply_cell_result(self, result_type, result_variable): + """Apply a regular cell result + + Arguments: + result_type (str): String representing the result category. The valid values are + - DYNAMIC_NATIVE + - STATIC_NATIVE + - SOURSIMRL + - GENERATED + - INPUT_PROPERTY + - FORMATION_NAMES + - FLOW_DIAGNOSTICS + - INJECTION_FLOODING + result_variable (str): String representing the result variable. + """ + cell_result = self.cell_result() + cell_result.result_type = result_type + cell_result.result_variable = result_variable + cell_result.update() + +@add_method(View) +def apply_flow_diagnostics_cell_result( + self, + result_variable='TOF', + selection_mode='FLOW_TR_BY_SELECTION', + injectors=None, + producers=None): + """Apply a flow diagnostics cell result + + Parameter | Description | Type + ------------------- | ------------------------------------------------------ | ----- + result_variable | String representing the result value | String + selection_mode | String specifying which tracers to select | String + injectors | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List + producers | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List + + ##### Enum compdat_export + + Option | Description + ------------------------| ------------ + "TOF" | Time of flight + "Fraction" | Fraction + "MaxFractionTracer" | Max Fraction Tracer + "Communication" | Communication """ - def __init__(self, pdm_object, project): - PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), project) - self.view_id = pdm_object.get_value("ViewId") + if injectors is None: + injectors = [] + if producers is None: + producers = [] + cell_result = self.cell_result() + cell_result.result_type = "FLOW_DIAGNOSTICS" + cell_result.result_variable = result_variable + cell_result.flow_tracer_selection_mode = selection_mode + if selection_mode == 'FLOW_TR_BY_SELECTION': + cell_result.selected_injector_tracers = injectors + cell_result.selected_producer_tracers = producers + cell_result.update() - def is_eclipse_view(self): - return self.class_keyword() == "ReservoirView" +@add_method(View) +def clone(self): + """Clone the current view""" + view_id = self._execute_command(cloneView=Cmd.CloneViewRequest( + viewId=self.id)).createViewResult.viewId + return self.case().view(view_id) - def is_geomech_view(self): - return self.class_keyword() == "GeoMechView" +@add_method(View) +def set_time_step(self, time_step): + """Set the time step for current view""" + case_id = self.case().id + return self._execute_command(setTimeStep=Cmd.SetTimeStepParams( + caseId=case_id, viewId=self.id, timeStep=time_step)) - def show_grid_box(self): - """Check if the grid box is meant to be shown in the view""" - return self.get_value("ShowGridBox") +@add_method(View) +def export_sim_well_fracture_completions(self, time_step, + simulation_well_names, file_split, + compdat_export): + """Export fracture completions for simulation wells - def set_show_grid_box(self, value): - """Set if the grid box is meant to be shown in the view""" - self.set_value("ShowGridBox", value) + Parameter | Description | Type + ----------------------------| ------------------------------------------------ | ----- + time_step | Time step to export for | Integer + simulation_well_names | List of simulation well names | List + file_split | Controls how export data is split into files | String enum + compdat_export | Compdat export type | String enum - def background_color(self): - """Get the current background color in the view""" - return self.get_value("ViewBackgroundColor") + ##### Enum file_split - def set_background_color(self, bgcolor): - """Set the background color in the view""" - self.set_value("ViewBackgroundColor", bgcolor) + Option | Description + ----------------------------------- | ------------ + "UNIFIED_FILE" Default Option| A single file with all transmissibilities + "SPLIT_ON_WELL" | One file for each well transmissibilities + "SPLIT_ON_WELL_AND_COMPLETION_TYPE" | One file for each completion type for each well - def set_cell_result(self): - """Retrieve the current cell results""" - return self.children("GridCellResult")[0] + ##### Enum compdat_export - def apply_cell_result(self, result_type, result_variable): - """Apply a regular cell result + Option | Description + -----------------------------------------| ------------ + "TRANSMISSIBILITIES"Default Option| Direct export of transmissibilities + "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS" | Include export of WPIMULT - Arguments: - result_type (str): String representing the result category. The valid values are - - DYNAMIC_NATIVE - - STATIC_NATIVE - - SOURSIMRL - - GENERATED - - INPUT_PROPERTY - - FORMATION_NAMES - - FLOW_DIAGNOSTICS - - INJECTION_FLOODING - result_variable (str): String representing the result variable. - """ - cell_result = self.set_cell_result() - cell_result.set_value("ResultType", result_type) - cell_result.set_value("ResultVariable", result_variable) - cell_result.update() + """ + if isinstance(simulation_well_names, str): + simulation_well_names = [simulation_well_names] - def apply_flow_diagnostics_cell_result( - self, - result_variable='TOF', - selection_mode='FLOW_TR_BY_SELECTION', - injectors=None, - producers=None): - """Apply a flow diagnostics cell result + case_id = self.case().id + return self._execute_command( + exportSimWellFractureCompletions=Cmd.ExportSimWellPathFracRequest( + caseId=case_id, + viewId=self.id, + timeStep=time_step, + simulationWellNames=simulation_well_names, + fileSplit=file_split, + compdatExport=compdat_export)) - Parameter | Description | Type - ------------------- | ------------------------------------------------------ | ----- - result_variable | String representing the result value | String - selection_mode | String specifying which tracers to select | String - injectors | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List - producers | List of injector names, used by 'FLOW_TR_BY_SELECTION' | String List +@add_method(View) +def export_visible_cells(self, + export_keyword='FLUXNUM', + visible_active_cells_value=1, + hidden_active_cells_value=0, + inactive_cells_value=0): + """Export special properties for all visible cells. - ##### Enum compdat_export + Arguments: + export_keyword (string): The keyword to export. + Choices: 'FLUXNUM' or 'MULTNUM'. Default: 'FLUXNUM' + visible_active_cells_value (int): Value to export forvisible active cells. Default: 1 + hidden_active_cells_value (int): Value to export for hidden active cells. Default: 0 + inactive_cells_value (int): Value to export for inactive cells. Default: 0 + """ + case_id = self.case().id + return self._execute_command( + exportVisibleCells=Cmd.ExportVisibleCellsRequest( + caseId=case_id, + viewId=self.id, + exportKeyword=export_keyword, + visibleActiveCellsValue=visible_active_cells_value, + hiddenActiveCellsValue=hidden_active_cells_value, + inactiveCellsValue=inactive_cells_value)) - Option | Description - ------------------------| ------------ - "TOF" | Time of flight - "Fraction" | Fraction - "MaxFractionTracer" | Max Fraction Tracer - "Communication" | Communication +@add_method(View) +def export_property(self, undefined_value=0.0): + """ Export the current Eclipse property from the view - """ - if injectors is None: - injectors = [] - if producers is None: - producers = [] - cell_result = self.set_cell_result() - cell_result.set_value("ResultType", "FLOW_DIAGNOSTICS") - cell_result.set_value("ResultVariable", result_variable) - cell_result.set_value("FlowTracerSelectionMode", selection_mode) - if selection_mode == 'FLOW_TR_BY_SELECTION': - cell_result.set_value("SelectedInjectorTracers", injectors) - cell_result.set_value("SelectedProducerTracers", producers) - cell_result.update() + Arguments: + undefined_value (double): Value to use for undefined values. Defaults to 0.0 + """ + case_id = self.case().id + return self._execute_command( + exportPropertyInViews=Cmd.ExportPropertyInViewsRequest( + caseId=case_id, + viewIds=[self.id], + undefinedValue=undefined_value)) - def case(self): - """Get the case the view belongs to""" - pdm_case = self.ancestor("EclipseCase") - if pdm_case is None: - pdm_case = self.ancestor("ResInsightGeoMechCase") - if pdm_case is None: - return None - return rips.case.Case(self._channel, pdm_case.get_value("CaseId"), self._project) +@add_method(ViewWindow) +def case(self): + """Get the case the view belongs to""" + mycase = self.ancestor(rips.case.Case) + assert(mycase is not None) + return mycase - def clone(self): - """Clone the current view""" - view_id = self._execute_command(cloneView=Cmd.CloneViewRequest( - viewId=self.view_id)).createViewResult.viewId - return self.case().view(view_id) - - def set_time_step(self, time_step): - """Set the time step for current view""" - case_id = self.case().case_id - return self._execute_command(setTimeStep=Cmd.SetTimeStepParams( - caseId=case_id, viewId=self.view_id, timeStep=time_step)) - - def export_sim_well_fracture_completions(self, time_step, - simulation_well_names, file_split, - compdat_export): - """Export fracture completions for simulation wells - - Parameter | Description | Type - ----------------------------| ------------------------------------------------ | ----- - time_step | Time step to export for | Integer - simulation_well_names | List of simulation well names | List - file_split | Controls how export data is split into files | String enum - compdat_export | Compdat export type | String enum - - ##### Enum file_split - - Option | Description - ----------------------------------- | ------------ - "UNIFIED_FILE" Default Option| 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"Default Option| Direct export of transmissibilities - "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS" | Include export of WPIMULT - - """ - if isinstance(simulation_well_names, str): - simulation_well_names = [simulation_well_names] - - case_id = self.case().case_id - return self._execute_command( - exportSimWellFractureCompletions=Cmd.ExportSimWellPathFracRequest( - caseId=case_id, - viewId=self.view_id, - timeStep=time_step, - simulationWellNames=simulation_well_names, - fileSplit=file_split, - compdatExport=compdat_export)) - - def export_visible_cells(self, - export_keyword='FLUXNUM', - visible_active_cells_value=1, - hidden_active_cells_value=0, - inactive_cells_value=0): - """Export special properties for all visible cells. - - Arguments: - export_keyword (string): The keyword to export. - Choices: 'FLUXNUM' or 'MULTNUM'. Default: 'FLUXNUM' - visible_active_cells_value (int): Value to export forvisible active cells. Default: 1 - hidden_active_cells_value (int): Value to export for hidden active cells. Default: 0 - inactive_cells_value (int): Value to export for inactive cells. Default: 0 - """ - case_id = self.case().case_id - return self._execute_command( - exportVisibleCells=Cmd.ExportVisibleCellsRequest( - caseId=case_id, - viewId=self.view_id, - exportKeyword=export_keyword, - visibleActiveCellsValue=visible_active_cells_value, - hiddenActiveCellsValue=hidden_active_cells_value, - inactiveCellsValue=inactive_cells_value)) - - def export_property(self, undefined_value=0.0): - """ Export the current Eclipse property from the view - - Arguments: - undefined_value (double): Value to use for undefined values. Defaults to 0.0 - """ - case_id = self.case().case_id - return self._execute_command( - exportPropertyInViews=Cmd.ExportPropertyInViewsRequest( - caseId=case_id, - viewIds=[self.view_id], - undefinedValue=undefined_value)) - - def export_snapshot(self, prefix='', export_folder=''): - """ Export snapshot for the current view +@add_method(ViewWindow) +def export_snapshot(self, prefix='', export_folder=''): + """ Export snapshot for the current view - Arguments: - prefix (str): Exported file name prefix - export_folder(str): The path to export to. By default will use the global export folder - """ - case_id = self.case().case_id - return self._execute_command( - exportSnapshots=Cmd.ExportSnapshotsRequest(type='VIEWS', - prefix=prefix, - caseId=case_id, - viewId=self.view_id, - exportFolder=export_folder)) + Arguments: + prefix (str): Exported file name prefix + export_folder(str): The path to export to. By default will use the global export folder + """ + case_id = self.case().id + return self._execute_command( + exportSnapshots=Cmd.ExportSnapshotsRequest(type='VIEWS', + prefix=prefix, + caseId=case_id, + viewId=self.id, + exportFolder=export_folder)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/well.py b/ApplicationCode/GrpcInterface/Python/rips/well.py deleted file mode 100644 index a10fb84280..0000000000 --- a/ApplicationCode/GrpcInterface/Python/rips/well.py +++ /dev/null @@ -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 diff --git a/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py b/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py index 13a39b1360..62651dffbc 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py +++ b/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py @@ -2,124 +2,44 @@ ResInsight Well Bore Stability Plot module """ -from rips.pdmobject import PdmObject +from rips.pdmobject import PdmObject, add_method from rips.well_log_plot import WellLogPlot +from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters -class WbsParameters: - """Well Bore Stability parameters - - Note that any parameter sources left at "UNDEFINED" will get ResInsight defaults - which depends on the available data. +@add_method(WbsParameters) +def __custom_init__(self, pb2_object=None, channel=None): + self.pore_pressure_reservoir_source = "UNDEFINED" + self.pore_pressure_non_reservoir_source = "UNDEFINED" + + self.poisson_ratio_source = "UNDEFINED" + self.ucs_source = "UNDEFINED" + self.obg0_source = "UNDEFINED" + self.df_source = "UNDEFINED" + self.k0sh_source = "UNDEFINED" + self.fg_shale_source = "UNDEFINED" + self.k0fg_source = "UNDEFINED" - Attributes: - pore_pressure_in_reservoir_source(enum string): can be "GRID", "LAS_FILE" and "ELEMENT_PROPERTY_TABLE". - pore_pressure_outside_reservoir_source(enum string): can be "HYDROSTATIC" and "USER_DEFINED". - poisson_ratio_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED". - ucs_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED". - obg0_source(enum string): can be "GRID" or "LAS_FILE". - df_source(enum string): can be "LAS_FILE", "ELEMENT_PROPERTY_TABLE" or "USER_DEFINED". - fg_shale_source(enum string): can be "DERIVED_FROM_K0FG" or "PROPORTIONAL_TO_SH". - k0fg_source(enum string): can be "LAS_FILE" or "USER_DEFINED"". Only relevant if fg_shale_source is "DERIVED_FROM_K0FG". + self.user_pp_non_reservoir = 1.05 + self.user_poission_ratio = 0.35 + self.user_ucs = 100 + self.user_df = 0.7 + self.user_k0sh = 0.65 + self.fg_multiplier = 1.05 + self.user_k0fg = 0.75 - user_pp_outside_reservoir(double): Used if pore_pressure_outside_reservoir_source is "USED_DEFINED". Default 1.05. - user_poission_ratio(double): Used if poisson_ratio_source is "USER_DEFINED", default 0.35. - user_ucs(double): Used if ucs_soruce is "USER_DEFINED", default 100. - user_df(double): Used if df is "USER_DEFINED", default 0.7. - user_k0sh(double): Used if k0sh_source is "USER_DEFINED", default 0.65. - fg_shale_sh_multiplier(double): Used if fg_shale_source is "PROPORTIONAL_TO_SH", default 1.05. - user_k0fg(double): Used if fg_shale_source is "DERIVED_FROM_K0FG" and k0fg_source is "USER_DEFINED", default 0.75. - - """ +@add_method(WellBoreStabilityPlot) +def parameters(self): + """Retrieve the parameters of the Plot + """ + children = self.children("WbsParameters", WbsParameters) + if len(children) == 1: + child = children[0] + return child + return None - def __init__(self): - self.pore_pressure_in_reservoir_source = "UNDEFINED" - self.pore_pressure_outside_reservoir_source = "UNDEFINED" - - self.poisson_ratio_source = "UNDEFINED" - self.ucs_source = "UNDEFINED" - self.obg0_source = "UNDEFINED" - self.df_source = "UNDEFINED" - self.k0sh_source = "UNDEFINED" - self.fg_shale_source = "UNDEFINED" - self.k0fg_source = "UNDEFINED" - - self.user_pp_outside_reservoir = 1.05 - self.user_poission_ratio = 0.35 - self.user_ucs = 100 - self.user_df = 0.7 - self.user_k0sh = 0.65 - self.fg_shale_multiplier = 1.05 - self.user_k0fg = 0.75 - - @classmethod - def from_pdm_object(cls, pdm_object): - params = cls() - params.pore_pressure_in_reservoir_source = pdm_object.get_value("PorePressureReservoirSource") - params.pore_pressure_outside_reservoir_source = pdm_object.get_value("PorePressureNonReservoirSource") - - params.poisson_ratio_source = pdm_object.get_value("PoissonRatioSource") - params.ucs_source = pdm_object.get_value("UcsSource") - params.obg0_source = pdm_object.get_value("OBG0Source") - params.df_source = pdm_object.get_value("DFSource") - params.k0sh_source = pdm_object.get_value("K0SHSource") - params.fg_shale_source = pdm_object.get_value("FGShaleSource") - params.k0fg_source = pdm_object.get_value("K0FGSource") - - params.user_pp_outside_reservoir = pdm_object.get_value("UserPPNonReservoir") - params.user_poisson_ratio = pdm_object.get_value("UserPoissonRatio") - params.user_ucs = pdm_object.get_value("UserUcs") - params.user_df = pdm_object.get_value("UserDF") - params.user_k0fg = pdm_object.get_value("UserK0FG") - params.user_k0sh = pdm_object.get_value("UserK0SH") - params.user_fg_shale = pdm_object.get_value("FGMultiplier") - return params - - def to_pdm_object(self, pdm_object): - pdm_object.set_value("PorePressureReservoirSource", self.pore_pressure_in_reservoir_source) - pdm_object.set_value("PorePressureNonReservoirSource", self.pore_pressure_outside_reservoir_source) - - pdm_object.set_value("UserPPNonReservoir", self.user_pp_outside_reservoir) - pdm_object.set_value("PoissonRatioSource", self.poisson_ratio_source) - pdm_object.set_value("UcsSource", self.ucs_source) - pdm_object.set_value("OBG0Source", self.obg0_source) - pdm_object.set_value("DFSource", self.df_source) - pdm_object.set_value("K0SHSource", self.k0sh_source) - pdm_object.set_value("FGShaleSource", self.fg_shale_source) - pdm_object.set_value("K0FGSource", self.k0fg_source) - - pdm_object.set_value("UserPoissonRatio", self.user_poisson_ratio) - pdm_object.set_value("UserUcs", self.user_ucs) - pdm_object.set_value("UserDF", self.user_df) - pdm_object.set_value("UserK0FG", self.user_k0fg) - pdm_object.set_value("UserK0SH", self.user_k0sh) - pdm_object.set_value("FGMultiplier", self.user_fg_shale) - -class WellBoreStabilityPlot(WellLogPlot): - """ResInsight Well Bore Stability Plot - """ - - def __init__(self, pdm_object): - WellLogPlot.__init__(self, pdm_object) - - @classmethod - def from_pdm_object(cls, pdm_object): - if isinstance(pdm_object, PdmObject): - if pdm_object.class_keyword() == "WellBoreStabilityPlot": - return cls(pdm_object) - return None - - def parameters(self): - """Retrieve the parameters of the Plot - """ - children = self.children("WbsParameters") - if len(children) == 1: - child = children[0] - return WbsParameters.from_pdm_object(child) - return None - - def set_parameters(self, wbs_parameters): - children = self.children("WbsParameters") - if len(children) == 1: - pdm_params = children[0] - wbs_parameters.to_pdm_object(pdm_params) - pdm_params.update() +@add_method(WellBoreStabilityPlot) +def set_parameters(self, wbs_parameters): + children = self.children("WbsParameters", WbsParameters) + if len(children) == 1: + pdm_params = children[0] + pdm_params.copy_from(wbs_parameters) diff --git a/ApplicationCode/GrpcInterface/Python/rips/well_log_plot.py b/ApplicationCode/GrpcInterface/Python/rips/well_log_plot.py index 03d1564ffd..c3d565ca76 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/well_log_plot.py +++ b/ApplicationCode/GrpcInterface/Python/rips/well_log_plot.py @@ -6,115 +6,50 @@ import rips.generated.Commands_pb2 as Cmd from rips.plot import Plot from rips.pdmobject import PdmObject +from rips.generated.pdm_objects import WellLogPlot +from rips.pdmobject import add_method -class WellLogPlot(Plot): - """ResInsight well log plot class +@add_method(WellLogPlot) +def export_data_as_las(self, export_folder, file_prefix='', export_tvdrkb=False, capitalize_file_names=False, resample_interval=0.0, convert_to_standard_units=False): + """ Export LAS file(s) for the current plot + + Arguments: + export_folder(str): The path to export to. By default will use the global export folder + file_prefix (str): Exported file name prefix + export_tvdrkb(bool): Export in TVD-RKB format + capitalize_file_names(bool): Make all file names upper case + resample_interval(double): if > 0.0 the files will be resampled + + Returns: + A list of files exported + """ + res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='LAS', + viewId=self.id, + exportFolder=export_folder, + filePrefix=file_prefix, + exportTvdRkb=export_tvdrkb, + capitalizeFileNames=capitalize_file_names, + resampleInterval=resample_interval, + convertCurveUnits=convert_to_standard_units)) + return res.exportWellLogPlotDataResult.exportedFiles + +@add_method(WellLogPlot) +def export_data_as_ascii(self, export_folder, file_prefix='', capitalize_file_names=False): + """ Export LAS file(s) for the current plot + + Arguments: + export_folder(str): The path to export to. By default will use the global export folder + file_prefix (str): Exported file name prefix + capitalize_file_names(bool): Make all file names upper case + + Returns: + A list of files exported """ - - def __init__(self, pdm_object): - Plot.__init__(self, pdm_object) - - @classmethod - def from_pdm_object(cls, pdm_object): - if isinstance(pdm_object, PdmObject): - if pdm_object.class_keyword() == "WellLogPlot": - return cls(pdm_object) - return None - - def export_data_as_las(self, export_folder, file_prefix='', export_tvdrkb=False, capitalize_file_names=False, resample_interval=0.0, convert_to_standard_units=False): - """ Export LAS file(s) for the current plot - - Arguments: - export_folder(str): The path to export to. By default will use the global export folder - file_prefix (str): Exported file name prefix - export_tvdrkb(bool): Export in TVD-RKB format - capitalize_file_names(bool): Make all file names upper case - resample_interval(double): if > 0.0 the files will be resampled - - Returns: - A list of files exported - """ - res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='LAS', - viewId=self.view_id, - exportFolder=export_folder, - filePrefix=file_prefix, - exportTvdRkb=export_tvdrkb, - capitalizeFileNames=capitalize_file_names, - resampleInterval=resample_interval, - convertCurveUnits=convert_to_standard_units)) - return res.exportWellLogPlotDataResult.exportedFiles - - def export_data_as_ascii(self, export_folder, file_prefix='', capitalize_file_names=False): - """ Export LAS file(s) for the current plot - - Arguments: - export_folder(str): The path to export to. By default will use the global export folder - file_prefix (str): Exported file name prefix - capitalize_file_names(bool): Make all file names upper case - - Returns: - A list of files exported - """ - res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='ASCII', - viewId=self.view_id, - exportFolder=export_folder, - filePrefix=file_prefix, - exportTvdRkb=False, - capitalizeFileNames=capitalize_file_names, - resampleInterval=0.0)) - return res.exportWellLogPlotDataResult.exportedFiles - - def depth_range(self): - """Get the depth range of the Plot - """ - return self.get_value("MinimumDepth"), self.get_value("MaximumDepth") - - def set_depth_range(self, min_depth, max_depth, update=True): - """ Set the visible depth range minimum - - Arguments: - min_depth(double): The new minimum depth - max_depth(double): The new maximum depth - update(bool, optional): Update the plot after setting the value? - """ - - self.set_value("MinimumDepth", min_depth) - self.set_value("MaximumDepth", max_depth) - self.set_value("AutoScaleDepthEnabled", False) - if update: - self.update() - - def depth_type(self): - """Get the plot depth type - - Returns: an enum string. Can be "MEASURED_DEPTH", "TRUE_VERTICAL_DEPTH" or "TRUE_VERTICAL_DEPTH_RKB". - """ - return self.get_value("DepthType") - - def set_depth_type(self, depth_type, update=True): - """Set the depth type - - Arguments: - depth_type(enum string): can be "MEASURED_DEPTH", "TRUE_VERTICAL_DEPTH" or "TRUE_VERTICAL_DEPTH_RKB". - update(bool, optional): Update the plot after setting the value? - """ - self.set_value("DepthType", depth_type) - if update: - self.update() - - def depth_unit(self): - """Get the plot depth units - - Returns: an enum string. Can be "UNIT_METER", "UNIT_FEET" or "UNIT_NONE". - """ - - def set_depth_unit(self, depth_unit, update=True): - """Set the depth unit - - Arguments: - depth_unit(enum string): can be "UNIT_METER", "UNIT_FEET" or "UNIT_NONE". - update(bool, optional): Update the plot after setting the value? - """ - self.set_value("DepthUnit", depth_unit) - if update: - self.update() + res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='ASCII', + viewId=self.id, + exportFolder=export_folder, + filePrefix=file_prefix, + exportTvdRkb=False, + capitalizeFileNames=capitalize_file_names, + resampleInterval=0.0)) + return res.exportWellLogPlotDataResult.exportedFiles diff --git a/ApplicationCode/GrpcInterface/Python/rips/wellpath.py b/ApplicationCode/GrpcInterface/Python/rips/wellpath.py new file mode 100644 index 0000000000..2c2c9c97ed --- /dev/null +++ b/ApplicationCode/GrpcInterface/Python/rips/wellpath.py @@ -0,0 +1,6 @@ +""" +ResInsight Well +""" +import rips.generated.Commands_pb2 as Cmd +from rips.generated.pdm_objects import WellPathBase + diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 38aac75bc2..e0db696577 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -74,7 +74,7 @@ void caf::AppEnum::setUp() } // End namespace caf -CAF_PDM_XML_ABSTRACT_SOURCE_INIT( Rim3dView, "GenericView" ); // Do not use. Abstract class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( Rim3dView, "View", "GenericView" ); // Do not use. Abstract class //-------------------------------------------------------------------------------------------------- /// @@ -86,7 +86,10 @@ Rim3dView::Rim3dView( void ) RiaPreferences* preferences = app->preferences(); CVF_ASSERT( preferences ); - RICF_InitField( &m_id, "ViewId", -1, "View ID", "", "", "" ); + CAF_PDM_InitObject( "3d View", "", "", "" ); + + RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" ); + m_id.xmlCapability()->registerKeywordAlias( "ViewId" ); m_id.uiCapability()->setUiReadOnly( true ); m_id.uiCapability()->setUiHidden( true ); m_id.capability()->setIOWriteable( false ); @@ -104,20 +107,21 @@ Rim3dView::Rim3dView( void ) CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "" ); m_cameraPointOfInterest.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" ); + RICF_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" ); double defaultScaleFactor = preferences->defaultScaleFactorZ(); - CAF_PDM_InitField( &scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "" ); + RICF_InitField( &scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "" ); cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); - RICF_InitField( &m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", "" ); + RICF_InitField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background", "", "", "" ); + m_backgroundColor.xmlCapability()->registerKeywordAlias( "ViewBackgroundColor" ); CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", "" ); maximumFrameRate.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", "" ); hasUserRequestedAnimation.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "" ); + RICF_InitField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "" ); m_currentTimeStep.uiCapability()->setUiHidden( true ); caf::AppEnum defaultMeshType = preferences->defaultMeshModeType(); @@ -126,15 +130,15 @@ Rim3dView::Rim3dView( void ) RICF_InitField( &m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "" ); - CAF_PDM_InitField( &m_disableLighting, - "DisableLighting", - false, - "Disable Results Lighting", - "", - "Disable light model for scalar result colors", - "" ); + RICF_InitField( &m_disableLighting, + "DisableLighting", + false, + "Disable Results Lighting", + "", + "Disable light model for scalar result colors", + "" ); - CAF_PDM_InitField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "" ); + RICF_InitField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_comparisonView, "ComparisonView", "Comparison View", "", "", "" ); @@ -880,8 +884,11 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const } else if ( changedField == &m_showZScaleLabel ) { - m_viewer->showZScaleLabel( m_showZScaleLabel() ); - m_viewer->update(); + if ( m_viewer ) + { + m_viewer->showZScaleLabel( m_showZScaleLabel() ); + m_viewer->update(); + } } else if ( changedField == &m_comparisonView ) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 3ffff2e73c..770dddc12e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -110,7 +110,7 @@ #include -CAF_PDM_SOURCE_INIT( RimEclipseView, "ReservoirView" ); +CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT( RimEclipseView, "ReservoirView" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ RimEclipseView::RimEclipseView() RiaPreferences* preferences = app->preferences(); CVF_ASSERT( preferences ); - CAF_PDM_InitObject( "Reservoir View", ":/3DView16x16.png", "", "" ); + CAF_PDM_InitObject( "Reservoir View", ":/3DView16x16.png", "", "The Eclipse 3d Reservoir View" ); CAF_PDM_InitFieldNoDefault( &m_cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", "" ); m_cellResult = new RimEclipseCellColors(); diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp index f1e565f5bb..d61c2e2c0a 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp @@ -5,7 +5,7 @@ #include "RimTools.h" #include "cafUtils.h" -CAF_PDM_SOURCE_INIT( RimFileWellPath, "WellPath" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimFileWellPath, "WellPath" ); //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 1c593ed17f..15e663351f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -77,7 +77,7 @@ #include -CAF_PDM_SOURCE_INIT( RimGeoMechView, "GeoMechView" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimGeoMechView, "GeoMechView" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -87,7 +87,7 @@ RimGeoMechView::RimGeoMechView( void ) RiaPreferences* preferences = app->preferences(); CVF_ASSERT( preferences ); - CAF_PDM_InitObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "" ); + CAF_PDM_InitObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" ); CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "" ); cellResult = new RimGeoMechCellColors(); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index eb5559e8b2..88bf0b9e10 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -48,7 +48,7 @@ #include #include -CAF_PDM_SOURCE_INIT( RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimIdenticalGridCaseGroup, "GridCaseGroup", "RimIdenticalGridCaseGroup" ); //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp b/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp index b07351472f..61d177eea1 100644 --- a/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimModeledWellPath.cpp @@ -32,7 +32,7 @@ #include "RimWellPathFractureCollection.h" #include "cafPdmUiTreeOrdering.h" -CAF_PDM_SOURCE_INIT( RimModeledWellPath, "ModeledWellPath" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimModeledWellPath, "ModeledWellPath" ); //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimPlot.cpp b/ApplicationCode/ProjectDataModel/RimPlot.cpp index 2c7dac760e..cf57a4665a 100644 --- a/ApplicationCode/ProjectDataModel/RimPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlot.cpp @@ -25,7 +25,7 @@ void RimPlot::RowOrColSpanEnum::setUp() } } // namespace caf -CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "Plot", "RimPlot" ); // Do not use. Abstract class //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp b/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp index c41e4ecc14..113ad8f9cd 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp @@ -30,7 +30,7 @@ #include -CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "RimPlotWindow" ); // Do not use. Abstract class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "PlotWindow", "RimPlotWindow" ); // Do not use. Abstract class //-------------------------------------------------------------------------------------------------- /// @@ -39,7 +39,8 @@ RimPlotWindow::RimPlotWindow() { CAF_PDM_InitObject( "PlotWindow", "", "", "" ); - RICF_InitField( &m_id, "ViewId", -1, "View ID", "", "", "" ); + RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" ); + m_id.xmlCapability()->registerKeywordAlias( "ViewId" ); m_id.uiCapability()->setUiReadOnly( true ); m_id.uiCapability()->setUiHidden( true ); m_id.capability()->setIOWriteable( false ); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index f2b36cec1b..59d54115a0 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -101,7 +101,7 @@ #include #include -CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimProject, "Project", "ResInsightProject" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index b27f326475..2279e401bb 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -55,16 +55,17 @@ //-------------------------------------------------------------------------------------------------- Rim2dIntersectionView* corresponding2dIntersectionView( RimSimWellInView* simWellInView ); -CAF_PDM_SOURCE_INIT( RimSimWellInView, "Well" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimSimWellInView, "SimulationWell", "Well" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSimWellInView::RimSimWellInView() { - CAF_PDM_InitObject( "Well", ":/Well.png", "", "" ); + CAF_PDM_InitObject( "Simulation Well", ":/Well.png", "", "" ); - RICF_InitFieldNoDefault( &name, "WellName", "Name", "", "", "" ); + RICF_InitFieldNoDefault( &name, "Name", "Name", "", "", "" ); + name.xmlCapability()->registerKeywordAlias( "WellName" ); CAF_PDM_InitField( &showWell, "ShowWell", true, "Show well ", "", "", "" ); diff --git a/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp b/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp index 05d83ce450..2e4ce5296f 100644 --- a/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp +++ b/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp @@ -26,7 +26,7 @@ #include "RimWellLogFile.h" #include "RimWellPath.h" -CAF_PDM_SOURCE_INIT( RimWbsParameters, "WbsParameters" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWbsParameters, "WbsParameters" ); //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp index 52bea75bd9..dcb3f0f535 100644 --- a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp @@ -33,7 +33,7 @@ #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiGroup.h" -CAF_PDM_SOURCE_INIT( RimWellBoreStabilityPlot, "WellBoreStabilityPlot" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellBoreStabilityPlot, "WellBoreStabilityPlot" ); //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 2a6000f32e..fa8175e82b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -64,14 +64,17 @@ void RimWellLogPlot::AxisGridEnum::setUp() } // End namespace caf -CAF_PDM_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimWellLogPlot::RimWellLogPlot() { - CAF_PDM_InitObject( "Well Log Plot", ":/WellLogPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Log Plot", + ":/WellLogPlot16x16.png", + "", + "A Well Log Plot With a shared Depth Axis and Multiple Tracks" ); CAF_PDM_InitFieldNoDefault( &m_commonDataSource, "CommonDataSource", diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index ad52e2c4c4..78b65c664d 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -61,7 +61,7 @@ #include -CAF_PDM_SOURCE_INIT( RimWellPath, "WellPathBase" ); +CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellPath, "WellPathBase" ); //-------------------------------------------------------------------------------------------------- /// @@ -75,7 +75,8 @@ RimWellPath::RimWellPath() { CAF_PDM_InitObject( "WellPath", ":/Well.png", "", "" ); - RICF_InitFieldNoDefault( &m_name, "WellPathName", "Name", "", "", "" ); + RICF_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); + m_name.xmlCapability()->registerKeywordAlias( "WellPathName" ); m_name.uiCapability()->setUiReadOnly( true ); m_name.uiCapability()->setUiHidden( true ); m_name.xmlCapability()->disableIO();