Skip to content

Commit

Permalink
Major improvements to documentation
Browse files Browse the repository at this point in the history
* Proper inclusion of generated classes
* Better organisation
* Linking to examples
  • Loading branch information
lindkvis authored and magnesj committed Jan 24, 2021
1 parent 812fe6c commit 3792a1b
Show file tree
Hide file tree
Showing 26 changed files with 442 additions and 219 deletions.
38 changes: 38 additions & 0 deletions docs/rips/PythonExamples/launch_load_case_snapshot_exit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Access to environment variables
import os
# Load ResInsight Processing Server Client Library
import rips
# Connect to ResInsight instance
resinsight = rips.Instance.launch()

# This requires the TestModels to be installed with ResInsight (RESINSIGHT_BUNDLE_TESTMODELS):
resinsight_exe_path = os.environ.get('RESINSIGHT_EXECUTABLE')

# Get the TestModels path from the executable path
resinsight_install_path = os.path.dirname(resinsight_exe_path)
test_models_path = os.path.join(resinsight_install_path, 'TestModels')
path_name = os.path.join(test_models_path, 'TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID')

# Load an example case. Needs to be replaced with a valid path!
case = resinsight.project.load_case(path_name)

# Get a view
view1 = case.views()[0]

# Set the time step for view1 only
view1.set_time_step(time_step=2)

# Set cell result to SOIL
view1.apply_cell_result(result_type='DYNAMIC_NATIVE', result_variable='SOIL')

# Set export folder for snapshots and properties
resinsight.set_export_folder(export_type='SNAPSHOTS', path="e:/temp")
resinsight.set_export_folder(export_type='PROPERTIES', path="e:/temp")

# Export all snapshots
resinsight.project.export_snapshots()

# Export properties in the view
view1.export_property()

resinsight.exit()
27 changes: 27 additions & 0 deletions docs/rips/PythonExamples/load_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Access to environment variables and path tools
import os
# Load ResInsight Processing Server Client Library
import rips
# Connect to ResInsight instance
resinsight = rips.Instance.find()

# This requires the TestModels to be installed with ResInsight (RESINSIGHT_BUNDLE_TESTMODELS):
resinsight_exe_path = os.environ.get('RESINSIGHT_EXECUTABLE')

# Get the TestModels path from the executable path
resinsight_install_path = os.path.dirname(resinsight_exe_path)
test_models_path = os.path.join(resinsight_install_path, 'TestModels')
path_name = os.path.join(test_models_path, 'TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID')
case = resinsight.project.load_case(path_name)

# Print out lots of information from the case object
print("Case id: " + str(case.id))
print("Case name: " + case.name)
print("Case type: " + case.__class__.__name__)
print("Case file name: " + case.file_path)
print("Case reservoir bounding box:", case.reservoir_boundingbox())

timesteps = case.time_steps()
for t in timesteps:
print("Year: " + str(t.year))
print("Month: " + str(t.month))
17 changes: 17 additions & 0 deletions docs/rips/PythonExamples/open_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Access to environment variables and path tools
import os
# Load ResInsight Processing Server Client Library
import rips
# Connect to ResInsight instance
resinsight = rips.Instance.find()

# This requires the TestModels to be installed with ResInsight (RESINSIGHT_BUNDLE_TESTMODELS):
resinsight_exe_path = os.environ.get('RESINSIGHT_EXECUTABLE')

# Get the TestModels path from the executable path
resinsight_install_path = os.path.dirname(resinsight_exe_path)
test_models_path = os.path.join(resinsight_install_path, 'TestModels')
path_name = os.path.join(test_models_path, 'TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp')

# Open a project
resinsight.project.open(path_name)
13 changes: 11 additions & 2 deletions docs/rips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))

from resinsight_classes import *
from .resinsight_classes import *

from .case import Case, EclipseCase, GeoMechCase
from .grid import Grid
from .instance import Instance
from .pdmobject import PdmObjectBase
from .view import View
from .project import Project
from .plot import Plot, PlotWindow
from .contour_map import EclipseContourMap, GeoMechContourMap
from .well_log_plot import WellLogPlot
from .simulation_well import SimulationWell

__all__ = []
for key in class_dict():
__all__.append(key)

# Add classes not in resinsight_classes
__all__.append("Grid")
__all__.append("Instance")

__all__.sort()
46 changes: 23 additions & 23 deletions docs/rips/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@
import builtins
import grpc

import Case_pb2
import Case_pb2_grpc
import Commands_pb2 as Cmd
import PdmObject_pb2 as PdmObject_pb2
import rips.generated.Case_pb2
import rips.generated.Case_pb2_grpc
import rips.generated.Commands_pb2 as Cmd
import rips.generated.PdmObject_pb2 as PdmObject_pb2

