Files
ResInsight/GrpcInterface/Python/rips/gridcasegroup.py
T

77 lines
2.1 KiB
Python
Raw 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
import warnings
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
Deprecated: use RimStatisticalCalculation.compute_statistics(update_views=True) on each
statistics case (see statistics_cases()) instead.
Arguments:
case_ids(list of integers): List of case ids. If this is None or empty all cases in group are included
"""
warnings.warn(
"GridCaseGroup.compute_statistics() is deprecated, use compute_statistics() on each statistics case instead",
DeprecationWarning,
stacklevel=3,
2021-01-26 20:48:01 +01:00
)
for statistics_case in self.statistics_cases():
if not case_ids or statistics_case.id in case_ids:
statistics_case.compute_statistics(update_views=True)