2019-09-23 04:50:33 -05:00
|
|
|
"""
|
|
|
|
Grid Case Group statistics module
|
|
|
|
"""
|
|
|
|
|
2020-08-19 00:30:51 -05:00
|
|
|
from .pdmobject import add_method
|
2020-08-21 15:43:48 -05:00
|
|
|
from .view import View
|
|
|
|
from .case import Case
|
2019-09-23 04:50:33 -05:00
|
|
|
|
2020-08-19 00:30:51 -05:00
|
|
|
import Commands_pb2
|
2021-01-21 03:45:37 -06:00
|
|
|
from .resinsight_classes import GridCaseGroup
|
2023-02-05 02:31:22 -06:00
|
|
|
from .resinsight_classes import EclipseView
|
2020-02-21 05:10:02 -06:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
@add_method(GridCaseGroup)
|
|
|
|
def create_statistics_case(self):
|
|
|
|
"""Create a Statistics case in the Grid Case Group
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
Returns:
|
2021-01-21 03:45:37 -06:00
|
|
|
:class:`rips.generated.generated_classes.EclipseCase`
|
2019-09-23 04:50:33 -05:00
|
|
|
"""
|
2020-02-21 05:10:02 -06:00
|
|
|
command_reply = self._execute_command(
|
2020-08-19 00:30:51 -05:00
|
|
|
createStatisticsCase=Commands_pb2.CreateStatisticsCaseRequest(
|
2021-01-26 13:48:01 -06:00
|
|
|
caseGroupId=self.group_id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return Case(self.channel, command_reply.createStatisticsCaseResult.caseId)
|
2020-02-21 05:10:02 -06:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
@add_method(GridCaseGroup)
|
|
|
|
def statistics_cases(self):
|
2020-04-16 09:06:18 -05:00
|
|
|
"""Get a list of all statistics cases in the Grid Case Group
|
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
Returns:
|
2021-01-21 03:45:37 -06:00
|
|
|
List of :class:`rips.generated.generated_classes.EclipseCase`
|
2020-04-16 09:06:18 -05:00
|
|
|
|
|
|
|
"""
|
2020-02-21 05:10:02 -06:00
|
|
|
stat_case_collection = self.children("StatisticsCaseCollection")[0]
|
|
|
|
return stat_case_collection.children("Reservoirs")
|
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
@add_method(GridCaseGroup)
|
|
|
|
def views(self):
|
2020-04-16 09:06:18 -05:00
|
|
|
"""Get a list of views belonging to a grid case group
|
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
Returns:
|
2021-01-21 03:45:37 -06:00
|
|
|
List of :class:`rips.generated.generated_classes.EclipseView`
|
2020-04-16 09:06:18 -05:00
|
|
|
|
|
|
|
"""
|
2021-01-21 11:48:59 -06:00
|
|
|
resinsight_classes = self.descendants(EclipseView)
|
2020-02-21 05:10:02 -06:00
|
|
|
view_list = []
|
2021-01-21 11:48:59 -06:00
|
|
|
for pdm_object in resinsight_classes:
|
2020-02-21 05:10:02 -06:00
|
|
|
view_list.append(pdm_object)
|
|
|
|
return view_list
|
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
@add_method(GridCaseGroup)
|
|
|
|
def view(self, view_id):
|
|
|
|
"""Get a particular view belonging to a case group by providing view id
|
2021-05-04 07:49:05 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
Arguments:
|
|
|
|
id(int): view id
|
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
Returns:
|
2021-01-21 03:45:37 -06:00
|
|
|
List of :class:`rips.generated.generated_classes.EclipseView`
|
2019-09-23 04:50:33 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
"""
|
|
|
|
views = self.views()
|
|
|
|
for view_object in views:
|
|
|
|
if view_object.id == view_id:
|
|
|
|
return view_object
|
|
|
|
return None
|
2019-09-23 04:50:33 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
@add_method(GridCaseGroup)
|
|
|
|
def compute_statistics(self, case_ids=None):
|
2021-01-26 13:48:01 -06:00
|
|
|
"""Compute statistics for the given case ids
|
2019-09-23 04:50:33 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
Arguments:
|
2020-04-16 09:06:18 -05:00
|
|
|
case_ids(list of integers): List of case ids. If this is None all cases in group are included
|
2019-09-23 04:50:33 -05:00
|
|
|
|
2020-02-21 05:10:02 -06:00
|
|
|
"""
|
|
|
|
if case_ids is None:
|
|
|
|
case_ids = []
|
|
|
|
return self._execute_command(
|
2020-08-19 00:30:51 -05:00
|
|
|
computeCaseGroupStatistics=Commands_pb2.ComputeCaseGroupStatRequest(
|
2021-01-26 13:48:01 -06:00
|
|
|
caseIds=case_ids, caseGroupId=self.group_id
|
|
|
|
)
|
|
|
|
)
|