mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-29 10:21:54 -06:00
Add new passthrough module for rips generated_classes and refactor imports
This commit is contained in:
parent
a2ee4c8fef
commit
0d3ea8ede1
@ -9,10 +9,19 @@ 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()
|
@ -16,7 +16,7 @@ methods in Project: loadCase, case, allCases, selectedCases
|
||||
|
||||
Result Definition
|
||||
-----------------
|
||||
When working with grid case results, the following two argumenst are used in many functions to identify a
|
||||
When working with grid case results, the following two arguments are used in many functions to identify a
|
||||
result
|
||||
|
||||
**Result Definition enums**::
|
||||
@ -33,17 +33,6 @@ result
|
||||
FLOW_DIAGNOSTICS | |
|
||||
INJECTION_FLOODING | |
|
||||
|
||||
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
import builtins
|
||||
@ -586,7 +575,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.
|
||||
@ -610,7 +599,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
|
||||
@ -641,7 +630,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
|
||||
@ -669,7 +658,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
|
||||
@ -700,7 +689,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
|
||||
@ -730,7 +719,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
|
||||
@ -765,7 +754,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
|
||||
@ -795,7 +784,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
|
||||
@ -827,7 +816,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
|
||||
@ -861,7 +850,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
|
||||
|
@ -44,9 +44,9 @@ def views(self):
|
||||
List of :class:`rips.generated.generated_classes.EclipseView`
|
||||
|
||||
"""
|
||||
generated_classes = self.descendants(EclipseView)
|
||||
resinsight_classes = self.descendants(EclipseView)
|
||||
view_list = []
|
||||
for pdm_object in generated_classes:
|
||||
for pdm_object in resinsight_classes:
|
||||
view_list.append(pdm_object)
|
||||
return view_list
|
||||
|
||||
|
@ -191,6 +191,7 @@ class PdmObjectBase:
|
||||
|
||||
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.
|
||||
@ -212,7 +213,7 @@ class PdmObjectBase:
|
||||
values.append(self.__convert_from_grpc_value(string))
|
||||
return values
|
||||
|
||||
def __from_pb2_to_generated_classes(self, pb2_object_list, super_class_definition):
|
||||
def __from_pb2_to_resinsight_classes(self, pb2_object_list, super_class_definition):
|
||||
pdm_object_list = []
|
||||
from .generated.generated_classes import class_from_keyword
|
||||
for pb2_object in pb2_object_list:
|
||||
@ -240,7 +241,7 @@ class PdmObjectBase:
|
||||
object=self._pb2_object, child_keyword=class_keyword)
|
||||
object_list = self._pdm_object_stub.GetDescendantPdmObjects(
|
||||
request).objects
|
||||
return self.__from_pb2_to_generated_classes(object_list, class_definition)
|
||||
return self.__from_pb2_to_resinsight_classes(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return [] # Valid empty result
|
||||
@ -257,7 +258,7 @@ class PdmObjectBase:
|
||||
child_field=child_field)
|
||||
try:
|
||||
object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects
|
||||
return self.__from_pb2_to_generated_classes(object_list, class_definition)
|
||||
return self.__from_pb2_to_resinsight_classes(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return []
|
||||
|
@ -106,7 +106,7 @@ def case(self, case_id):
|
||||
Arguments:
|
||||
id(int): case id
|
||||
Returns:
|
||||
:class:`rips.generated.generated_classes.Case`
|
||||
:class:`rips.generated.resinsight_classes.Case`
|
||||
"""
|
||||
allCases = self.cases()
|
||||
for case in allCases:
|
||||
@ -135,7 +135,7 @@ def create_grid_case_group(self, case_paths):
|
||||
Arguments:
|
||||
case_paths (list): list of file path strings
|
||||
Returns:
|
||||
:class:`rips.generated.generated_classes.GridCaseGroup`
|
||||
:class:`rips.generated.resinsight_classes.GridCaseGroup`
|
||||
"""
|
||||
command_reply = self._execute_command(
|
||||
createGridCaseGroup=Commands_pb2.CreateGridCaseGroupRequest(
|
||||
@ -147,7 +147,7 @@ def create_grid_case_group(self, case_paths):
|
||||
def summary_cases(self):
|
||||
"""Get a list of all summary cases in the Project
|
||||
|
||||
Returns: A list of :class:`rips.generated.generated_classes.SummaryCase`
|
||||
Returns: A list of :class:`rips.generated.resinsight_classes.SummaryCase`
|
||||
"""
|
||||
return self.descendants(SummaryCase)
|
||||
|
||||
@ -180,9 +180,9 @@ def plots(self):
|
||||
Returns:
|
||||
List of :class:`rips.generated.generated_classes.Plot`
|
||||
"""
|
||||
generated_classes = self.descendants(PlotWindow)
|
||||
resinsight_classes = self.descendants(PlotWindow)
|
||||
plot_list = []
|
||||
for pdm_object in generated_classes:
|
||||
for pdm_object in resinsight_classes:
|
||||
if pdm_object.id != -1:
|
||||
plot_list.append(pdm_object)
|
||||
return plot_list
|
||||
|
@ -1 +1,2 @@
|
||||
name = "rips"
|
||||
from .generated.generated_classes import *
|
||||
|
Loading…
Reference in New Issue
Block a user