import Properties_pb2
import Properties_pb2_grpc
import NNCProperties_pb2
import NNCProperties_pb2_grpc
from resinsight_classes import Case, EclipseCase, GeoMechCase, WellBoreStabilityPlot, WbsParameters
import rips.generated.Properties_pb2
import rips.generated.Properties_pb2_grpc
import rips.generated.NNCProperties_pb2
import rips.generated.NNCProperties_pb2_grpc
from .resinsight_classes import Case, EclipseCase, GeoMechCase, WellBoreStabilityPlot, WbsParameters

from .grid import Grid
from .pdmobject import add_method
Expand Down Expand Up @@ -321,7 +321,7 @@ def view(self, view_id):
view_id(int): view id
Returns:
:class:`rips.generated.resinsight_classes.View`
:class:`rips.generated.generated_classes.View`
"""
views = self.views()
for view_object in views:
Expand All @@ -335,7 +335,7 @@ def create_view(self):
"""Create a new view in the current case
Returns:
:class:`rips.generated.resinsight_classes.View`
:class:`rips.generated.generated_classes.View`
"""
return self.view(
self._execute_command(createView=Cmd.CreateViewRequest(
Expand Down Expand Up @@ -586,7 +586,7 @@ def available_properties(self,
porosity_model="MATRIX_MODEL"):
"""Get a list of available properties
For argument details, see :ref:`result-definition-label`
For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type (str): string corresponding to property_type enum.
Expand All @@ -610,7 +610,7 @@ def active_cell_property_async(self,
property_name,
time_step,
porosity_model="MATRIX_MODEL"):
"""Get a cell property for all active cells. Async, so returns an iterator. For argument details, see :ref:`result-definition-label`
"""Get a cell property for all active cells. Async, so returns an iterator. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type(str): string enum
Expand Down Expand Up @@ -641,7 +641,7 @@ def active_cell_property(self,
property_name,
time_step,
porosity_model="MATRIX_MODEL"):
"""Get a cell property for all active cells. Sync, so returns a list. For argument details, see :ref:`result-definition-label`
"""Get a cell property for all active cells. Sync, so returns a list. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type(str): string enum
Expand Down Expand Up @@ -669,7 +669,7 @@ def selected_cell_property_async(self,
property_name,
time_step,
porosity_model="MATRIX_MODEL"):
"""Get a cell property for all selected cells. Async, so returns an iterator. For argument details, see :ref:`result-definition-label`
"""Get a cell property for all selected cells. Async, so returns an iterator. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type(str): string enum
Expand Down Expand Up @@ -700,7 +700,7 @@ def selected_cell_property(self,
property_name,
time_step,
porosity_model="MATRIX_MODEL"):
"""Get a cell property for all selected cells. Sync, so returns a list. For argument details, see :ref:`result-definition-label`
"""Get a cell property for all selected cells. Sync, so returns a list. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type(str): string enum
Expand Down Expand Up @@ -730,7 +730,7 @@ def grid_property_async(
time_step,
grid_index=0,
porosity_model="MATRIX_MODEL"):
"""Get a cell property for all grid cells. Async, so returns an iterator. For argument details, see :ref:`result-definition-label`
"""Get a cell property for all grid cells. Async, so returns an iterator. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type(str): string enum
Expand Down Expand Up @@ -765,7 +765,7 @@ def grid_property(
time_step,
grid_index=0,
porosity_model="MATRIX_MODEL"):
"""Get a cell property for all grid cells. Synchronous, so returns a list. For argument details, see :ref:`result-definition-label`
"""Get a cell property for all grid cells. Synchronous, so returns a list. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
property_type(str): string enum
Expand Down Expand Up @@ -795,7 +795,7 @@ def set_active_cell_property_async(
property_name,
time_step,
porosity_model="MATRIX_MODEL"):
"""Set cell property for all active cells Async. Takes an iterator to the input values. For argument details, see :ref:`result-definition-label`
"""Set cell property for all active cells Async. Takes an iterator to the input values. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
values_iterator(iterator): an iterator to the properties to be set
Expand Down Expand Up @@ -827,7 +827,7 @@ def set_active_cell_property(
property_name,
time_step,
porosity_model="MATRIX_MODEL"):
"""Set a cell property for all active cells. For argument details, see :ref:`result-definition-label`
"""Set a cell property for all active cells. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
values(list): a list of double precision floating point numbers
Expand Down Expand Up @@ -861,7 +861,7 @@ def set_grid_property(
time_step,
grid_index=0,
porosity_model="MATRIX_MODEL"):
"""Set a cell property for all grid cells. For argument details, see :ref:`result-definition-label`
"""Set a cell property for all grid cells. For argument details, see :ref:`Result Definition <result-definition-label>`
Arguments:
values(list): a list of double precision floating point numbers
Expand Down Expand Up @@ -924,7 +924,7 @@ def create_well_bore_stability_plot(self, well_path, time_step, parameters=None)
time_step(int): time step
Returns:
:class:`rips.generated.resinsight_classes.WellBoreStabilityPlot`
:class:`rips.generated.generated_classes.WellBoreStabilityPlot`
"""
pb2_parameters = None
if parameters is not None:
Expand Down Expand Up @@ -962,7 +962,7 @@ def simulation_wells(self):
"""Get a list of all simulation wells for a case
Returns:
:class:`rips.generated.resinsight_classes.SimulationWell`
:class:`rips.generated.generated_classes.SimulationWell`
"""
wells = self.descendants(SimulationWell)
Expand Down
4 changes: 2 additions & 2 deletions docs/rips/contour_map.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
ResInsight 3d contour map module
"""
import Commands_pb2
import rips.generated.Commands_pb2

