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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user