mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-31 09:14:11 -05:00
#5792 Python : Add import_summary_case and find summary case from ID
Add example of use and updated documentation
This commit is contained in:
1 parent
f0275df249
commit
185e4c15ef
15 files changed
+533
-64
No files matched your search
+24
-21
@@ -5,6 +5,22 @@
|
||||
|
||||
"""
|
||||
Module containing the 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
|
||||
|
||||
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
|
||||
@@ -29,22 +45,6 @@ from rips.view import View
|
||||
from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters
|
||||
from rips.simulation_well import SimulationWell
|
||||
|
||||
"""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
|
||||
|
||||
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)
|
||||
@@ -102,18 +102,21 @@ def __generate_property_input_chunks(self, array, parameters):
|
||||
|
||||
@add_method(Case)
|
||||
def grid(self, index):
|
||||
"""Get Grid of a given index. Returns a rips Grid object
|
||||
"""Get Grid of a given index
|
||||
|
||||
Arguments:
|
||||
index (int): The grid index
|
||||
|
||||
Returns: Grid object
|
||||
Returns: :class:`rips.grid.Grid`
|
||||
"""
|
||||
return Grid(index, self, self.channel())
|
||||
|
||||
@add_method(Case)
|
||||
def grids(self):
|
||||
"""Get a list of all rips Grid objects in the case"""
|
||||
"""Get a list of all rips Grid objects in the case
|
||||
|
||||
Returns: List of :class:`rips.grid.Grid`
|
||||
"""
|
||||
grid_list = []
|
||||
for i in range(0, self.__grid_count()):
|
||||
grid_list.append(Grid(i, self, self.channel()))
|
||||
@@ -870,8 +873,8 @@ def import_formation_names(self, formation_files=None):
|
||||
elif isinstance(formation_files, str):
|
||||
formation_files = [formation_files]
|
||||
|
||||
res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
applyToCaseId=self.id))
|
||||
self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
applyToCaseId=self.id))
|
||||
|
||||
@add_method(Case)
|
||||
def simulation_wells(self):
|
||||
|
||||
@@ -5,6 +5,45 @@ class PdmObject:
|
||||
if PdmObject.__custom_init__ is not None:
|
||||
PdmObject.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class DataContainerFloat(PdmObject):
|
||||
"""
|
||||
Attributes:
|
||||
values (List of float): Float Values
|
||||
"""
|
||||
__custom_init__ = None #: Assign a custom init routine to be run at __init__
|
||||
|
||||
def __init__(self, pb2_object=None, channel=None):
|
||||
self.values = []
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
if DataContainerFloat.__custom_init__ is not None:
|
||||
DataContainerFloat.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class DataContainerString(PdmObject):
|
||||
"""
|
||||
Attributes:
|
||||
values (List of str): String Values
|
||||
"""
|
||||
__custom_init__ = None #: Assign a custom init routine to be run at __init__
|
||||
|
||||
def __init__(self, pb2_object=None, channel=None):
|
||||
self.values = []
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
if DataContainerString.__custom_init__ is not None:
|
||||
DataContainerString.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class DataContainerTime(PdmObject):
|
||||
"""
|
||||
Attributes:
|
||||
values (List of time): Time Values
|
||||
"""
|
||||
__custom_init__ = None #: Assign a custom init routine to be run at __init__
|
||||
|
||||
def __init__(self, pb2_object=None, channel=None):
|
||||
self.values = []
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
if DataContainerTime.__custom_init__ is not None:
|
||||
DataContainerTime.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class Case(PdmObject):
|
||||
"""
|
||||
The ResInsight base class for Cases
|
||||
@@ -62,6 +101,7 @@ class SummaryCase(PdmObject):
|
||||
|
||||
Attributes:
|
||||
auto_shorty_name (str): Use Auto Display Name
|
||||
id (int): Case ID
|
||||
short_name (str): Display Name
|
||||
summary_header_filename (str): Summary Header File
|
||||
"""
|
||||
@@ -69,12 +109,58 @@ class SummaryCase(PdmObject):
|
||||
|
||||
def __init__(self, pb2_object=None, channel=None):
|
||||
self.auto_shorty_name = False
|
||||
self.id = -1
|
||||
self.short_name = "Display Name"
|
||||
self.summary_header_filename = ""
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
if SummaryCase.__custom_init__ is not None:
|
||||
SummaryCase.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
def available_addresses(self, ):
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
DataContainerString
|
||||
"""
|
||||
return self._call_pdm_method("availableAddresses")
|
||||
|
||||
|
||||
def available_time_steps(self, ):
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
DataContainerTime
|
||||
"""
|
||||
return self._call_pdm_method("availableTimeSteps")
|
||||
|
||||
|
||||
def resample_values(self, address=None, resampling_period=None):
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
address (str): Formatted address specifying the summary vector
|
||||
resampling_period (str): Resampling Period
|
||||
Returns:
|
||||
ResampleData
|
||||
"""
|
||||
return self._call_pdm_method("resampleValues", address=address, resampling_period=resampling_period)
|
||||
|
||||
|
||||
def summary_vector_values(self, address=None):
|
||||
"""
|
||||
Create a new Summary Plot
|
||||
Arguments:
|
||||
address (str): Formatted address specifying the summary vector
|
||||
Returns:
|
||||
DataContainerFloat
|
||||
"""
|
||||
return self._call_pdm_method("summaryVectorValues", address=address)
|
||||
|
||||
|
||||
class FileSummaryCase(SummaryCase):
|
||||
"""
|
||||
A Summary Case based on SMSPEC files
|
||||
@@ -212,6 +298,43 @@ class Project(PdmObject):
|
||||
if Project.__custom_init__ is not None:
|
||||
Project.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
def import_summary_case(self, file_name=None):
|
||||
"""
|
||||
Import Summary Case
|
||||
Arguments:
|
||||
file_name (str):
|
||||
Returns:
|
||||
FileSummaryCase
|
||||
"""
|
||||
return self._call_pdm_method("importSummaryCase", file_name=file_name)
|
||||
|
||||
|
||||
def summary_case(self, case_id=None):
|
||||
"""
|
||||
Find Summary Case
|
||||
Arguments:
|
||||
case_id (int):
|
||||
Returns:
|
||||
FileSummaryCase
|
||||
"""
|
||||
return self._call_pdm_method("summaryCase", case_id=case_id)
|
||||
|
||||
|
||||
class ResampleData(PdmObject):
|
||||
"""
|
||||
Attributes:
|
||||
time_steps (List of time): Time Steps
|
||||
values (List of float): Values
|
||||
"""
|
||||
__custom_init__ = None #: Assign a custom init routine to be run at __init__
|
||||
|
||||
def __init__(self, pb2_object=None, channel=None):
|
||||
self.time_steps = []
|
||||
self.values = []
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
if ResampleData.__custom_init__ is not None:
|
||||
ResampleData.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class EclipseView(View):
|
||||
"""
|
||||
The Eclipse 3d Reservoir View
|
||||
@@ -259,9 +382,9 @@ class EclipseResult(PdmObject):
|
||||
porosity_model_type (str): Porosity
|
||||
result_type (str): Type
|
||||
result_variable (str): Variable
|
||||
selected_injector_tracers (str): Injector Tracers
|
||||
selected_producer_tracers (str): Producer Tracers
|
||||
selected_souring_tracers (str): Tracers
|
||||
selected_injector_tracers (List of str): Injector Tracers
|
||||
selected_producer_tracers (List of str): Producer Tracers
|
||||
selected_souring_tracers (List of str): Tracers
|
||||
"""
|
||||
__custom_init__ = None #: Assign a custom init routine to be run at __init__
|
||||
|
||||
@@ -331,6 +454,25 @@ class GridCaseGroup(PdmObject):
|
||||
if GridCaseGroup.__custom_init__ is not None:
|
||||
GridCaseGroup.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class SummaryCaseSubCollection(PdmObject):
|
||||
"""
|
||||
Attributes:
|
||||
id (int): Ensemble ID
|
||||
is_ensemble (str): Is Ensemble
|
||||
name_count (str): Name
|
||||
summary_collection_name (str): Name
|
||||
"""
|
||||
__custom_init__ = None #: Assign a custom init routine to be run at __init__
|
||||
|
||||
def __init__(self, pb2_object=None, channel=None):
|
||||
self.id = -1
|
||||
self.is_ensemble = False
|
||||
self.name_count = "Group"
|
||||
self.summary_collection_name = "Group"
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
if SummaryCaseSubCollection.__custom_init__ is not None:
|
||||
SummaryCaseSubCollection.__custom_init__(self, pb2_object=pb2_object, channel=channel)
|
||||
|
||||
class PlotWindow(ViewWindow):
|
||||
"""
|
||||
The Abstract base class for all MDI Windows in the Plot Window
|
||||
@@ -438,7 +580,7 @@ class WbsParameters(PdmObject):
|
||||
self.user_k0_fg = 0.75
|
||||
self.user_k0_sh = 0.65
|
||||
self.user_poisson_ratio = 0.35
|
||||
self.user_pp_non_reservoir = 1.05
|
||||
self.user_pp_non_reservoir = 1
|
||||
self.user_ucs = 100
|
||||
self.water_density = 1.03
|
||||
PdmObject.__init__(self, pb2_object, channel)
|
||||
@@ -524,6 +666,9 @@ def class_dict():
|
||||
classes = {}
|
||||
classes['Case'] = Case
|
||||
classes['CellColors'] = CellColors
|
||||
classes['DataContainerFloat'] = DataContainerFloat
|
||||
classes['DataContainerString'] = DataContainerString
|
||||
classes['DataContainerTime'] = DataContainerTime
|
||||
classes['EclipseCase'] = EclipseCase
|
||||
classes['EclipseContourMap'] = EclipseContourMap
|
||||
classes['EclipseResult'] = EclipseResult
|
||||
@@ -540,9 +685,11 @@ def class_dict():
|
||||
classes['Plot'] = Plot
|
||||
classes['PlotWindow'] = PlotWindow
|
||||
classes['Project'] = Project
|
||||
classes['ResampleData'] = ResampleData
|
||||
classes['Reservoir'] = Reservoir
|
||||
classes['SimulationWell'] = SimulationWell
|
||||
classes['SummaryCase'] = SummaryCase
|
||||
classes['SummaryCaseSubCollection'] = SummaryCaseSubCollection
|
||||
classes['SummaryPlot'] = SummaryPlot
|
||||
classes['SummaryPlotCollection'] = SummaryPlotCollection
|
||||
classes['View'] = View
|
||||
|
||||
@@ -362,7 +362,15 @@ def _call_pdm_method(self, method_name, **kwargs):
|
||||
for key, value in kwargs.items():
|
||||
pb2_params.parameters[snake_to_camel(key)] = self.__convert_to_grpc_value(value)
|
||||
request = PdmObject_pb2.PdmObjectMethodRequest(object=self._pb2_object, method=method_name, params=pb2_params)
|
||||
return self._pdm_object_stub.CallPdmObjectMethod(request)
|
||||
|
||||
pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request)
|
||||
|
||||
child_class_definition = class_from_keyword(pb2_object.class_keyword)
|
||||
if child_class_definition is None:
|
||||
return None
|
||||
|
||||
pdm_object = child_class_definition(pb2_object=pb2_object, channel=self.channel())
|
||||
return pdm_object
|
||||
|
||||
@add_method(PdmObject)
|
||||
def update(self):
|
||||
|
||||
@@ -341,5 +341,6 @@ def import_formation_names(self, formation_files=None):
|
||||
elif isinstance(formation_files, str):
|
||||
formation_files = [formation_files]
|
||||
|
||||
res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
applyToCaseId=-1))
|
||||
|
||||
Reference in new issue
Block a user