from .pdmobject import add_method
from .view import View
from resinsight_classes import EclipseContourMap, GeoMechContourMap
from .resinsight_classes import EclipseContourMap, GeoMechContourMap


@add_method(EclipseContourMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class FaciesProperties(PdmObjectBase):
__custom_init__ = None #: Assign a custom init routine to be run at __init__

def __init__(self, pb2_object=None, channel=None):
self.color_legend = "ColorLegend:2174931122064"
self.color_legend = "ColorLegend:2448476982720"
self.file_path = ""
self.properties_table = ""
PdmObjectBase.__init__(self, pb2_object, channel)
Expand Down Expand Up @@ -573,6 +573,7 @@ class EclipseResult(PdmObjectBase):
selected_injector_tracers (List of str): Injector Tracers
selected_producer_tracers (List of str): Producer Tracers
selected_souring_tracers (List of str): Tracers
show_only_visible_tracers_in_legend (str): Show Only Visible Tracers In Legend
"""
__custom_init__ = None #: Assign a custom init routine to be run at __init__

Expand All @@ -585,6 +586,7 @@ def __init__(self, pb2_object=None, channel=None):
self.selected_injector_tracers = []
self.selected_producer_tracers = []
self.selected_souring_tracers = []
self.show_only_visible_tracers_in_legend = True
PdmObjectBase.__init__(self, pb2_object, channel)
if EclipseResult.__custom_init__ is not None:
EclipseResult.__custom_init__(self, pb2_object=pb2_object, channel=channel)
Expand All @@ -601,6 +603,27 @@ def __init__(self, pb2_object=None, channel=None):
if CellColors.__custom_init__ is not None:
CellColors.__custom_init__(self, pb2_object=pb2_object, channel=channel)

class RimCellFilterCollection(PdmObjectBase):
"""
Attributes:
active (str): Active
"""
__custom_init__ = None #: Assign a custom init routine to be run at __init__

def __init__(self, pb2_object=None, channel=None):
self.active = True
PdmObjectBase.__init__(self, pb2_object, channel)
if RimCellFilterCollection.__custom_init__ is not None:
RimCellFilterCollection.__custom_init__(self, pb2_object=pb2_object, channel=channel)

def cell_filters(self):
"""Filters
Returns:
List of CellFilter
"""
return self.children("CellFilters", CellFilter)


class EclipseContourMap(EclipseView):
"""
A contour map for Eclipse cases
Expand Down Expand Up @@ -882,7 +905,7 @@ class StimPlanModelTemplate(PdmObjectBase):

def __init__(self, pb2_object=None, channel=None):
self.default_permeability = 1e-05
self.default_porosity = 0
self.default_porosity = 0.01
self.id = -1
self.overburden_facies = ""
self.overburden_fluid_density = 1.03
Expand Down Expand Up @@ -1330,6 +1353,7 @@ def class_dict():
classes['Project'] = Project
classes['ResampleData'] = ResampleData
classes['Reservoir'] = Reservoir
classes['RimCellFilterCollection'] = RimCellFilterCollection
classes['SimulationWell'] = SimulationWell
classes['StimPlanModel'] = StimPlanModel
classes['StimPlanModelCollection'] = StimPlanModelCollection
Expand Down
6 changes: 3 additions & 3 deletions docs/rips/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
about Case grids.
"""

import Case_pb2
import Grid_pb2
import Grid_pb2_grpc
import rips.generated.Case_pb2
import rips.generated.Grid_pb2
import rips.generated.Grid_pb2_grpc


class Grid:
Expand Down

0 comments on commit 3792a1b

Please sign in to comment.