Skip to content

Commit

Permalink
Have both res2df and ecl2df integration
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Apr 26, 2024
1 parent d2ef39f commit af1bc17
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/fmu-ensemble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: 📦 Install test dependencies
run: |
pip install res2df
pip install res2df ecl2df
pip install .[tests,docs]
- name: 🧾 List all installed packages
Expand Down
42 changes: 42 additions & 0 deletions src/fmu/ensemble/realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
from .util.rates import compute_volumetric_rates
from .virtualrealization import VirtualRealization

HAVE_ECL2DF = False
try:
import ecl2df

HAVE_ECL2DF = True
except ImportError:
HAVE_ECL2DF = False

HAVE_RES2DF = False
try:
import res2df
Expand Down Expand Up @@ -844,6 +852,40 @@ def parameters(self):
"""
return self.data["parameters.txt"]

def get_eclfiles(self):
"""
get_eclfiles is deprecated as ecl2df has been renamed to res2df.
Use the function get_resdatafiles together with res2df instead.
"""
if not HAVE_ECL2DF:
logger.warning("ecl2df not installed. Skipping")
return None
data_file_row = self.files[self.files["FILETYPE"] == "DATA"]
data_filename = None
if len(data_file_row) == 1:
data_filename = data_file_row["FULLPATH"].values[0]
elif self._autodiscovery:
data_fileguess = os.path.join(self._origpath, "eclipse/model", "*.DATA")
data_filenamelist = glob.glob(data_fileguess)
if not data_filenamelist:
return None # No filename matches *DATA
if len(data_filenamelist) > 1:
logger.warning(
(
"Multiple DATA files found, "
"consider turning off auto-discovery"
)
)
data_filename = data_filenamelist[0]
self.find_files(data_filename)
else:
# There is no DATA file to be found.
logger.warning("No DATA file found!")
return None
if not os.path.exists(data_filename):
return None
return ecl2df.EclFiles(data_filename)

def get_resdatafiles(self):
"""
Return an res2df.ResdataFiles object to connect to the res2df package
Expand Down

0 comments on commit af1bc17

Please sign in to comment.