Files

73 lines
1.8 KiB
Python
Raw Permalink Normal View History

"""
Grid Case Group statistics module
"""
2020-08-19 07:30:51 +02:00
from .pdmobject import add_method
2025-05-16 15:46:45 +02:00
from .view import View as View
from .case import Case as Case
2020-08-19 07:30:51 +02:00
import Commands_pb2
from .resinsight_classes import GridCaseGroup
2023-02-05 09:31:22 +01:00
from .resinsight_classes import EclipseView
2023-07-07 10:31:26 +02:00
from .resinsight_classes import RimStatisticalCalculation
2020-04-16 16:06:18 +02:00
@add_method(GridCaseGroup)
def statistics_cases(self):
2020-04-16 16:06:18 +02:00
"""Get a list of all statistics cases in the Grid Case Group
2021-01-26 20:48:01 +01:00
Returns:
List of :class:`rips.generated.generated_classes.EclipseCase`
2020-04-16 16:06:18 +02:00
"""
2023-07-07 10:31:26 +02:00
return self.descendants(RimStatisticalCalculation)
2020-04-16 16:06:18 +02:00
@add_method(GridCaseGroup)
def views(self):
2020-04-16 16:06:18 +02:00
"""Get a list of views belonging to a grid case group
2021-01-26 20:48:01 +01:00
Returns:
List of :class:`rips.generated.generated_classes.EclipseView`
2020-04-16 16:06:18 +02:00
"""
resinsight_classes = self.descendants(EclipseView)
view_list = []
for pdm_object in resinsight_classes:
view_list.append(pdm_object)
return view_list
2020-04-16 16:06:18 +02:00
@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
2020-04-16 16:06:18 +02:00
Returns:
List of :class:`rips.generated.generated_classes.EclipseView`
"""
views = self.views()
for view_object in views:
if view_object.id == view_id:
return view_object
return None
2020-04-16 16:06:18 +02:00
@add_method(GridCaseGroup)
def compute_statistics(self, case_ids=None):
2021-01-26 20:48:01 +01:00
"""Compute statistics for the given case ids
Arguments:
2020-04-16 16:06:18 +02:00
case_ids(list of integers): List of case ids. If this is None all cases in group are included
"""
if case_ids is None:
case_ids = []
return self._execute_command(
2020-08-19 07:30:51 +02:00
computeCaseGroupStatistics=Commands_pb2.ComputeCaseGroupStatRequest(
2021-01-26 20:48:01 +01:00
caseIds=case_ids, caseGroupId=self.group_id
)
)