From c23e27eef0e15b80bc77ebeacd23cab03cc79522 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 4 Mar 2020 15:11:24 +0100 Subject: [PATCH] Simplify Python API --- .../GrpcInterface/Python/rips/__init__.py | 4 +-- .../GrpcInterface/Python/rips/case.py | 2 +- .../GrpcInterface/Python/rips/project.py | 11 +++---- .../GrpcInterface/Python/rips/view.py | 13 -------- .../Python/rips/well_bore_stability_plot.py | 33 ------------------- .../GrpcInterface/Python/rips/wellpath.py | 6 ---- .../ProjectDataModel/RimWellPath.cpp | 2 +- 7 files changed, 9 insertions(+), 62 deletions(-) delete mode 100644 ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py delete mode 100644 ApplicationCode/GrpcInterface/Python/rips/wellpath.py diff --git a/ApplicationCode/GrpcInterface/Python/rips/__init__.py b/ApplicationCode/GrpcInterface/Python/rips/__init__.py index 1dd1075892..a861e636e1 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/__init__.py +++ b/ApplicationCode/GrpcInterface/Python/rips/__init__.py @@ -13,6 +13,6 @@ from rips.project import Project from rips.plot import Plot, PlotWindow from rips.contour_map import EclipseContourMap, GeoMechContourMap 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 + +from rips.generated.pdm_objects import * diff --git a/ApplicationCode/GrpcInterface/Python/rips/case.py b/ApplicationCode/GrpcInterface/Python/rips/case.py index 3987d1e66b..669ebe0e98 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/case.py +++ b/ApplicationCode/GrpcInterface/Python/rips/case.py @@ -26,7 +26,7 @@ import rips.project from rips.grid import Grid from rips.pdmobject import add_method, PdmObject from rips.view import View -from rips.well_bore_stability_plot import WellBoreStabilityPlot, WbsParameters +from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters from rips.simulation_well import SimulationWell """ResInsight case class diff --git a/ApplicationCode/GrpcInterface/Python/rips/project.py b/ApplicationCode/GrpcInterface/Python/rips/project.py index 583a92d3cd..305d87f0ca 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/project.py +++ b/ApplicationCode/GrpcInterface/Python/rips/project.py @@ -11,14 +11,13 @@ from rips.gridcasegroup import GridCaseGroup from rips.pdmobject import PdmObject, add_method, add_static_method from rips.plot import Plot from rips.view import View -from rips.wellpath import WellPathBase 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 +from rips.generated.pdm_objects import Project, PlotWindow, WellPath @add_method(Project) @@ -277,7 +276,7 @@ def import_well_paths(self, well_path_files=None, well_path_folder=''): well_path_folder(str): A folder path containing files to import Returns: - A list of WellPathBase objects + A list of WellPath objects """ if well_path_files is None: well_path_files = [] @@ -294,16 +293,16 @@ def well_paths(self): """Get a list of all well paths in the project Returns: - A list of rips WellPathBase objects + A list of rips WellPath objects """ - return self.descendants(WellPathBase) + return self.descendants(WellPath) @add_method(Project) def well_path_by_name(self, well_path_name): """Get a specific well path by name from the project Returns: - A WellPathBase object + A WellPath object """ all_well_paths = self.well_paths() for well_path in all_well_paths: diff --git a/ApplicationCode/GrpcInterface/Python/rips/view.py b/ApplicationCode/GrpcInterface/Python/rips/view.py index 4e1669402c..fd5418e8c3 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/view.py +++ b/ApplicationCode/GrpcInterface/Python/rips/view.py @@ -9,19 +9,6 @@ import rips.case # Circular import of Case, which already imports View. Use ful from rips.pdmobject import add_method from rips.generated.pdm_objects import View, ViewWindow, EclipseView, GeoMechView -@add_method(View) -def is_eclipse_view(self): - return isinstance(self, EclipseView) - -@add_method(View) -def is_geomech_view(self): - return isinstance(self, GeoMechView) - -@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 diff --git a/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py b/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py deleted file mode 100644 index b8c3fb775e..0000000000 --- a/ApplicationCode/GrpcInterface/Python/rips/well_bore_stability_plot.py +++ /dev/null @@ -1,33 +0,0 @@ -""" -ResInsight Well Bore Stability Plot module -""" - -from rips.pdmobject import PdmObject, add_method -from rips.well_log_plot import WellLogPlot -from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters - -@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" - - 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 - -@add_method(WellBoreStabilityPlot) -def set_parameters(self, new_parameters): - current_params = self.parameters() - current_params.copy_from(new_parameters) diff --git a/ApplicationCode/GrpcInterface/Python/rips/wellpath.py b/ApplicationCode/GrpcInterface/Python/rips/wellpath.py deleted file mode 100644 index 2c2c9c97ed..0000000000 --- a/ApplicationCode/GrpcInterface/Python/rips/wellpath.py +++ /dev/null @@ -1,6 +0,0 @@ -""" -ResInsight Well -""" -import rips.generated.Commands_pb2 as Cmd -from rips.generated.pdm_objects import WellPathBase - diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 0ee41e2424..2e60eb1c8e 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -73,7 +73,7 @@ const char RimWellPath::SIM_WELL_NONE_UI_TEXT[] = "None"; //-------------------------------------------------------------------------------------------------- RimWellPath::RimWellPath() { - CAF_PDM_InitScriptableObject( "WellPath", ":/Well.png", "", "The Base class for Well Paths" ); + CAF_PDM_InitScriptableObjectWithNameAndComment( "WellPath", ":/Well.png", "", "", "WellPath", "The Base class for Well Paths" ); RICF_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); m_name.registerKeywordAlias( "WellPathName" );