Skip to content

Commit

Permalink
ecl_ -> res_
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen committed Nov 14, 2023
1 parent d58b2b3 commit bf1edc0
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 157 deletions.
4 changes: 2 additions & 2 deletions docs/usage/nnc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ to an Eclipse include file:
nnc_df = nnc.df(resdatafiles)
nnc_df["TRANM"] = 0.1 # Reduce all NNC transmissibilities
nnc.df2ecl_editnnc(nnc_df, filename="editnnc.inc")
nnc.df2res_editnnc(nnc_df, filename="editnnc.inc")
and the contents of the exported file can be:

..
print(nnc.df2ecl_editnnc(nnc.df(resdatafiles).head(4).assign(TRANM=0.1)))
print(nnc.df2res_editnnc(nnc.df(resdatafiles).head(4).assign(TRANM=0.1)))
.. code-block:: console
Expand Down
8 changes: 4 additions & 4 deletions res2df/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def datetime_to_eclipsedate(
return string.replace("00:00:00", "").strip()


def ecl_keyworddata_to_df(
def res_keyworddata_to_df(
deck,
keyword: str,
renamer: Optional[Dict[str, Union[str, List[str]]]] = None,
Expand Down Expand Up @@ -353,7 +353,7 @@ def parse_opmio_date_rec(record: "opm.io.DeckRecord") -> datetime.date:
day = record[0].get_int(0)
month = record[1].get_str(0)
year = record[2].get_int(0)
return datetime.date(year=year, month=parse_ecl_month(month), day=day)
return datetime.date(year=year, month=parse_res_month(month), day=day)


def parse_opmio_tstep_rec(record: "opm.io.DeckRecord") -> List[Union[float, int]]:
Expand Down Expand Up @@ -519,7 +519,7 @@ def df2ecl(
"""Generate resdata include strings from dataframes in res2df format.
This function hands over the actual text generation pr. keyword
to functions named df2ecl_<keywordname> in the calling module.
to functions named df2res_<keywordname> in the calling module.
These functions may again use generic_ecltable() from this module
for the actual string construction.
Expand Down Expand Up @@ -611,7 +611,7 @@ def df2ecl(
string += comment_formatter(comments["master"])
for keyword in keywords:
# Construct the associated function names
function_name = "df2ecl_" + keyword.lower()
function_name = "df2res_" + keyword.lower()
function = getattr(calling_module, function_name)
if keyword in comments:
string += function(dataframe, comments[keyword])
Expand Down
36 changes: 18 additions & 18 deletions res2df/equil.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def rsvd_fromdeck(
"""
if "EQLDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "RSVD", renamer=RENAMERS["RSVD"], recordcountername="EQLNUM"
)

Expand All @@ -158,7 +158,7 @@ def rvvd_fromdeck(
"""
if "EQLDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "RVVD", renamer=RENAMERS["RVVD"], recordcountername="EQLNUM"
)

Expand All @@ -175,7 +175,7 @@ def pbvd_fromdeck(
"""
if "EQLDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "PBVD", renamer=RENAMERS["PBVD"], recordcountername="EQLNUM"
)

Expand All @@ -192,7 +192,7 @@ def pdvd_fromdeck(
"""
if "EQLDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "PDVD", renamer=RENAMERS["PDVD"], recordcountername="EQLNUM"
)

Expand Down Expand Up @@ -264,7 +264,7 @@ def equil_fromdeck(
raise ValueError(f"Could not determine phase configuration, got '{phases}'")
columnrenamer = RENAMERS[phases_from_deck(deck)]

dataframe = common.ecl_keyworddata_to_df(
dataframe = common.res_keyworddata_to_df(
deck, "EQUIL", renamer=columnrenamer, recordcountername="EQLNUM"
)

Expand Down Expand Up @@ -392,7 +392,7 @@ def df2ecl(
return string


def df2ecl_equil(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_equil(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print EQUIL keyword with data
Args:
Expand Down Expand Up @@ -427,7 +427,7 @@ def df2ecl_equil(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
)


def df2ecl_rsvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_rsvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print RSVD keyword with data
This data consists of one table (rs as a function
Expand All @@ -437,10 +437,10 @@ def df2ecl_rsvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
dframe: Containing RSVD data
comment Text that will be included as a comment
"""
return _df2ecl_equilfuncs("RSVD", dframe, comment)
return _df2res_equilfuncs("RSVD", dframe, comment)


def df2ecl_rvvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_rvvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print RVVD keyword with data
This data consists of one table (rv as a function
Expand All @@ -450,10 +450,10 @@ def df2ecl_rvvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
dframe: Containing RVVD data
comment: Text that will be included as a comment
"""
return _df2ecl_equilfuncs("RVVD", dframe, comment)
return _df2res_equilfuncs("RVVD", dframe, comment)


def df2ecl_pbvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_pbvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print PBVD keyword with data
Bubble-point versus depth
Expand All @@ -465,10 +465,10 @@ def df2ecl_pbvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
dframe: Containing PBVD data
comment: Text that will be included as a comment
"""
return _df2ecl_equilfuncs("PBVD", dframe, comment)
return _df2res_equilfuncs("PBVD", dframe, comment)


def df2ecl_pdvd(dframe: pd.DataFrame, comment: Optional[str] = None):
def df2res_pdvd(dframe: pd.DataFrame, comment: Optional[str] = None):
"""Print PDVD keyword with data.
Dew-point versus depth.
Expand All @@ -480,13 +480,13 @@ def df2ecl_pdvd(dframe: pd.DataFrame, comment: Optional[str] = None):
dframe: Containing PDVD data
comment: Text that will be included as a comment
"""
return _df2ecl_equilfuncs("PDVD", dframe, comment)
return _df2res_equilfuncs("PDVD", dframe, comment)


def _df2ecl_equilfuncs(
def _df2res_equilfuncs(
keyword: str, dframe: pd.DataFrame, comment: Optional[str] = None
) -> str:
"""Internal function to be used by df2ecl_<keyword>() functions"""
"""Internal function to be used by df2res_<keyword>() functions"""
if dframe.empty:
return "-- No data!"
string = f"{keyword}\n"
Expand All @@ -500,7 +500,7 @@ def _df2ecl_equilfuncs(
else:
subset = dframe[dframe["KEYWORD"] == keyword]

def _df2ecl_equilfuncs_eqlnum(dframe: pd.DataFrame) -> str:
def _df2res_equilfuncs_eqlnum(dframe: pd.DataFrame) -> str:
"""Print one equilibriation function table for a specific
EQLNUM
Expand All @@ -519,5 +519,5 @@ def _df2ecl_equilfuncs_eqlnum(dframe: pd.DataFrame) -> str:
subset = subset.set_index("EQLNUM").sort_index()
for eqlnum in subset.index.unique():
string += f"-- EQLNUM: {eqlnum}\n"
string += _df2ecl_equilfuncs_eqlnum(subset[subset.index == eqlnum])
string += _df2res_equilfuncs_eqlnum(subset[subset.index == eqlnum])
return string + "\n"
8 changes: 4 additions & 4 deletions res2df/fipreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas as pd

from res2df import ResdataFiles, getLogger_res2csv
from res2df.common import parse_ecl_month, write_dframe_stdout_file
from res2df.common import parse_res_month, write_dframe_stdout_file

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -126,7 +126,7 @@ def df(prtfile: Union[str, ResdataFiles], fipname: str = "FIPNUM") -> pd.DataFra
region_index = None
date = None

ecl_datematcher = re.compile(r"\s\sREPORT\s+\d+\s+(\d+)\s+(\w+)\s+(\d+)")
res_datematcher = re.compile(r"\s\sREPORT\s+\d+\s+(\d+)\s+(\w+)\s+(\d+)")
opm_datematcher = re.compile(r"Starting time step.*? date = (\d+)-(\w+)-(\d+)\s*")

# When case insensitive, this one works with both Eclipse100 and OPM:
Expand All @@ -144,15 +144,15 @@ def df(prtfile: Union[str, ResdataFiles], fipname: str = "FIPNUM") -> pd.DataFra
fipname,
)
for line in prt_fh:
matcheddate = re.match(ecl_datematcher, line)
matcheddate = re.match(res_datematcher, line)
if matcheddate is None:
matcheddate = re.match(opm_datematcher, line)
if matcheddate is not None:
opm = True
if matcheddate is not None:
newdate = datetime.date(
year=int(matcheddate.group(3)),
month=parse_ecl_month(matcheddate.group(2).upper()),
month=parse_res_month(matcheddate.group(2).upper()),
day=int(matcheddate.group(1)),
)
if newdate != date:
Expand Down
2 changes: 1 addition & 1 deletion res2df/nnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
return parser


def df2ecl_editnnc(
def df2res_editnnc(
nnc_df: pd.DataFrame, filename: Optional[str] = None, nocomments: bool = False
) -> str:
"""Write an EDITNNC keyword
Expand Down
28 changes: 14 additions & 14 deletions res2df/pvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def pvtw_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "PVTW", renamer=RENAMERS["PVTW"], recordcountername="PVTNUM"
)

Expand All @@ -98,7 +98,7 @@ def density_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "DENSITY", renamer=RENAMERS["DENSITY"], recordcountername="PVTNUM"
)

Expand All @@ -115,7 +115,7 @@ def rock_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
return common.ecl_keyworddata_to_df(
return common.res_keyworddata_to_df(
deck, "ROCK", renamer=RENAMERS["ROCK"], recordcountername="PVTNUM"
)

Expand All @@ -132,7 +132,7 @@ def pvto_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
pvto_df = common.ecl_keyworddata_to_df(
pvto_df = common.res_keyworddata_to_df(
deck, "PVTO", renamer=RENAMERS["PVTO"], emptyrecordcountername="PVTNUM"
)
return pvto_df
Expand All @@ -150,7 +150,7 @@ def pvdo_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
pvdg_df = common.ecl_keyworddata_to_df(
pvdg_df = common.res_keyworddata_to_df(
deck, "PVDO", renamer=RENAMERS["PVDO"], recordcountername="PVTNUM"
)
return pvdg_df
Expand All @@ -168,7 +168,7 @@ def pvdg_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
pvdg_df = common.ecl_keyworddata_to_df(
pvdg_df = common.res_keyworddata_to_df(
deck, "PVDG", renamer=RENAMERS["PVDG"], recordcountername="PVTNUM"
)
return pvdg_df
Expand All @@ -186,7 +186,7 @@ def pvtg_fromdeck(
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
pvtg_df = common.ecl_keyworddata_to_df(
pvtg_df = common.res_keyworddata_to_df(
deck, "PVTG", renamer=RENAMERS["PVTG"], emptyrecordcountername="PVTNUM"
)
return pvtg_df
Expand Down Expand Up @@ -351,7 +351,7 @@ def df2ecl(
)


def df2ecl_rock(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_rock(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print ROCK keyword with data
Args:
Expand Down Expand Up @@ -379,7 +379,7 @@ def df2ecl_rock(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
return string + "\n"


def df2ecl_density(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_density(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print DENSITY keyword with data
Args:
Expand Down Expand Up @@ -408,7 +408,7 @@ def df2ecl_density(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
return string + "\n"


def df2ecl_pvtw(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_pvtw(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print PVTW keyword with data
PVTW is one line/record with data for a reference pressure
Expand Down Expand Up @@ -444,7 +444,7 @@ def df2ecl_pvtw(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
return string + "\n"


def df2ecl_pvtg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_pvtg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print PVTG keyword with data
Args:
Expand Down Expand Up @@ -503,7 +503,7 @@ def _pvtg_pvtnum_pg(dframe):
return string + "\n"


def df2ecl_pvdg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_pvdg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print PVDG keyword with data
This data consists of one table (volumefactor and visosity
Expand Down Expand Up @@ -553,7 +553,7 @@ def _pvdg_pvtnum(dframe):
return string + "\n"


def df2ecl_pvdo(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_pvdo(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print PVDO keyword with data
Args:
Expand Down Expand Up @@ -600,7 +600,7 @@ def _pvdo_pvtnum(dframe: pd.DataFrame) -> str:
return string + "\n"


def df2ecl_pvto(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
def df2res_pvto(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"""Print PVTO-data from a dataframe
Args:
Expand Down
Loading

0 comments on commit bf1edc0

Please sign in to comment.