mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Update python doc (#5803)
Several improvement and adjustments to the Python documentation - applied autopep8 - add summary example - use references to reference other classes and methods
This commit is contained in:
@@ -33,10 +33,10 @@ release = '2019.04.01'
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.napoleon',
|
||||
'sphinx_markdown_builder'
|
||||
'sphinx_markdown_builder'
|
||||
]
|
||||
|
||||
master_doc = 'PythonRips'
|
||||
master_doc = 'PythonRips'
|
||||
|
||||
napoleon_google_docstring = True
|
||||
|
||||
@@ -56,7 +56,7 @@ exclude_patterns = ['build/*', 'rips.rst']
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
|
||||
smartquotes=False
|
||||
smartquotes = False
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
|
||||
@@ -12,6 +12,29 @@ 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
|
||||
|
||||
.. _result-definition-label:
|
||||
|
||||
Result Definition
|
||||
-----------------
|
||||
When working with grid case results, the following two argumenst are used in many functions to identify a
|
||||
result
|
||||
|
||||
**Result Definition enums**::
|
||||
|
||||
property_type | | porosity_model
|
||||
(str enum) | | (str enum)
|
||||
----------------------- | ----- | --------------
|
||||
DYNAMIC_NATIVE | | MATRIX_MODEL
|
||||
STATIC_NATIVE | | FRACTURE_MODEL
|
||||
SOURSIMRL | |
|
||||
GENERATED | |
|
||||
INPUT_PROPERTY | |
|
||||
FORMATION_NAMES | |
|
||||
FLOW_DIAGNOSTICS | |
|
||||
INJECTION_FLOODING | |
|
||||
|
||||
|
||||
|
||||
Attributes:
|
||||
id (int): Case Id corresponding to case Id in ResInsight project.
|
||||
name (str): Case name
|
||||
@@ -45,6 +68,7 @@ from rips.view import View
|
||||
from rips.generated.pdm_objects import WellBoreStabilityPlot, WbsParameters
|
||||
from rips.simulation_well import SimulationWell
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __custom_init__(self, pb2_object, channel):
|
||||
self.__case_stub = Case_pb2_grpc.CaseStub(self._channel)
|
||||
@@ -55,6 +79,7 @@ def __custom_init__(self, pb2_object, channel):
|
||||
# Public properties
|
||||
self.chunk_size = 8160
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __grid_count(self):
|
||||
"""Get number of grids in the case"""
|
||||
@@ -65,10 +90,12 @@ def __grid_count(self):
|
||||
return 0
|
||||
return 0
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __request(self):
|
||||
return Case_pb2.CaseRequest(id=self.id)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __generate_property_input_iterator(self, values_iterator, parameters):
|
||||
chunk = Properties_pb2.PropertyInputChunk()
|
||||
@@ -80,6 +107,7 @@ def __generate_property_input_iterator(self, values_iterator, parameters):
|
||||
chunk.values.CopyFrom(valmsg)
|
||||
yield chunk
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __generate_property_input_chunks(self, array, parameters):
|
||||
index = -1
|
||||
@@ -92,7 +120,7 @@ def __generate_property_input_chunks(self, array, parameters):
|
||||
actual_chunk_size = min(len(array) - index + 1, self.chunk_size)
|
||||
chunk.values.CopyFrom(
|
||||
Properties_pb2.PropertyChunk(values=array[index:index +
|
||||
actual_chunk_size]))
|
||||
actual_chunk_size]))
|
||||
index += actual_chunk_size
|
||||
|
||||
yield chunk
|
||||
@@ -100,6 +128,7 @@ def __generate_property_input_chunks(self, array, parameters):
|
||||
chunk = Properties_pb2.PropertyInputChunk()
|
||||
yield chunk
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def grid(self, index):
|
||||
"""Get Grid of a given index
|
||||
@@ -107,27 +136,31 @@ def grid(self, index):
|
||||
Arguments:
|
||||
index (int): The grid index
|
||||
|
||||
Returns: :class:`rips.grid.Grid`
|
||||
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
|
||||
|
||||
Returns: List of :class:`rips.grid.Grid`
|
||||
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()))
|
||||
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
|
||||
new_egrid_file (str): Path to EGRID file
|
||||
"""
|
||||
project = self.ancestor(rips.project.Project)
|
||||
self._execute_command(replaceCase=Cmd.ReplaceCaseRequest(
|
||||
@@ -135,10 +168,10 @@ def replace(self, new_grid_file):
|
||||
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
|
||||
"""Get a cell count object containing number of active cells and total number of cells
|
||||
|
||||
Arguments:
|
||||
porosity_model (str): String representing an enum.
|
||||
@@ -147,12 +180,21 @@ def cell_count(self, porosity_model="MATRIX_MODEL"):
|
||||
Cell Count object with the following integer attributes:
|
||||
active_cell_count: number of active cells
|
||||
reservoir_cell_count: total number of reservoir cells
|
||||
|
||||
**CellCount class description**::
|
||||
|
||||
Parameter | Description | Type
|
||||
----------------------- | ------------------------- | -----
|
||||
active_cell_count | Number of active cells | Integer
|
||||
reservoir_cell_count | Total number of cells | Integer
|
||||
|
||||
"""
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
request = Case_pb2.CellInfoRequest(case_request=self.__request(),
|
||||
porosity_model=porosity_model_enum)
|
||||
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
|
||||
@@ -164,13 +206,14 @@ def cell_info_for_active_cells_async(self, porosity_model="MATRIX_MODEL"):
|
||||
Returns:
|
||||
Stream of **CellInfo** objects
|
||||
|
||||
See cell_info_for_active_cells() for detalis on the **CellInfo** class.
|
||||
See :meth:`rips.case.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)
|
||||
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
|
||||
@@ -209,6 +252,7 @@ def cell_info_for_active_cells(self, porosity_model="MATRIX_MODEL"):
|
||||
received_active_cells.append(active_cell)
|
||||
return received_active_cells
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def time_steps(self):
|
||||
"""Get a list containing all time steps
|
||||
@@ -230,36 +274,56 @@ def time_steps(self):
|
||||
"""
|
||||
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
|
||||
Returns:
|
||||
BoundingBox
|
||||
|
||||
**BoundingBox class description**::
|
||||
|
||||
Type | Name
|
||||
--------- | ----------
|
||||
int | min_x
|
||||
int | max_x
|
||||
int | min_y
|
||||
int | max_y
|
||||
int | min_z
|
||||
int | 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
|
||||
|
||||
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 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
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.View`
|
||||
"""
|
||||
views = self.views()
|
||||
for view_object in views:
|
||||
@@ -267,13 +331,19 @@ def view(self, view_id):
|
||||
return view_object
|
||||
return None
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_view(self):
|
||||
"""Create a new view in the current case"""
|
||||
"""Create a new view in the current case
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.View`
|
||||
"""
|
||||
return self.view(
|
||||
self._execute_command(createView=Cmd.CreateViewRequest(
|
||||
caseId=self.id)).createViewResult.viewId)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def export_snapshots_of_all_views(self, prefix="", export_folder=""):
|
||||
""" Export snapshots for all views in the case
|
||||
@@ -287,6 +357,7 @@ def export_snapshots_of_all_views(self, prefix="", export_folder=""):
|
||||
exportSnapshots=Cmd.ExportSnapshotsRequest(
|
||||
type="VIEWS", prefix=prefix, caseId=self.id, viewId=-1, exportFolder=export_folder))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def export_well_path_completions(
|
||||
self,
|
||||
@@ -353,6 +424,7 @@ def export_well_path_completions(
|
||||
combinationMode=combination_mode,
|
||||
))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def export_msw(self, well_path):
|
||||
"""
|
||||
@@ -364,6 +436,7 @@ def export_msw(self, well_path):
|
||||
return self._execute_command(exportMsw=Cmd.ExportMswRequest(
|
||||
caseId=self.id, wellPath=well_path))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_multiple_fractures(
|
||||
self,
|
||||
@@ -408,6 +481,7 @@ def create_multiple_fractures(
|
||||
action=action,
|
||||
))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_lgr_for_completion(
|
||||
self,
|
||||
@@ -454,6 +528,7 @@ def create_lgr_for_completion(
|
||||
splitType=split_type,
|
||||
))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_saturation_pressure_plots(self):
|
||||
"""
|
||||
@@ -464,6 +539,7 @@ def create_saturation_pressure_plots(self):
|
||||
createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest(
|
||||
caseIds=case_ids))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def export_flow_characteristics(
|
||||
self,
|
||||
@@ -505,23 +581,17 @@ def export_flow_characteristics(
|
||||
aquiferCellThreshold=aquifer_cell_threshold,
|
||||
))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def available_properties(self,
|
||||
property_type,
|
||||
porosity_model="MATRIX_MODEL"):
|
||||
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
|
||||
For argument details, see :ref:`result-definition-label`
|
||||
|
||||
Arguments:
|
||||
property_type (str): string corresponding to property_type enum.
|
||||
porosity_model(str): 'MATRIX_MODEL' or 'FRACTURE_MODEL'.
|
||||
"""
|
||||
|
||||
@@ -535,19 +605,20 @@ def available_properties(self,
|
||||
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
|
||||
property_type,
|
||||
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`
|
||||
|
||||
Arguments:
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
|
||||
Returns:
|
||||
An iterator to a chunk object containing an array of double values
|
||||
@@ -565,19 +636,20 @@ def active_cell_property_async(self,
|
||||
for chunk in self.__properties_stub.GetActiveCellProperty(request):
|
||||
yield chunk
|
||||
|
||||
|
||||
@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
|
||||
property_type,
|
||||
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`
|
||||
|
||||
Arguments:
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
|
||||
Returns:
|
||||
A list containing double values
|
||||
@@ -592,19 +664,20 @@ def active_cell_property(self,
|
||||
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
|
||||
property_type,
|
||||
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`
|
||||
|
||||
Arguments:
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
|
||||
Returns:
|
||||
An iterator to a chunk object containing an array of double values
|
||||
@@ -622,19 +695,20 @@ def selected_cell_property_async(self,
|
||||
for chunk in self.__properties_stub.GetSelectedCellProperty(request):
|
||||
yield chunk
|
||||
|
||||
|
||||
@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
|
||||
property_type,
|
||||
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`
|
||||
|
||||
Arguments:
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
|
||||
Returns:
|
||||
A list containing double values
|
||||
@@ -642,13 +716,14 @@ def selected_cell_property(self,
|
||||
"""
|
||||
all_values = []
|
||||
generator = self.selected_cell_property_async(property_type,
|
||||
property_name, time_step,
|
||||
porosity_model)
|
||||
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 grid_property_async(
|
||||
self,
|
||||
@@ -657,14 +732,14 @@ 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
|
||||
"""Get a cell property for all grid cells. Async, so returns an iterator. For argument details, see :ref:`result-definition-label`
|
||||
|
||||
Arguments:
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
|
||||
Returns:
|
||||
An iterator to a chunk object containing an array of double values
|
||||
@@ -683,6 +758,7 @@ def grid_property_async(
|
||||
for chunk in self.__properties_stub.GetGridProperty(request):
|
||||
yield chunk
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def grid_property(
|
||||
self,
|
||||
@@ -691,27 +767,28 @@ 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
|
||||
"""Get a cell property for all grid cells. Synchronous, so returns a list. For argument details, see :ref:`result-definition-label`
|
||||
|
||||
Arguments:
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
|
||||
Returns:
|
||||
A list of double values
|
||||
"""
|
||||
all_values = []
|
||||
generator = self.grid_property_async(property_type, property_name,
|
||||
time_step, grid_index,
|
||||
porosity_model)
|
||||
time_step, grid_index,
|
||||
porosity_model)
|
||||
for chunk in generator:
|
||||
for value in chunk.values:
|
||||
all_values.append(value)
|
||||
return all_values
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def set_active_cell_property_async(
|
||||
self,
|
||||
@@ -720,14 +797,14 @@ 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
|
||||
"""Set cell property for all active cells Async. Takes an iterator to the input values. For argument details, see :ref:`result-definition-label`
|
||||
|
||||
Arguments:
|
||||
values_iterator(iterator): an iterator to the properties to be set
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
"""
|
||||
property_type_enum = Properties_pb2.PropertyType.Value(property_type)
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
@@ -743,6 +820,7 @@ def set_active_cell_property_async(
|
||||
values_iterator, request)
|
||||
self.__properties_stub.SetActiveCellProperty(request_iterator)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def set_active_cell_property(
|
||||
self,
|
||||
@@ -751,14 +829,14 @@ def set_active_cell_property(
|
||||
property_name,
|
||||
time_step,
|
||||
porosity_model="MATRIX_MODEL"):
|
||||
"""Set a cell property for all active cells.
|
||||
"""Set a cell property for all active cells. For argument details, see :ref:`result-definition-label`
|
||||
|
||||
Arguments:
|
||||
values(list): a list of double precision floating point numbers
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
"""
|
||||
property_type_enum = Properties_pb2.PropertyType.Value(property_type)
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
@@ -775,6 +853,7 @@ def set_active_cell_property(
|
||||
if reply.accepted_value_count < len(values):
|
||||
raise IndexError
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def set_grid_property(
|
||||
self,
|
||||
@@ -784,15 +863,15 @@ def set_grid_property(
|
||||
time_step,
|
||||
grid_index=0,
|
||||
porosity_model="MATRIX_MODEL"):
|
||||
"""Set a cell property for all grid cells.
|
||||
"""Set a cell property for all grid cells. For argument details, see :ref:`result-definition-label`
|
||||
|
||||
Arguments:
|
||||
values(list): a list of double precision floating point numbers
|
||||
property_type(str): string enum. See available()
|
||||
property_type(str): string enum
|
||||
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()
|
||||
porosity_model(str): string enum
|
||||
"""
|
||||
property_type_enum = Properties_pb2.PropertyType.Value(property_type)
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
@@ -810,6 +889,7 @@ def set_grid_property(
|
||||
if reply.accepted_value_count < len(values):
|
||||
raise IndexError
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def export_property(
|
||||
self,
|
||||
@@ -836,6 +916,7 @@ def export_property(
|
||||
exportFile=export_file,
|
||||
))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_well_bore_stability_plot(self, well_path, time_step, parameters=None):
|
||||
""" Create a new well bore stability plot
|
||||
@@ -845,7 +926,7 @@ def create_well_bore_stability_plot(self, well_path, time_step, parameters=None)
|
||||
time_step(int): time step
|
||||
|
||||
Returns:
|
||||
A new plot object
|
||||
:class:`rips.generated.pdm_objects.WellBoreStabilityPlot`
|
||||
"""
|
||||
pb2_parameters = None
|
||||
if parameters is not None:
|
||||
@@ -853,13 +934,14 @@ def create_well_bore_stability_plot(self, well_path, time_step, parameters=None)
|
||||
pb2_parameters = parameters.pb2_object()
|
||||
|
||||
plot_result = self._execute_command(createWellBoreStabilityPlot=Cmd.CreateWbsPlotRequest(caseId=self.id,
|
||||
wellPath=well_path,
|
||||
timeStep=time_step,
|
||||
wbsParameters=pb2_parameters))
|
||||
wellPath=well_path,
|
||||
timeStep=time_step,
|
||||
wbsParameters=pb2_parameters))
|
||||
project = self.ancestor(rips.project.Project)
|
||||
plot = project.plot(view_id=plot_result.createWbsPlotResult.viewId)
|
||||
return plot
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def import_formation_names(self, formation_files=None):
|
||||
""" Import formation names into project and apply it to the current case
|
||||
@@ -876,16 +958,19 @@ def import_formation_names(self, formation_files=None):
|
||||
self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
applyToCaseId=self.id))
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def simulation_wells(self):
|
||||
"""Get a list of all simulation wells for a case
|
||||
|
||||
Returns:
|
||||
A list of rips **SimulationWell** objects
|
||||
:class:`rips.generated.pdm_objects.SimulationWell`
|
||||
|
||||
"""
|
||||
wells = self.descendants(SimulationWell)
|
||||
return wells
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def active_cell_centers_async(
|
||||
self,
|
||||
@@ -901,9 +986,10 @@ def active_cell_centers_async(
|
||||
"""
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
request = Case_pb2.CellInfoRequest(case_request=self.__request(),
|
||||
porosity_model=porosity_model_enum)
|
||||
porosity_model=porosity_model_enum)
|
||||
return self.__case_stub.GetCellCenterForActiveCells(request)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def active_cell_centers(
|
||||
self,
|
||||
@@ -923,6 +1009,7 @@ def active_cell_centers(
|
||||
cell_centers.append(value)
|
||||
return cell_centers
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def active_cell_corners_async(
|
||||
self,
|
||||
@@ -938,9 +1025,10 @@ def active_cell_corners_async(
|
||||
"""
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
request = Case_pb2.CellInfoRequest(case_request=self.__request(),
|
||||
porosity_model=porosity_model_enum)
|
||||
porosity_model=porosity_model_enum)
|
||||
return self.__case_stub.GetCellCornersForActiveCells(request)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def active_cell_corners(
|
||||
self,
|
||||
@@ -950,8 +1038,20 @@ def active_cell_corners(
|
||||
Arguments:
|
||||
porosity_model(str): string enum. See available()
|
||||
|
||||
Returns:
|
||||
A list of CellCorners
|
||||
**CellCorner class description**::
|
||||
|
||||
Parameter | Description | Type
|
||||
----------- | ------------ | -----
|
||||
c0 | | Vec3d
|
||||
c1 | | Vec3d
|
||||
c2 | | Vec3d
|
||||
c3 | | Vec3d
|
||||
c4 | | Vec3d
|
||||
c5 | | Vec3d
|
||||
c6 | | Vec3d
|
||||
c7 | | Vec3d
|
||||
|
||||
|
||||
"""
|
||||
cell_corners = []
|
||||
generator = self.active_cell_corners_async(porosity_model)
|
||||
@@ -960,16 +1060,18 @@ def active_cell_corners(
|
||||
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.
|
||||
@@ -984,6 +1086,7 @@ def selected_cells(self):
|
||||
cells.append(value)
|
||||
return cells
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def coarsening_info(self):
|
||||
"""Get a coarsening information for all grids in the case.
|
||||
@@ -994,12 +1097,24 @@ def coarsening_info(self):
|
||||
"""
|
||||
return self.__case_stub.GetCoarseningInfoArray(self.__request()).data
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def available_nnc_properties(self):
|
||||
"""Get a list of available NNC properties
|
||||
|
||||
**NNCConnection class description**::
|
||||
|
||||
Parameter | Description | Type
|
||||
------------------------| --------------------------------------------- | -----
|
||||
cell_grid_index1 | Reservoir Cell Index to cell 1 | int32
|
||||
cell_grid_index2 | Reservoir Cell Index to cell 2 | int32
|
||||
cell1 | Reservoir Cell IJK to cell 1 | Vec3i
|
||||
cell2 | Reservoir Cell IJK to cell 1 | Vec3i
|
||||
|
||||
"""
|
||||
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.
|
||||
@@ -1010,6 +1125,7 @@ def nnc_connections_async(self):
|
||||
"""
|
||||
return self.__nnc_properties_stub.GetNNCConnections(self.__request())
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def nnc_connections(self):
|
||||
"""Get the NNC connection. Synchronous, so returns a list.
|
||||
@@ -1024,14 +1140,16 @@ def nnc_connections(self):
|
||||
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)
|
||||
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."""
|
||||
@@ -1041,10 +1159,11 @@ def __nnc_values_generator_to_list(self, generator):
|
||||
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
|
||||
@@ -1054,10 +1173,11 @@ def nnc_connections_static_values_async(self, property_name):
|
||||
"""
|
||||
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
|
||||
@@ -1066,10 +1186,11 @@ def nnc_connections_static_values(self, property_name):
|
||||
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
|
||||
@@ -1079,10 +1200,11 @@ def nnc_connections_dynamic_values_async(self, property_name, time_step):
|
||||
"""
|
||||
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
|
||||
@@ -1091,10 +1213,11 @@ def nnc_connections_dynamic_values(self, property_name, time_step):
|
||||
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
|
||||
@@ -1104,10 +1227,11 @@ def nnc_connections_generated_values_async(self, property_name, time_step):
|
||||
"""
|
||||
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
|
||||
@@ -1116,6 +1240,7 @@ def nnc_connections_generated_values(self, property_name, time_step):
|
||||
generator = self.nnc_connections_generated_values_async(property_name, time_step)
|
||||
return self.__nnc_values_generator_to_list(generator)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __generate_nnc_property_input_chunks(self, array, parameters):
|
||||
index = -1
|
||||
@@ -1135,6 +1260,7 @@ def __generate_nnc_property_input_chunks(self, array, parameters):
|
||||
chunk = NNCProperties_pb2.NNCValuesChunk()
|
||||
yield chunk
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def set_nnc_connections_values(
|
||||
self,
|
||||
|
||||
@@ -7,10 +7,11 @@ from rips.pdmobject import PdmObject, add_method
|
||||
from rips.view import View
|
||||
from rips.generated.pdm_objects import EclipseContourMap, GeoMechContourMap
|
||||
|
||||
|
||||
@add_method(EclipseContourMap)
|
||||
def export_to_text(self, export_file_name='', export_local_coordinates=False, undefined_value_label="NaN", exclude_undefined_values=False):
|
||||
""" Export snapshot for the current view
|
||||
|
||||
|
||||
Arguments:
|
||||
export_file_name(str): The file location to store results in.
|
||||
export_local_coordinates(bool): Should we export local coordinates, or UTM.
|
||||
@@ -25,10 +26,11 @@ def export_to_text(self, export_file_name='', export_local_coordinates=False, un
|
||||
excludeUndefinedValues=exclude_undefined_values,
|
||||
viewId=self.id))
|
||||
|
||||
|
||||
@add_method(GeoMechContourMap)
|
||||
def export_to_text(self, export_file_name='', export_local_coordinates=False, undefined_value_label="NaN", exclude_undefined_values=False):
|
||||
""" Export snapshot for the current view
|
||||
|
||||
|
||||
Arguments:
|
||||
export_file_name(str): The file location to store results in.
|
||||
export_local_coordinates(bool): Should we export local coordinates, or UTM.
|
||||
@@ -42,4 +44,3 @@ def export_to_text(self, export_file_name='', export_local_coordinates=False, un
|
||||
undefinedValueLabel=undefined_value_label,
|
||||
excludeUndefinedValues=exclude_undefined_values,
|
||||
viewId=self.id))
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@ import rips.generated.Grid_pb2_grpc as Grid_pb2_grpc
|
||||
|
||||
|
||||
class Grid:
|
||||
"""Grid Information. Not meant to be constructed separately
|
||||
|
||||
Create Grid objects using methods on Case: Grid() and Grids()
|
||||
"""Grid Information. Created by methods in Case
|
||||
:meth:`rips.case.grid()`
|
||||
:meth:`rips.case.grids()`
|
||||
"""
|
||||
|
||||
def __init__(self, index, case, channel):
|
||||
self.__channel = channel
|
||||
self.__stub = Grid_pb2_grpc.GridStub(self.__channel)
|
||||
@@ -33,7 +34,6 @@ class Grid:
|
||||
Grid_pb2.GridRequest(case_request=case_request,
|
||||
grid_index=self.index)).dimensions
|
||||
|
||||
|
||||
def cell_centers_async(self):
|
||||
"""The cells center for all cells in given grid async.
|
||||
|
||||
|
||||
@@ -9,12 +9,13 @@ from rips.case import Case
|
||||
import rips.generated.Commands_pb2 as Cmd
|
||||
from rips.generated.pdm_objects import GridCaseGroup
|
||||
|
||||
|
||||
@add_method(GridCaseGroup)
|
||||
def create_statistics_case(self):
|
||||
"""Create a Statistics case in the Grid Case Group
|
||||
|
||||
|
||||
Returns:
|
||||
A new Case
|
||||
:class:`rips.generated.pdm_objects.EclipseCase`
|
||||
"""
|
||||
command_reply = self._execute_command(
|
||||
createStatisticsCase=Cmd.CreateStatisticsCaseRequest(
|
||||
@@ -22,28 +23,42 @@ def create_statistics_case(self):
|
||||
return Case(self.channel,
|
||||
command_reply.createStatisticsCaseResult.caseId)
|
||||
|
||||
|
||||
@add_method(GridCaseGroup)
|
||||
def statistics_cases(self):
|
||||
"""Get a list of all statistics cases in the Grid Case Group"""
|
||||
"""Get a list of all statistics cases in the Grid Case Group
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.EclipseCase`
|
||||
|
||||
"""
|
||||
stat_case_collection = self.children("StatisticsCaseCollection")[0]
|
||||
return stat_case_collection.children("Reservoirs")
|
||||
|
||||
|
||||
@add_method(GridCaseGroup)
|
||||
def views(self):
|
||||
"""Get a list of views belonging to a grid case group"""
|
||||
"""Get a list of views belonging to a grid case group
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.EclipseView`
|
||||
|
||||
"""
|
||||
pdm_objects = self.descendants(EclipseView)
|
||||
view_list = []
|
||||
for pdm_object in pdm_objects:
|
||||
view_list.append(pdm_object)
|
||||
return view_list
|
||||
|
||||
|
||||
@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
|
||||
|
||||
Returns: a view object
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.EclipseView`
|
||||
|
||||
"""
|
||||
views = self.views()
|
||||
@@ -52,13 +67,13 @@ def view(self, view_id):
|
||||
return view_object
|
||||
return None
|
||||
|
||||
|
||||
@add_method(GridCaseGroup)
|
||||
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
|
||||
case_ids(list of integers): List of case ids. If this is None all cases in group are included
|
||||
|
||||
"""
|
||||
if case_ids is None:
|
||||
|
||||
@@ -46,7 +46,7 @@ class Instance:
|
||||
options=[
|
||||
('grpc.enable_http_proxy',
|
||||
False)
|
||||
])
|
||||
])
|
||||
app = App_pb2_grpc.AppStub(channel)
|
||||
try:
|
||||
app.GetVersion(Empty(), timeout=1)
|
||||
@@ -91,7 +91,7 @@ class Instance:
|
||||
return None
|
||||
|
||||
print("Trying port " + str(port))
|
||||
while Instance.__is_port_in_use(port):
|
||||
while Instance.__is_port_in_use(port):
|
||||
port += 1
|
||||
print("Trying port " + str(port))
|
||||
|
||||
@@ -266,7 +266,7 @@ class Instance:
|
||||
Set the plot window size in pixels
|
||||
|
||||
**Parameters**::
|
||||
|
||||
|
||||
Parameter | Description | Type
|
||||
--------- | ---------------- | -----
|
||||
width | Width in pixels | Integer
|
||||
|
||||
@@ -17,29 +17,34 @@ import rips.generated.Commands_pb2 as Cmd
|
||||
import rips.generated.Commands_pb2_grpc as CmdRpc
|
||||
from rips.generated.pdm_objects import PdmObject, class_from_keyword
|
||||
|
||||
|
||||
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 snake_to_camel(name):
|
||||
return ''.join(word.title() for word in name.split('_'))
|
||||
|
||||
|
||||
def add_method(cls):
|
||||
def decorator(func):
|
||||
setattr(cls, func.__name__, func)
|
||||
return func # returning func means func can still be used normally
|
||||
return func # returning func means func can still be used normally
|
||||
return decorator
|
||||
|
||||
|
||||
def add_static_method(cls):
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
@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 func # returning func means func can still be used normally
|
||||
return decorator
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def _execute_command(self, **command_params):
|
||||
self.__warnings = []
|
||||
@@ -51,13 +56,14 @@ def _execute_command(self, **command_params):
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __custom_init__(self, pb2_object, channel):
|
||||
self.__warnings = []
|
||||
self.__chunk_size = 8160
|
||||
|
||||
self._channel = channel
|
||||
|
||||
|
||||
# Create stubs
|
||||
if self._channel:
|
||||
self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self._channel)
|
||||
@@ -66,7 +72,7 @@ def __custom_init__(self, pb2_object, channel):
|
||||
if pb2_object is not None:
|
||||
# Copy parameters from ResInsight
|
||||
assert(not isinstance(pb2_object, PdmObject))
|
||||
self._pb2_object = pb2_object
|
||||
self._pb2_object = pb2_object
|
||||
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))
|
||||
@@ -75,6 +81,7 @@ def __custom_init__(self, pb2_object, channel):
|
||||
self._pb2_object = PdmObject_pb2.PdmObject(class_keyword=self.__class__.__name__)
|
||||
self.__copy_to_pb2()
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def copy_from(self, object):
|
||||
"""Copy attribute values from object to self
|
||||
@@ -84,19 +91,22 @@ def copy_from(self, object):
|
||||
value = getattr(object, attribute)
|
||||
# This is crucial to avoid overwriting methods
|
||||
if not callable(value):
|
||||
setattr(self, attribute, value)
|
||||
setattr(self, attribute, value)
|
||||
if self.__custom_init__ is not None:
|
||||
self.__custom_init__(self._pb2_object, self._channel)
|
||||
self.update()
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def warnings(self):
|
||||
return self.__warnings
|
||||
|
||||
@add_method(PdmObject)
|
||||
|
||||
@add_method(PdmObject)
|
||||
def has_warnings(self):
|
||||
return len(self.__warnings) > 0
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __copy_to_pb2(self):
|
||||
if self._pb2_object is not None:
|
||||
@@ -108,16 +118,19 @@ def __copy_to_pb2(self):
|
||||
camel_kw = snake_to_camel(snake_kw)
|
||||
self.__set_grpc_value(camel_kw, value)
|
||||
|
||||
|
||||
@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
|
||||
@@ -128,15 +141,18 @@ def address(self):
|
||||
|
||||
return self._pb2_object.address
|
||||
|
||||
|
||||
@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
|
||||
return self._pb2_object.visible
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def print_object_info(self):
|
||||
@@ -147,11 +163,12 @@ def print_object_info(self):
|
||||
if not snake_kw.startswith("_") and not callable(getattr(self, snake_kw)):
|
||||
camel_kw = snake_to_camel(snake_kw)
|
||||
print(" " + snake_kw + " [" + type(getattr(self, snake_kw)).__name__ +
|
||||
"]: " + str(getattr(self, snake_kw)))
|
||||
"]: " + str(getattr(self, snake_kw)))
|
||||
print("Object Methods:")
|
||||
for snake_kw in dir(self):
|
||||
if not snake_kw.startswith("_") and callable(getattr(self, snake_kw)):
|
||||
print (" " + snake_kw)
|
||||
print(" " + snake_kw)
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __convert_from_grpc_value(self, value):
|
||||
@@ -173,6 +190,7 @@ def __convert_from_grpc_value(self, value):
|
||||
return self.__makelist(value)
|
||||
return value
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __convert_to_grpc_value(self, value):
|
||||
if isinstance(value, bool):
|
||||
@@ -188,14 +206,17 @@ def __convert_to_grpc_value(self, value):
|
||||
return "[" + ", ".join(list_of_strings) + "]"
|
||||
return str(value)
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __get_grpc_value(self, camel_keyword):
|
||||
return self.__convert_from_grpc_value(self._pb2_object.parameters[camel_keyword])
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __set_grpc_value(self, camel_keyword, value):
|
||||
self._pb2_object.parameters[camel_keyword] = self.__convert_to_grpc_value(value)
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def set_value(self, snake_keyword, value):
|
||||
"""Set the value associated with the provided keyword and updates ResInsight
|
||||
@@ -208,10 +229,12 @@ def set_value(self, snake_keyword, value):
|
||||
setattr(self, snake_keyword, value)
|
||||
self.update()
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __islist(self, value):
|
||||
return value.startswith("[") and value.endswith("]")
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __makelist(self, list_string):
|
||||
list_string = list_string.lstrip("[")
|
||||
@@ -222,6 +245,7 @@ def __makelist(self, list_string):
|
||||
values.append(self.__convert_from_grpc_value(string))
|
||||
return values
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __from_pb2_to_pdm_objects(self, pb2_object_list, super_class_definition):
|
||||
pdm_object_list = []
|
||||
@@ -231,9 +255,10 @@ def __from_pb2_to_pdm_objects(self, pb2_object_list, super_class_definition):
|
||||
child_class_definition = super_class_definition
|
||||
|
||||
pdm_object = child_class_definition(pb2_object=pb2_object, channel=self.channel())
|
||||
pdm_object_list.append(pdm_object)
|
||||
pdm_object_list.append(pdm_object)
|
||||
return pdm_object_list
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def descendants(self, class_definition):
|
||||
"""Get a list of all project tree descendants matching the class keyword
|
||||
@@ -254,8 +279,9 @@ def descendants(self, class_definition):
|
||||
return self.__from_pb2_to_pdm_objects(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return [] # Valid empty result
|
||||
raise e
|
||||
return [] # Valid empty result
|
||||
raise e
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def children(self, child_field, class_definition=PdmObject):
|
||||
@@ -275,6 +301,7 @@ def children(self, child_field, class_definition=PdmObject):
|
||||
return []
|
||||
raise e
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def ancestor(self, class_definition):
|
||||
"""Find the first ancestor that matches the provided class_keyword
|
||||
@@ -301,12 +328,14 @@ def ancestor(self, class_definition):
|
||||
return None
|
||||
raise e
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def _call_get_method_async(self, method_name):
|
||||
request = PdmObject_pb2.PdmObjectGetterRequest(object=self._pb2_object, method=method_name)
|
||||
for chunk in self._pdm_object_stub.CallPdmObjectGetter(request):
|
||||
yield chunk
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def _call_get_method(self, method_name):
|
||||
all_values = []
|
||||
@@ -317,6 +346,7 @@ def _call_get_method(self, method_name):
|
||||
all_values.append(value)
|
||||
return all_values
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def __generate_set_method_chunks(self, array, method_request):
|
||||
index = -1
|
||||
@@ -324,22 +354,23 @@ def __generate_set_method_chunks(self, array, method_request):
|
||||
while index < len(array):
|
||||
chunk = PdmObject_pb2.PdmObjectSetterChunk()
|
||||
if index is -1:
|
||||
chunk.set_request.CopyFrom(PdmObject_pb2.PdmObjectSetterRequest(request=method_request, data_count=len(array)))
|
||||
chunk.set_request.CopyFrom(PdmObject_pb2.PdmObjectSetterRequest(
|
||||
request=method_request, data_count=len(array)))
|
||||
index += 1
|
||||
else:
|
||||
actual_chunk_size = min(len(array) - index + 1, self.__chunk_size)
|
||||
if isinstance(array[0], float):
|
||||
chunk.CopyFrom(
|
||||
PdmObject_pb2.PdmObjectSetterChunk(doubles=PdmObject_pb2.DoubleArray(data=array[index:index +
|
||||
actual_chunk_size])))
|
||||
actual_chunk_size])))
|
||||
elif isinstance(array[0], int):
|
||||
chunk.CopyFrom(
|
||||
PdmObject_pb2.PdmObjectSetterChunk(ints=PdmObject_pb2.IntArray(data=array[index:index +
|
||||
actual_chunk_size])))
|
||||
actual_chunk_size])))
|
||||
elif isinstance(array[0], str):
|
||||
chunk.CopyFrom(
|
||||
PdmObject_pb2.PdmObjectSetterChunk(strings=PdmObject_pb2.StringArray(data=array[index:index +
|
||||
actual_chunk_size])))
|
||||
actual_chunk_size])))
|
||||
else:
|
||||
raise Exception("Wrong data type for set method")
|
||||
index += actual_chunk_size
|
||||
@@ -348,20 +379,24 @@ def __generate_set_method_chunks(self, array, method_request):
|
||||
chunk = PdmObject_pb2.PdmObjectSetterChunk()
|
||||
yield chunk
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def _call_set_method(self, method_name, values):
|
||||
method_request = PdmObject_pb2.PdmObjectGetterRequest(object=self._pb2_object, method=method_name)
|
||||
method_request = PdmObject_pb2.PdmObjectGetterRequest(
|
||||
object=self._pb2_object, method=method_name)
|
||||
request_iterator = self.__generate_set_method_chunks(values, method_request)
|
||||
reply = self._pdm_object_stub.CallPdmObjectSetter(request_iterator)
|
||||
if reply.accepted_value_count < len(values):
|
||||
raise IndexError
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def _call_pdm_method(self, method_name, **kwargs):
|
||||
pb2_params = PdmObject_pb2.PdmObject(class_keyword=method_name)
|
||||
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)
|
||||
request = PdmObject_pb2.PdmObjectMethodRequest(
|
||||
object=self._pb2_object, method=method_name, params=pb2_params)
|
||||
|
||||
pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request)
|
||||
|
||||
@@ -372,6 +407,7 @@ def _call_pdm_method(self, method_name, **kwargs):
|
||||
pdm_object = child_class_definition(pb2_object=pb2_object, channel=self.channel())
|
||||
return pdm_object
|
||||
|
||||
|
||||
@add_method(PdmObject)
|
||||
def update(self):
|
||||
"""Sync all fields from the Python Object to ResInsight"""
|
||||
|
||||
@@ -7,21 +7,20 @@ from rips.pdmobject import PdmObject
|
||||
from rips.generated.pdm_objects import PlotWindow, Plot
|
||||
from rips.pdmobject import add_method
|
||||
|
||||
|
||||
@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'.
|
||||
|
||||
|
||||
"""
|
||||
return self._execute_command(
|
||||
exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS',
|
||||
prefix=file_prefix,
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
plotOutputFormat=output_format))
|
||||
|
||||
|
||||
prefix=file_prefix,
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
plotOutputFormat=output_format))
|
||||
|
||||
@@ -24,12 +24,14 @@ from rips.generated.pdm_objects import Project, PlotWindow, WellPath
|
||||
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
|
||||
@@ -40,21 +42,25 @@ def open(self, path):
|
||||
"""
|
||||
self._execute_command(openProject=Cmd.FilePathRequest(path=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
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def close(self):
|
||||
"""Close the current project (and open new blank project)"""
|
||||
self._execute_command(closeProject=Empty())
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def load_case(self, path):
|
||||
"""Load a new case from the given file path
|
||||
@@ -62,18 +68,19 @@ def load_case(self, path):
|
||||
Arguments:
|
||||
path(str): file path to case
|
||||
Returns:
|
||||
A rips Case object
|
||||
:class:`rips.generated.pdm_objects.Case`
|
||||
"""
|
||||
command_reply = self._execute_command(loadCase=Cmd.FilePathRequest(
|
||||
path=path))
|
||||
return self.case(command_reply.loadCaseResult.id)
|
||||
|
||||
|
||||
@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
|
||||
A list of :class:`rips.generated.pdm_objects.Case`
|
||||
"""
|
||||
case_infos = self._project_stub.GetSelectedCases(Empty())
|
||||
cases = []
|
||||
@@ -81,15 +88,17 @@ def selected_cases(self):
|
||||
cases.append(self.case(case_info.id))
|
||||
return cases
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def cases(self):
|
||||
"""Get a list of all cases in the project
|
||||
|
||||
Returns:
|
||||
A list of rips Case objects
|
||||
A list of :class:`rips.generated.pdm_objects.Case`
|
||||
"""
|
||||
return self.descendants(Case)
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def case(self, case_id):
|
||||
"""Get a specific case from the provided case Id
|
||||
@@ -97,7 +106,7 @@ def case(self, case_id):
|
||||
Arguments:
|
||||
id(int): case id
|
||||
Returns:
|
||||
A rips Case object
|
||||
:class:`rips.generated.pdm_objects.Case`
|
||||
"""
|
||||
allCases = self.cases()
|
||||
for case in allCases:
|
||||
@@ -105,10 +114,11 @@ def case(self, case_id):
|
||||
return case
|
||||
return None
|
||||
|
||||
|
||||
@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
|
||||
@@ -117,14 +127,15 @@ def replace_source_cases(self, grid_list_file, case_group_id=0):
|
||||
replaceSourceCases=Cmd.ReplaceSourceCasesRequest(
|
||||
gridListFile=grid_list_file, caseGroupId=case_group_id))
|
||||
|
||||
|
||||
@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
|
||||
:class:`rips.generated.pdm_objects.GridCaseGroup`
|
||||
"""
|
||||
command_reply = self._execute_command(
|
||||
createGridCaseGroup=Cmd.CreateGridCaseGroupRequest(
|
||||
@@ -132,18 +143,21 @@ def create_grid_case_group(self, case_paths):
|
||||
return self.grid_case_group(
|
||||
command_reply.createGridCaseGroupResult.groupId)
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def views(self):
|
||||
"""Get a list of views belonging to a project"""
|
||||
return self.descendants(View)
|
||||
|
||||
|
||||
@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
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.View`
|
||||
"""
|
||||
views = self.views()
|
||||
for view_object in views:
|
||||
@@ -151,9 +165,14 @@ def view(self, view_id):
|
||||
return view_object
|
||||
return None
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def plots(self):
|
||||
"""Get a list of all plots belonging to a project"""
|
||||
"""Get a list of all plots belonging to a project
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.Plot`
|
||||
"""
|
||||
pdm_objects = self.descendants(PlotWindow)
|
||||
plot_list = []
|
||||
for pdm_object in pdm_objects:
|
||||
@@ -161,12 +180,16 @@ def plots(self):
|
||||
plot_list.append(pdm_object)
|
||||
return plot_list
|
||||
|
||||
|
||||
@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
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.Plot`
|
||||
"""
|
||||
plots = self.plots()
|
||||
for plot_object in plots:
|
||||
@@ -174,20 +197,28 @@ def plot(self, view_id):
|
||||
return plot_object
|
||||
return None
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def grid_case_groups(self):
|
||||
"""Get a list of all grid case groups in the project"""
|
||||
"""Get a list of all grid case groups in the project
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.GridCaseGroup`
|
||||
|
||||
"""
|
||||
case_groups = self.descendants(GridCaseGroup)
|
||||
return case_groups
|
||||
|
||||
|
||||
@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
|
||||
|
||||
Returns: a grid case group object
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.GridCaseGroup`
|
||||
"""
|
||||
case_groups = self.grid_case_groups()
|
||||
for case_group in case_groups:
|
||||
@@ -195,10 +226,11 @@ def grid_case_group(self, group_id):
|
||||
return case_group
|
||||
return None
|
||||
|
||||
|
||||
@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
|
||||
"""
|
||||
@@ -206,10 +238,11 @@ def export_multi_case_snapshots(self, grid_list_file):
|
||||
exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest(
|
||||
gridListFile=grid_list_file))
|
||||
|
||||
|
||||
@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
|
||||
@@ -219,10 +252,11 @@ def export_snapshots(self, snapshot_type='ALL', prefix='', plot_format='PNG'):
|
||||
exportSnapshots=Cmd.ExportSnapshotsRequest(
|
||||
type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1, plotOutputFormat=plot_format))
|
||||
|
||||
|
||||
@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
|
||||
@@ -234,11 +268,12 @@ def export_well_paths(self, well_paths=None, md_step_size=5.0):
|
||||
return self._execute_command(exportWellPaths=Cmd.ExportWellPathRequest(
|
||||
wellPathNames=well_paths, mdStepSize=md_step_size))
|
||||
|
||||
|
||||
@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
|
||||
@@ -254,10 +289,11 @@ def scale_fracture_template(self, template_id, half_length, height,
|
||||
dFactor=d_factor,
|
||||
conductivity=conductivity))
|
||||
|
||||
|
||||
@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
|
||||
@@ -267,6 +303,7 @@ def set_fracture_containment(self, template_id, top_layer, base_layer):
|
||||
setFractureContainment=Cmd.SetFracContainmentRequest(
|
||||
id=template_id, topLayer=top_layer, baseLayer=base_layer))
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def import_well_paths(self, well_path_files=None, well_path_folder=''):
|
||||
""" Import well paths into project
|
||||
@@ -276,33 +313,35 @@ 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 WellPath objects
|
||||
List of :class:`rips.generated.pdm_objects.WellPath`
|
||||
"""
|
||||
if well_path_files is None:
|
||||
well_path_files = []
|
||||
|
||||
|
||||
res = self._execute_command(importWellPaths=Cmd.ImportWellPathsRequest(wellPathFolder=well_path_folder,
|
||||
wellPathFiles=well_path_files))
|
||||
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
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def well_paths(self):
|
||||
"""Get a list of all well paths in the project
|
||||
|
||||
Returns:
|
||||
A list of rips WellPath objects
|
||||
List of :class:`rips.generated.pdm_objects.WellPath`
|
||||
"""
|
||||
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 WellPath object
|
||||
:class:`rips.generated.pdm_objects.WellPath`
|
||||
"""
|
||||
all_well_paths = self.well_paths()
|
||||
for well_path in all_well_paths:
|
||||
@@ -310,6 +349,7 @@ def well_path_by_name(self, well_path_name):
|
||||
return well_path
|
||||
return None
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def import_well_log_files(self, well_log_files=None, well_log_folder=''):
|
||||
""" Import well log files into project
|
||||
@@ -325,9 +365,10 @@ def import_well_log_files(self, well_log_files=None, well_log_folder=''):
|
||||
if well_log_files is None:
|
||||
well_log_files = []
|
||||
res = self._execute_command(importWellLogFiles=Cmd.ImportWellLogFilesRequest(wellLogFolder=well_log_folder,
|
||||
wellLogFiles=well_log_files))
|
||||
wellLogFiles=well_log_files))
|
||||
return res.importWellLogFilesResult.wellPathNames
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
def import_formation_names(self, formation_files=None):
|
||||
""" Import formation names into project
|
||||
@@ -342,5 +383,4 @@ def import_formation_names(self, formation_files=None):
|
||||
formation_files = [formation_files]
|
||||
|
||||
self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
applyToCaseId=-1))
|
||||
|
||||
applyToCaseId=-1))
|
||||
|
||||
@@ -15,24 +15,60 @@ from rips.generated.pdm_objects import SimulationWell
|
||||
from rips.pdmobject import PdmObject, add_method
|
||||
import rips.case
|
||||
|
||||
|
||||
@add_method(SimulationWell)
|
||||
def __custom_init__(self, pb2_object, channel):
|
||||
self._simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(channel)
|
||||
|
||||
|
||||
@add_method(SimulationWell)
|
||||
def status(self, timestep):
|
||||
"""Get simulation well status
|
||||
|
||||
**SimulationWellStatus class description**::
|
||||
|
||||
Parameter | Description | Type
|
||||
----------- | ------------------------------------------------------------- | -----
|
||||
well_type | Well type as string | string
|
||||
is_open | True if simulation well is open at the specified time step | bool
|
||||
|
||||
Arguments:
|
||||
timestep(int): Time step index
|
||||
|
||||
"""
|
||||
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)
|
||||
|
||||
|
||||
@add_method(SimulationWell)
|
||||
def cells(self, timestep):
|
||||
"""Get reservoir cells the simulation well is defined for
|
||||
|
||||
**SimulationWellCellInfo class description**::
|
||||
|
||||
Parameter | Description | Type
|
||||
----------- | --------------------------------------------------------- | -----
|
||||
ijk | Cell IJK location | Vec3i
|
||||
grid_index | Grid index | int
|
||||
is_open | True if connection to is open at the specified time step | bool
|
||||
branch_id | | int
|
||||
segment_id | | int
|
||||
|
||||
Arguments:
|
||||
timestep(int): Time step index
|
||||
|
||||
Returns:
|
||||
List of SimulationWellCellInfo
|
||||
|
||||
"""
|
||||
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)
|
||||
|
||||
@@ -8,19 +8,25 @@ import rips
|
||||
|
||||
_rips_instance = None
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def rips_instance():
|
||||
return _rips_instance
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def initialize_test():
|
||||
_rips_instance.project.close() # make sure ResInsight is clean before execution of test
|
||||
_rips_instance.project.close() # make sure ResInsight is clean before execution of test
|
||||
yield initialize_test
|
||||
_rips_instance.project.close() # make sure ResInsight is clean after test
|
||||
_rips_instance.project.close() # make sure ResInsight is clean after test
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption("--console", action="store_true", default=False, help="Run as console application")
|
||||
parser.addoption("--existing", action="store_true", default=False, help="Look for existing ResInsight")
|
||||
parser.addoption("--console", action="store_true", default=False,
|
||||
help="Run as console application")
|
||||
parser.addoption("--existing", action="store_true", default=False,
|
||||
help="Look for existing ResInsight")
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
global _rips_instance
|
||||
@@ -36,6 +42,7 @@ def pytest_configure(config):
|
||||
print("Need a valid ResInsight executable to launch tests")
|
||||
exit(0)
|
||||
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
if not config.getoption('--existing'):
|
||||
_rips_instance.exit()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
import os
|
||||
import math
|
||||
import pytest
|
||||
import pytest
|
||||
import grpc
|
||||
import tempfile
|
||||
|
||||
@@ -10,22 +10,28 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_Launch(rips_instance, initialize_test):
|
||||
assert(rips_instance is not None)
|
||||
|
||||
|
||||
def test_EmptyProject(rips_instance, initialize_test):
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 0)
|
||||
|
||||
|
||||
def test_OneCase(rips_instance, initialize_test):
|
||||
case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
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.id == 0)
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
|
||||
|
||||
def test_BoundingBox(rips_instance, initialize_test):
|
||||
case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
case = rips_instance.project.load_case(
|
||||
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
assert(case.name == "TEST10K_FLT_LGR_NNC")
|
||||
boundingbox = case.reservoir_boundingbox()
|
||||
assert(math.isclose(3382.90, boundingbox.min_x, abs_tol=1.0e-1))
|
||||
@@ -39,12 +45,13 @@ def test_BoundingBox(rips_instance, initialize_test):
|
||||
assert(math.isclose(4103.60, min_depth, abs_tol=1.0e-1))
|
||||
assert(math.isclose(4252.61, max_depth, abs_tol=1.0e-1))
|
||||
|
||||
|
||||
def test_MultipleCases(rips_instance, initialize_test):
|
||||
case_paths = []
|
||||
case_paths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
case_paths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
case_paths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
|
||||
|
||||
case_names = []
|
||||
for case_path in case_paths:
|
||||
case_name = os.path.splitext(os.path.basename(case_path))[0]
|
||||
@@ -56,17 +63,20 @@ def test_MultipleCases(rips_instance, initialize_test):
|
||||
for i, case_name in enumerate(case_names):
|
||||
assert(case_name == cases[i].name)
|
||||
|
||||
|
||||
def get_cell_index_with_ijk(cell_info, i, j, k):
|
||||
for (idx, cell) in enumerate(cell_info):
|
||||
if cell.local_ijk.i == i and cell.local_ijk.j == j and cell.local_ijk.k == k:
|
||||
return idx
|
||||
return -1
|
||||
|
||||
|
||||
def check_corner(actual, expected):
|
||||
assert(math.isclose(actual.x, expected[0], abs_tol=0.1))
|
||||
assert(math.isclose(actual.y, expected[1], abs_tol=0.1))
|
||||
assert(math.isclose(actual.z, expected[2], abs_tol=0.1))
|
||||
|
||||
|
||||
def test_10k(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)
|
||||
@@ -96,14 +106,14 @@ def test_10k(rips_instance, initialize_test):
|
||||
cell_corners = case.active_cell_corners()
|
||||
assert(len(cell_corners) == cell_count_info.active_cell_count)
|
||||
# Expected values from ResInsight UI
|
||||
expected_corners = [[ 3565.22, 5179.02, 4177.18],
|
||||
[ 3655.67, 5145.34, 4176.63],
|
||||
[ 3690.07, 5240.69, 4180.02],
|
||||
[ 3599.87, 5275.16, 4179.32],
|
||||
[ 3564.13, 5178.61, 4179.75],
|
||||
[ 3654.78, 5144.79, 4179.23],
|
||||
[ 3688.99, 5239.88, 4182.7],
|
||||
[ 3598.62, 5274.48, 4181.96]]
|
||||
expected_corners = [[3565.22, 5179.02, 4177.18],
|
||||
[3655.67, 5145.34, 4176.63],
|
||||
[3690.07, 5240.69, 4180.02],
|
||||
[3599.87, 5275.16, 4179.32],
|
||||
[3564.13, 5178.61, 4179.75],
|
||||
[3654.78, 5144.79, 4179.23],
|
||||
[3688.99, 5239.88, 4182.7],
|
||||
[3598.62, 5274.48, 4181.96]]
|
||||
check_corner(cell_corners[cell_index].c0, expected_corners[0])
|
||||
check_corner(cell_corners[cell_index].c1, expected_corners[1])
|
||||
check_corner(cell_corners[cell_index].c2, expected_corners[2])
|
||||
@@ -117,6 +127,7 @@ def test_10k(rips_instance, initialize_test):
|
||||
coarsening_info = case.coarsening_info()
|
||||
assert(len(coarsening_info) == 0)
|
||||
|
||||
|
||||
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)
|
||||
@@ -124,6 +135,7 @@ def test_PdmObject(rips_instance, initialize_test):
|
||||
assert(case.address() is not 0)
|
||||
assert(case.__class__.__name__ == "EclipseCase")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
def test_brugge_0010(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"
|
||||
@@ -137,6 +149,7 @@ def test_brugge_0010(rips_instance, initialize_test):
|
||||
days_since_start = case.days_since_start()
|
||||
assert(len(days_since_start) == 11)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
def test_replaceCase(rips_instance, initialize_test):
|
||||
project = rips_instance.project.open(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp")
|
||||
@@ -159,12 +172,14 @@ def test_replaceCase(rips_instance, initialize_test):
|
||||
case = project.case(case_id=0)
|
||||
assert(case.name == "Real0--BRUGGE_0000.EGRID")
|
||||
assert(case.id == 0)
|
||||
|
||||
|
||||
|
||||
def test_loadNonExistingCase(rips_instance, initialize_test):
|
||||
case_path = "Nonsense/Nonsense/Nonsense"
|
||||
with pytest.raises(grpc.RpcError):
|
||||
assert rips_instance.project.load_case(case_path)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
def test_exportFlowCharacteristics(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"
|
||||
@@ -172,10 +187,13 @@ def test_exportFlowCharacteristics(rips_instance, initialize_test):
|
||||
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
print("Temporary folder: ", tmpdirname)
|
||||
file_name = tmpdirname + "/exportFlowChar.txt"
|
||||
case.export_flow_characteristics(time_steps=8, producers=[], injectors = "I01", file_name = file_name)
|
||||
case.export_flow_characteristics(time_steps=8, producers=[],
|
||||
injectors="I01", file_name=file_name)
|
||||
|
||||
|
||||
def test_selected_cells(rips_instance, initialize_test):
|
||||
case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
case = rips_instance.project.load_case(
|
||||
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
assert(case.name == "TEST10K_FLT_LGR_NNC")
|
||||
selected_cells = case.selected_cells()
|
||||
assert(len(selected_cells) == 0)
|
||||
|
||||
@@ -8,4 +8,3 @@ sys.path.insert(1, os.path.join(sys.path[0], '../../'))
|
||||
import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def check_corner(actual, expected):
|
||||
assert(math.isclose(actual.x, expected[0], abs_tol=0.1))
|
||||
assert(math.isclose(actual.y, expected[1], abs_tol=0.1))
|
||||
assert(math.isclose(actual.z, expected[2], abs_tol=0.1))
|
||||
|
||||
|
||||
def test_10k(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -35,14 +37,14 @@ def test_10k(rips_instance, initialize_test):
|
||||
assert(len(cell_corners) == (dimensions.i * dimensions.j * dimensions.k))
|
||||
|
||||
# Expected values from ResInsight UI
|
||||
expected_corners = [[ 3565.22, 5179.02, 4177.18],
|
||||
[ 3655.67, 5145.34, 4176.63],
|
||||
[ 3690.07, 5240.69, 4180.02],
|
||||
[ 3599.87, 5275.16, 4179.32],
|
||||
[ 3564.13, 5178.61, 4179.75],
|
||||
[ 3654.78, 5144.79, 4179.23],
|
||||
[ 3688.99, 5239.88, 4182.7],
|
||||
[ 3598.62, 5274.48, 4181.96]]
|
||||
expected_corners = [[3565.22, 5179.02, 4177.18],
|
||||
[3655.67, 5145.34, 4176.63],
|
||||
[3690.07, 5240.69, 4180.02],
|
||||
[3599.87, 5275.16, 4179.32],
|
||||
[3564.13, 5178.61, 4179.75],
|
||||
[3654.78, 5144.79, 4179.23],
|
||||
[3688.99, 5239.88, 4182.7],
|
||||
[3598.62, 5274.48, 4181.96]]
|
||||
check_corner(cell_corners[cell_index].c0, expected_corners[0])
|
||||
check_corner(cell_corners[cell_index].c1, expected_corners[1])
|
||||
check_corner(cell_corners[cell_index].c2, expected_corners[2])
|
||||
|
||||
@@ -68,6 +68,7 @@ def test_10kSync(rips_instance, initialize_test):
|
||||
for i in range(0, len(new_data)):
|
||||
assert(new_data[i] == new_prop_vals[i])
|
||||
|
||||
|
||||
def test_non_existing_dynamic_values(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -75,6 +76,7 @@ def test_non_existing_dynamic_values(rips_instance, initialize_test):
|
||||
with pytest.raises(grpc.RpcError):
|
||||
case.nnc_connections_dynamic_values("x", 0)
|
||||
|
||||
|
||||
def test_invalid_time_steps(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
@@ -9,6 +9,7 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_loadProject(rips_instance, initialize_test):
|
||||
project = rips_instance.project.open(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp")
|
||||
case = project.cases()[0]
|
||||
@@ -18,6 +19,7 @@ def test_loadProject(rips_instance, initialize_test):
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
|
||||
|
||||
def test_well_log_plots(rips_instance, initialize_test):
|
||||
project = rips_instance.project.open(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp")
|
||||
plots = project.plots()
|
||||
@@ -36,24 +38,26 @@ def test_well_log_plots(rips_instance, initialize_test):
|
||||
well_log_plot.export_snapshot(tmpdirname)
|
||||
well_log_plot.export_data_as_las(tmpdirname)
|
||||
files = os.listdir(tmpdirname)
|
||||
print (files)
|
||||
print(files)
|
||||
if rips_instance.is_gui():
|
||||
assert(len(files) == 4)
|
||||
else:
|
||||
assert(len(files) == 2)
|
||||
|
||||
|
||||
plots2 = project.plots()
|
||||
for plot2 in plots2:
|
||||
for plot2 in plots2:
|
||||
if isinstance(plot2, rips.WellLogPlot):
|
||||
assert(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):
|
||||
case_paths = []
|
||||
case_paths.append(dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
|
||||
case_paths.append(dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
|
||||
grid_case_group = rips_instance.project.create_grid_case_group(case_paths=case_paths)
|
||||
assert(grid_case_group is not None and grid_case_group.group_id == 0)
|
||||
case_paths = []
|
||||
case_paths.append(dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
|
||||
case_paths.append(dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
|
||||
grid_case_group = rips_instance.project.create_grid_case_group(case_paths=case_paths)
|
||||
assert(grid_case_group is not None and grid_case_group.group_id == 0)
|
||||
|
||||
|
||||
def test_exportSnapshots(rips_instance, initialize_test):
|
||||
if not rips_instance.is_gui():
|
||||
|
||||
@@ -9,6 +9,7 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_10kAsync(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -24,6 +25,7 @@ def test_10kAsync(rips_instance, initialize_test):
|
||||
assert(average != pytest.approx(0.0158893, abs=0.0000001))
|
||||
assert(average == pytest.approx(0.0558893, abs=0.0000001))
|
||||
|
||||
|
||||
def test_10kSync(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -35,6 +37,7 @@ def test_10kSync(rips_instance, initialize_test):
|
||||
assert(average != pytest.approx(0.0158893, abs=0.0000001))
|
||||
assert(average == pytest.approx(0.0558893, abs=0.0000001))
|
||||
|
||||
|
||||
def test_10k_set(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -42,6 +45,7 @@ def test_10k_set(rips_instance, initialize_test):
|
||||
results = case.active_cell_property('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
case.set_active_cell_property(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
|
||||
def test_10k_set_out_of_bounds(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -51,6 +55,7 @@ def test_10k_set_out_of_bounds(rips_instance, initialize_test):
|
||||
with pytest.raises(grpc.RpcError):
|
||||
assert case.set_active_cell_property(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
|
||||
def test_10k_set_out_of_bounds_client(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
@@ -61,6 +66,7 @@ def test_10k_set_out_of_bounds_client(rips_instance, initialize_test):
|
||||
with pytest.raises(IndexError):
|
||||
assert case.set_active_cell_property(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
|
||||
def createResult(poroChunks, permxChunks):
|
||||
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
|
||||
resultChunk = []
|
||||
@@ -68,10 +74,12 @@ def createResult(poroChunks, permxChunks):
|
||||
resultChunk.append(poro * permx)
|
||||
yield resultChunk
|
||||
|
||||
|
||||
def checkResults(poroValues, permxValues, poropermxValues):
|
||||
for (poro, permx, poropermx) in zip(poroValues, permxValues, poropermxValues):
|
||||
recalc = poro * permx
|
||||
assert(recalc == pytest.approx(poropermx, rel=1.0e-10))
|
||||
recalc = poro * permx
|
||||
assert(recalc == pytest.approx(poropermx, rel=1.0e-10))
|
||||
|
||||
|
||||
def test_10k_PoroPermX(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
@@ -80,7 +88,8 @@ def test_10k_PoroPermX(rips_instance, initialize_test):
|
||||
poroChunks = case.active_cell_property_async('STATIC_NATIVE', 'PORO', 0)
|
||||
permxChunks = case.active_cell_property_async('STATIC_NATIVE', 'PERMX', 0)
|
||||
|
||||
case.set_active_cell_property_async(createResult(poroChunks, permxChunks), 'GENERATED', 'POROPERMXAS', 0)
|
||||
case.set_active_cell_property_async(createResult(
|
||||
poroChunks, permxChunks), 'GENERATED', 'POROPERMXAS', 0)
|
||||
|
||||
poro = case.active_cell_property('STATIC_NATIVE', 'PORO', 0)
|
||||
permx = case.active_cell_property('STATIC_NATIVE', 'PERMX', 0)
|
||||
@@ -88,6 +97,7 @@ def test_10k_PoroPermX(rips_instance, initialize_test):
|
||||
|
||||
checkResults(poro, permx, poroPermX)
|
||||
|
||||
|
||||
def test_exportPropertyInView(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
rips_instance.project.load_case(case_path)
|
||||
@@ -99,4 +109,4 @@ def test_exportPropertyInView(rips_instance, initialize_test):
|
||||
view.export_property()
|
||||
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
|
||||
full_path = tmpdirname + "/" + expected_file_name
|
||||
assert(os.path.exists(full_path))
|
||||
assert(os.path.exists(full_path))
|
||||
|
||||
@@ -6,6 +6,7 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_10k(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)
|
||||
@@ -28,7 +29,7 @@ def test_10k(rips_instance, initialize_test):
|
||||
|
||||
# On time step 3 all wells are producing
|
||||
for sim_well in sim_wells:
|
||||
status = sim_well.status(3)
|
||||
status = sim_well.status(3)
|
||||
assert(status.well_type == "Producer")
|
||||
|
||||
# On time step 0 all simulation wells have no cells
|
||||
@@ -45,5 +46,6 @@ def test_10k(rips_instance, initialize_test):
|
||||
for (tidx, timestep) in enumerate(timesteps):
|
||||
if (tidx > 0):
|
||||
cells = sim_well.cells(tidx)
|
||||
print("well: " + sim_well.name + " timestep: " + str(tidx) + " cells:" + str(len(cells)))
|
||||
print("well: " + sim_well.name + " timestep: " +
|
||||
str(tidx) + " cells:" + str(len(cells)))
|
||||
assert(len(cells) == expected_cell_count[sim_well.name])
|
||||
|
||||
@@ -7,6 +7,7 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_summary_import_and_find(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC"
|
||||
summary_case = rips_instance.project.import_summary_case(casePath)
|
||||
@@ -37,6 +38,7 @@ def test_summary_data(rips_instance, initialize_test):
|
||||
summary_data = summary_case.summary_vector_values("FOPT")
|
||||
assert(len(summary_data.values) == 60)
|
||||
|
||||
|
||||
def test_summary_resample(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC"
|
||||
summary_case = rips_instance.project.import_summary_case(casePath)
|
||||
|
||||
@@ -6,6 +6,7 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
|
||||
def test_10k(rips_instance, initialize_test):
|
||||
case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
|
||||
case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
|
||||
@@ -9,6 +9,7 @@ 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 apply_cell_result(self, result_type, result_variable):
|
||||
"""Apply a regular cell result
|
||||
@@ -30,6 +31,7 @@ def apply_cell_result(self, result_type, result_variable):
|
||||
cell_result.result_variable = result_variable
|
||||
cell_result.update()
|
||||
|
||||
|
||||
@add_method(View)
|
||||
def apply_flow_diagnostics_cell_result(
|
||||
self,
|
||||
@@ -71,6 +73,7 @@ def apply_flow_diagnostics_cell_result(
|
||||
cell_result.selected_producer_tracers = producers
|
||||
cell_result.update()
|
||||
|
||||
|
||||
@add_method(View)
|
||||
def clone(self):
|
||||
"""Clone the current view"""
|
||||
@@ -78,6 +81,7 @@ def clone(self):
|
||||
viewId=self.id)).createViewResult.viewId
|
||||
return self.case().view(view_id)
|
||||
|
||||
|
||||
@add_method(View)
|
||||
def set_time_step(self, time_step):
|
||||
"""Set the time step for current view"""
|
||||
@@ -85,10 +89,11 @@ def set_time_step(self, time_step):
|
||||
return self._execute_command(setTimeStep=Cmd.SetTimeStepParams(
|
||||
caseId=case_id, viewId=self.id, timeStep=time_step))
|
||||
|
||||
|
||||
@add_method(View)
|
||||
def export_sim_well_fracture_completions(self, time_step,
|
||||
simulation_well_names, file_split,
|
||||
compdat_export):
|
||||
simulation_well_names, file_split,
|
||||
compdat_export):
|
||||
"""Export fracture completions for simulation wells
|
||||
|
||||
**Parameters**::
|
||||
@@ -129,12 +134,13 @@ def export_sim_well_fracture_completions(self, time_step,
|
||||
fileSplit=file_split,
|
||||
compdatExport=compdat_export))
|
||||
|
||||
|
||||
@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_keyword='FLUXNUM',
|
||||
visible_active_cells_value=1,
|
||||
hidden_active_cells_value=0,
|
||||
inactive_cells_value=0):
|
||||
"""Export special properties for all visible cells.
|
||||
|
||||
Arguments:
|
||||
@@ -154,6 +160,7 @@ def export_visible_cells(self,
|
||||
hiddenActiveCellsValue=hidden_active_cells_value,
|
||||
inactiveCellsValue=inactive_cells_value))
|
||||
|
||||
|
||||
@add_method(View)
|
||||
def export_property(self, undefined_value=0.0):
|
||||
""" Export the current Eclipse property from the view
|
||||
@@ -168,6 +175,7 @@ def export_property(self, undefined_value=0.0):
|
||||
viewIds=[self.id],
|
||||
undefinedValue=undefined_value))
|
||||
|
||||
|
||||
@add_method(ViewWindow)
|
||||
def case(self):
|
||||
"""Get the case the view belongs to"""
|
||||
@@ -175,10 +183,11 @@ def case(self):
|
||||
assert(mycase is not None)
|
||||
return mycase
|
||||
|
||||
|
||||
@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
|
||||
@@ -186,7 +195,7 @@ def export_snapshot(self, prefix='', 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))
|
||||
prefix=prefix,
|
||||
caseId=case_id,
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder))
|
||||
|
||||
@@ -9,47 +9,49 @@ from rips.pdmobject import PdmObject
|
||||
from rips.generated.pdm_objects import WellLogPlot
|
||||
from rips.pdmobject import add_method
|
||||
|
||||
|
||||
@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))
|
||||
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
|
||||
"""
|
||||
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))
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
filePrefix=file_prefix,
|
||||
exportTvdRkb=False,
|
||||
capitalizeFileNames=capitalize_file_names,
|
||||
resampleInterval=0.0))
|
||||
return res.exportWellLogPlotDataResult.exportedFiles
|
||||
|
||||
Reference in New Issue
Block a user