Skip to content

Commit

Permalink
Deprecate function that are planned removed in v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Feb 1, 2021
1 parent 82cf5fa commit b5effb7
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/fmu/ensemble/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import glob
import logging
import warnings

import dateutil
import pandas as pd
Expand Down Expand Up @@ -1105,6 +1106,10 @@ def get_wellnames(self, well_match=None):
summary file or no matched well names.
"""
warnings.warn(
"ensemble.get_wellnames() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if isinstance(well_match, str):
well_match = [well_match]
result = set()
Expand Down Expand Up @@ -1135,7 +1140,10 @@ def get_groupnames(self, group_match=None):
summary file or no matched well names.
"""

warnings.warn(
"ensemble.get_groupnames() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if isinstance(group_match, str):
group_match = [group_match]
result = set()
Expand Down Expand Up @@ -1406,6 +1414,10 @@ def get_eclgrid(self, props, report=0, agg="mean", active_only=False):
A dictionary. Index by grid attribute, and contains a list
corresponding to a set of values for each grid cells.
"""
warnings.warn(
"ensemble.get_eclgrid() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
egrid_reals = [
real for real in self.realizations.values() if real.get_grid() is not None
]
Expand All @@ -1432,6 +1444,10 @@ def global_active(self):
:returns: An EclKw with, for each cell,
the number of realizations where the cell is active.
"""
warnings.warn(
"ensemble.global_active() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if not self._global_active:
self._global_active = EclKW(
"eactive", self.global_size, EclDataType.ECL_INT
Expand All @@ -1448,6 +1464,10 @@ def global_size(self):
:returns: global size of the realizations in the Ensemble. see
:func:`fmu_postprocessing.modelling.Realization.global_size()`.
"""
warnings.warn(
"ensemble.global_size() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if not self.realizations:
return 0
if self._global_size is None:
Expand All @@ -1467,13 +1487,18 @@ def _get_grid_index(self, active=True):
Returns: The grid of the ensemble, see
:func:`fmu.ensemble.Realization.get_grid()`.
"""
# ensemble._get_grid_index() is deprecated and will be removed in fmu-ensemble v2.0.0
if not self.realizations:
return None
return list(self.realizations.values())[0].get_grid_index(active=active)

@property
def init_keys(self):
"""Return all keys available in the Eclipse INIT file """
warnings.warn(
"ensemble.init_keys() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if not self.realizations:
return None
all_keys = set.union(
Expand All @@ -1488,6 +1513,10 @@ def init_keys(self):
@property
def unrst_keys(self):
"""Return keys availaible in the Eclipse UNRST file """
warnings.warn(
"ensemble.unrst_keys() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if not self.realizations:
return None
all_keys = set.union(
Expand All @@ -1501,6 +1530,10 @@ def unrst_keys(self):

def get_unrst_report_dates(self):
"""Returns UNRST report step and the corresponding date """
warnings.warn(
"ensemble.get_unrst_report_dates() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if not self.realizations:
return None
all_report_dates = set.union(
Expand All @@ -1523,6 +1556,10 @@ def get_init(self, prop, agg):
and corresponding values for given property as values.
:raises ValueError: If prop is not found.
"""
warnings.warn(
"ensemble.get_init() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if agg == "mean":
mean = self._keyword_mean(prop, self.global_active)
return pd.Series(mean.numpy_copy(), name=prop)
Expand All @@ -1539,7 +1576,10 @@ def get_unrst(self, prop, report, agg):
and corresponding values for given property as values.
:raises ValueError: If prop is not in `TIME_DEPENDENT`.
"""

warnings.warn(
"ensemble.get_unrst() is deprecated and will be removed in fmu-ensemble v2.0.0",
FutureWarning,
)
if agg == "mean":
mean = self._keyword_mean(prop, self.global_active, report=report)
return pd.Series(mean.numpy_copy(), name=prop)
Expand All @@ -1558,6 +1598,7 @@ def _keyword_mean(self, prop, global_active, report=None):
realizations where the cell is active.
:param report: Report step for unrst keywords
"""
# ensemble._keyword_mean() is deprecated and will be removed in fmu-ensemble v2.0.0
mean = EclKW(prop, len(global_active), EclDataType.ECL_FLOAT)
if report:
for _, realization in self.realizations.items():
Expand All @@ -1580,6 +1621,7 @@ def _keyword_std_dev(self, prop, global_active, mean, report=0):
realizations where the cell is active.
:param mean: Mean of keywords.
"""
# ensemble._keyword_std_dev() is deprecated and will be removed in fmu-ensemble v2.0.0
std_dev = EclKW(prop, len(global_active), EclDataType.ECL_FLOAT)
if report:
for _, realization in self.realizations.items():
Expand Down
5 changes: 5 additions & 0 deletions src/fmu/ensemble/ensembleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import glob
import logging
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -744,6 +745,10 @@ def get_wellnames(self, well_match=None):
summary file or no matched well names.
"""
warnings.warn(
"fmu.ensemble.etc is deprecated and will be removed in later versions.",
FutureWarning,
)
result = set()
for _, ensemble in self._ensembles.items():
result = result.union(ensemble.get_wellnames(well_match))
Expand Down
45 changes: 45 additions & 0 deletions src/fmu/ensemble/realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from datetime import datetime, date, time
import dateutil
import logging
import warnings

import yaml
import numpy as np
Expand Down Expand Up @@ -1410,6 +1411,10 @@ def get_init(self):
"""
:returns: init file of the realization.
"""
warnings.warn(
"realization.get_init() is deprecated and will be removed in later versions.",
FutureWarning,
)
init_file_row = self.files[self.files.FILETYPE == "INIT"]
init_filename = None
if len(init_file_row) == 1:
Expand All @@ -1433,6 +1438,10 @@ def get_unrst(self):
"""
:returns: restart file of the realization.
"""
warnings.warn(
"realization.get_unrst() is deprecated and will be removed in later versions.",
FutureWarning,
)
unrst_file_row = self.files[self.files.FILETYPE == "UNRST"]
unrst_filename = None
if len(unrst_file_row) == 1:
Expand All @@ -1455,13 +1464,21 @@ def get_grid_index(self, active_only):
"""
Return the grid index in a pandas dataframe.
"""
warnings.warn(
"realization.get_grid_index() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_grid():
return self.get_grid().export_index(active_only=active_only)
logger.warning("No GRID file in realization %s", self)

def get_grid_corners(self, grid_index):
"""Return a dataframe with the the x, y, z for the
8 grid corners of corner point cells"""
warnings.warn(
"realization.get_grid_corners() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_grid():
corners = self.get_grid().export_corners(grid_index)
columns = [
Expand Down Expand Up @@ -1498,6 +1515,10 @@ def get_grid_corners(self, grid_index):
def get_grid_centre(self, grid_index):
"""Return the grid centre of corner-point-cells, x, y and z
in distinct columns"""
warnings.warn(
"realization.get_grid_centre() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_grid():
grid_cell_centre = self.get_grid().export_position(grid_index)
return pd.DataFrame(
Expand All @@ -1510,6 +1531,10 @@ def get_grid(self):
"""
:returns: grid file of the realization.
"""
warnings.warn(
"realization.get_grid() is deprecated and will be removed in later versions.",
FutureWarning,
)
grid_file_row = self.files[self.files.FILETYPE == "EGRID"]
grid_filename = None
if len(grid_file_row) == 1:
Expand All @@ -1531,6 +1556,10 @@ def global_size(self):
"""
:returns: Number of cells in the realization.
"""
warnings.warn(
"realization.get_grid() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_grid() is not None:
return self.get_grid().get_global_size()

Expand All @@ -1541,6 +1570,10 @@ def actnum(self):
Active cells are given value 1, while
inactive cells have value 1.
"""
warnings.warn(
"realization.get_grid() is deprecated and will be removed in later versions.",
FutureWarning,
)
if not self._actnum and self.get_init() is not None:
self._actnum = self.get_init()["PORV"][0].create_actnum()
return self._actnum
Expand All @@ -1550,6 +1583,10 @@ def report_dates(self):
"""
:returns: List of DateTime.DateTime for which values are reported.
"""
warnings.warn(
"realization.get_grid() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_unrst() is not None:
return self.get_unrst().report_dates

Expand All @@ -1559,6 +1596,10 @@ def get_global_init_keyword(self, prop):
:returns: The EclKw of given name. Length is global_size.
non-active cells are given value 0.
"""
warnings.warn(
"realization.get_global_init_keyword() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_init() is not None:
return self.get_init()[prop][0].scatter_copy(self.actnum)

Expand All @@ -1568,5 +1609,9 @@ def get_global_unrst_keyword(self, prop, report):
:returns: The EclKw of given name. Length is global_size.
non-active cells are given value 0.
"""
warnings.warn(
"realization.get_global_unrst_keyword() is deprecated and will be removed in later versions.",
FutureWarning,
)
if self.get_unrst() is not None:
return self.get_unrst()[prop][report].scatter_copy(self.actnum)

0 comments on commit b5effb7

Please sign in to comment.