Skip to content

Commit

Permalink
df2ecl->df2res
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 0606b7c
Show file tree
Hide file tree
Showing 24 changed files with 257 additions and 257 deletions.
2 changes: 1 addition & 1 deletion docs/usage/equil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Eclipse from your modified data by issuing

.. code-block:: python
equil.df2ecl(dframe, filename="solution.inc")
equil.df2res(dframe, filename="solution.inc")
The last step can also be done using the ``csv2res`` command line utility
if you dump to CSV from your Python code instead.
6 changes: 3 additions & 3 deletions docs/usage/grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Generating Eclipse include files from grid data

If you have loaded grid data into a Pandas frame, some operations are easily performed,
scaling porosity, permeability etc. Or remapping some region parameters. Using the
:func:`res2df.grid.df2ecl()` function these manipulated vectors can be written back as
:func:`res2df.grid.df2res()` function these manipulated vectors can be written back as
include files to Eclipse.

Say you want to change the FIPNUM, and that FIPNUM 6 should be removed, and set
Expand All @@ -165,11 +165,11 @@ it to FIPNUM 5. This can be accomplished using
dframe.loc[rows_to_touch, "FIPNUM"] = 5
# Write back to new include file, ensure datatype is integer.
grid.df2ecl(dframe, "FIPNUM", dtype=int, filename="fipnum.inc", resdatafiles=resdatafiles)
grid.df2res(dframe, "FIPNUM", dtype=int, filename="fipnum.inc", resdatafiles=resdatafiles)
This will produce the file `fipnum.inc` with the contents:

.. literalinclude:: fipnum.inc

It is recommended to supply the ``resdatafiles`` object to ``df2ecl``, if not, correct grid
It is recommended to supply the ``resdatafiles`` object to ``df2res``, if not, correct grid
size can not be ensured.
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
2 changes: 1 addition & 1 deletion docs/usage/pvt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Eclipse from your modified data by issuing

.. code-block:: python
pvt.df2ecl(dframe, filename="pvt.inc")
pvt.df2res(dframe, filename="pvt.inc")
When injecting this produced ``pvt.inc`` into any new input deck, ensure you
check which keywords have been written out, compared to what you gave in to
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/satfunc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ the command
For a dataframe or a CSV file in the format provided by this module, an Eclipse
include file can be generated either with the Python API
:func:`res2df.satfunc.df2ecl` function or the command
:func:`res2df.satfunc.df2res` function or the command

.. code-block:: console
Expand Down Expand Up @@ -117,5 +117,5 @@ Pyscal can create initialize its relperm objects from Eclipse include files
though the parsing capabilities of res2df.satfunc.

The function ``pyscal.pyscallist.df()`` is analogous to ``res2df.satfunc.df()`` in
what it produces, and the :func:`res2df.satfunc.df2ecl()` can be used on both
what it produces, and the :func:`res2df.satfunc.df2res()` can be used on both
(potentially with some filtering needed.).
6 changes: 3 additions & 3 deletions res2df/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def fill_reverse_parser(
return parser


def df2ecl(
def df2res(
dataframe: pd.DataFrame,
keywords: Optional[Union[str, List[str], List[Optional[str]]]] = None,
comments: Optional[Dict[str, str]] = None,
Expand All @@ -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
32 changes: 16 additions & 16 deletions res2df/equil.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ def equil_reverse_main(args) -> None:
)
equil_df = pd.read_csv(args.csvfile)
logger.info("Parsed %s", args.csvfile)
inc_string = df2ecl(equil_df, keywords=args.keywords)
inc_string = df2res(equil_df, keywords=args.keywords)
common.write_inc_stdout_file(inc_string, args.output)


def df2ecl(
def df2res(
equil_df: pd.DataFrame,
keywords: Optional[List[str]] = None,
comments: Optional[Dict[str, str]] = None,
Expand Down Expand Up @@ -381,7 +381,7 @@ def df2ecl(
string += (
phases_from_columns(equil_df.columns).upper().replace("-", "\n") + "\n\n"
)
string += common.df2ecl(
string += common.df2res(
equil_df,
keywords=keywords,
comments=comments,
Expand All @@ -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"
4 changes: 2 additions & 2 deletions res2df/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def drop_constant_columns(
return dframe.drop(columnstodelete, axis=1)


def df2ecl(
def df2res(
grid_df: pd.DataFrame,
keywords: Union[str, List[str]],
resdatafiles: Optional[ResdataFiles] = None,
Expand Down Expand Up @@ -730,7 +730,7 @@ def df2ecl(
logger.warning(
(
"Mismatch between dumped vector length "
"%d from df2ecl and assumed grid size %d"
"%d from df2res and assumed grid size %d"
),
len(vector),
global_size,
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
20 changes: 10 additions & 10 deletions res2df/pvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ def pvt_reverse_main(args) -> None:
)
pvt_df = pd.read_csv(args.csvfile)
logger.info("Parsed %s", args.csvfile)
inc_string = df2ecl(pvt_df, keywords=args.keywords)
inc_string = df2res(pvt_df, keywords=args.keywords)
common.write_inc_stdout_file(inc_string, args.output)


def df2ecl(
def df2res(
pvt_df: pd.DataFrame,
keywords: Optional[Union[str, List[str]]] = None,
comments: Optional[Dict[str, str]] = None,
Expand All @@ -341,7 +341,7 @@ def df2ecl(
filename: If supplied, the generated text will also be dumped
to file.
"""
return common.df2ecl(
return common.df2res(
pvt_df,
keywords,
comments,
Expand All @@ -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 0606b7c

Please sign in to comment.