Skip to content

Commit

Permalink
eclfile->resfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen committed Nov 14, 2023
1 parent fceffb5 commit b4d9303
Show file tree
Hide file tree
Showing 57 changed files with 649 additions and 649 deletions.
10 changes: 5 additions & 5 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ a Pandas Dataframe.
import res2df
eclfiles = res2df.EclFiles("MYECLDECK.DATA")
smry = res2df.summary.df(eclfiles, column_keys="F*", time_index="monthly")
hc_contacts = res2df.pillars.df(eclfiles, rstdates="all")
resfiles = res2df.ResFiles("MYECLDECK.DATA")
smry = res2df.summary.df(resfiles, column_keys="F*", time_index="monthly")
hc_contacts = res2df.pillars.df(resfiles, rstdates="all")
See the API for more documentation and possibilities for each module.

Expand Down Expand Up @@ -169,11 +169,11 @@ associated data in a dataframe format.

More documentation on :doc:`usage/wcon`.

``eclfiles``
``resfiles``
^^^^^^^^^^^^

This is an internal helper module in order to represent finished or
unfinished Eclipse decks and runs. The class EclFiles can cache binary
unfinished Eclipse decks and runs. The class ResFiles can cache binary
files that are recently read, and is able to locate the various output
files based on the basename or the `.DATA` filename.

Expand Down
8 changes: 4 additions & 4 deletions docs/usage/compdat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Additionally, it will parse WELOPEN statements and emit new COMPDAT
statements from the actions in WELOPEN.

..
compdat.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head(15).to_csv('docs/usage/compdat.csv', index=False)
compdat.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head(15).to_csv('docs/usage/compdat.csv', index=False)
.. code-block:: python
from res2df import compdat, EclFiles
from res2df import compdat, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
dframe = compdat.df(eclfiles)
resfiles = ResFiles("MYDATADECK.DATA")
dframe = compdat.df(resfiles)
.. csv-table:: Example COMPDAT table
:file: compdat.csv
Expand Down
6 changes: 3 additions & 3 deletions docs/usage/equil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ Supported keywords are ``EQUIL``, ``RSVD``, ``RVVD``, ``PBVD`` and

.. code-block:: python
from res2df import equil, EclFiles
from res2df import equil, ResFiles
dframe = equil.df(EclFiles('MYECLDECK.DATA'))
dframe = equil.df(ResFiles('MYECLDECK.DATA'))
Which will provide a dataframe similar to the example below. Note that the column
`Z` is used both for datum depth and the depth values in ``RSVD`` tables. The
amount of columns obtained depends on the input dataset, and should be possible
to link up with the Eclipse documentation. API doc: :func:`res2df.equil.df`

..
dframe = equil.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'))
dframe = equil.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'))
dframe[['EQLNUM', 'KEYWORD', 'Z', 'PRESSURE', 'OWC', 'GOC', 'RS']]\
.to_csv(index=False))
Expand Down
26 changes: 13 additions & 13 deletions docs/usage/grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ Typical usage

.. code-block:: python
from res2df import grid, EclFiles
from res2df import grid, ResFiles
eclfiles = EclFiles('MYDATADECK.DATA')
dframe = grid.df(eclfiles, rstdates='last')
resfiles = ResFiles('MYDATADECK.DATA')
dframe = grid.df(resfiles, rstdates='last')
where the API is documented at :func:`res2df.grid.df`.

..
eclfiles = EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')
grid.df(eclfiles).sample(10).to_csv('docs/usage/grid.csv', float_format="%.2f", index=False)
resfiles = ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')
grid.df(resfiles).sample(10).to_csv('docs/usage/grid.csv', float_format="%.2f", index=False)
.. csv-table:: Example grid table
:file: grid.csv
Expand Down Expand Up @@ -110,10 +110,10 @@ the whereabouts of the file:

.. code-block:: python
from res2df import grid, EclFiles, common
from res2df import grid, ResFiles, common
eclfiles = EclFiles("'MYDATADECK.DATA")
dframe = grid.df(eclfiles)
resfiles = ResFiles("'MYDATADECK.DATA")
dframe = grid.df(resfiles)
# The filename with layers is relative to DATA-file location
# or an absolute path.
subzonemap = res2df.common.parse_zonemapfile("subzones.lyr")
Expand Down Expand Up @@ -155,21 +155,21 @@ it to FIPNUM 5. This can be accomplished using

.. code-block:: python
from res2df import grid, EclFiles, common
from res2df import grid, ResFiles, common
eclfiles = EclFiles("'MYDATADECK.DATA")
dframe = grid.df(eclfiles)
resfiles = ResFiles("'MYDATADECK.DATA")
dframe = grid.df(resfiles)
# Change FIPNUM 6 to FIPNUM 5:
rows_to_touch = dframe["FIPNUM"] == 6
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", eclfiles=eclfiles)
grid.df2ecl(dframe, "FIPNUM", dtype=int, filename="fipnum.inc", resfiles=resfiles)
This will produce the file `fipnum.inc` with the contents:

.. literalinclude:: fipnum.inc

It is recommended to supply the ``eclfiles`` object to ``df2ecl``, if not, correct grid
It is recommended to supply the ``resfiles`` object to ``df2ecl``, if not, correct grid
size can not be ensured.
16 changes: 8 additions & 8 deletions docs/usage/nnc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Note: Eclipse300 will not export TRANNNC data in parallel mode.
Run in serial to get this output.

..
nnc.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head(15).to_csv('docs/usage/nnc.csv', index=False)
nnc.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head(15).to_csv('docs/usage/nnc.csv', index=False)
.. code-block:: python
from res2df import nnc, EclFiles
from res2df import nnc, ResFiles
eclfiles = EclFiles('MYDATADECK.DATA')
dframe = nnc.df(eclfiles)
resfiles = ResFiles('MYDATADECK.DATA')
dframe = nnc.df(resfiles)
.. csv-table:: Example nnc table
:file: nnc.csv
Expand Down Expand Up @@ -49,18 +49,18 @@ to an Eclipse include file:

.. code-block:: python
from ecl2f import nnc, EclFiles
from ecl2f import nnc, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
nnc_df = nnc.df(eclfiles)
resfiles = ResFiles("MYDATADECK.DATA")
nnc_df = nnc.df(resfiles)
nnc_df["TRANM"] = 0.1 # Reduce all NNC transmissibilities
nnc.df2ecl_editnnc(nnc_df, filename="editnnc.inc")
and the contents of the exported file can be:

..
print(nnc.df2ecl_editnnc(nnc.df(eclfiles).head(4).assign(TRANM=0.1)))
print(nnc.df2ecl_editnnc(nnc.df(resfiles).head(4).assign(TRANM=0.1)))
.. code-block:: console
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/pillars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Typical usage is to obtain property statistics, and compute contacts pr.
pillar (and optionally pr some region parameter).

..
from res2df import pillars, EclFiles
pillars.df(res2df.EclFiles('../tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'))
pillars.df(res2df.EclFiles('../tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head().to_csv("pillars-example1.csv"float_format="%.1f", index=False))
from res2df import pillars, ResFiles
pillars.df(res2df.ResFiles('../tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'))
pillars.df(res2df.ResFiles('../tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head().to_csv("pillars-example1.csv"float_format="%.1f", index=False))
.. csv-table:: Example pillar table
:file: pillars-example1.csv
Expand Down Expand Up @@ -90,7 +90,7 @@ By default, dynamic data are added as a set of columns for every date, like in
this example:

..
pillars.df(res2df.EclFiles('../tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'), rstdates='all').dropna().head().to_csv('pillars-dyn1-unstacked.csv', float_format="%.1f", index=False)
pillars.df(res2df.ResFiles('../tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'), rstdates='all').dropna().head().to_csv('pillars-dyn1-unstacked.csv', float_format="%.1f", index=False)
.. csv-table:: Example pillar table with dynamical data, unstacked
:file: pillars-dyn1-unstacked.csv
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/pvt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Example usage:

.. code-block:: python
from res2df import pvt, EclFiles
from res2df import pvt, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
dframe = pvt.df(eclfiles)
resfiles = ResFiles("MYDATADECK.DATA")
dframe = pvt.df(resfiles)
Alternatively, we may also read directly from an include file
if we read the contents of the file and supply it as a string:
Expand All @@ -22,7 +22,7 @@ if we read the contents of the file and supply it as a string:
dframe = pvt.df(open("pvt.inc").read())
..
pvt.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).tail(15).to_csv('docs/usage/pvt.csv', index=False)
pvt.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).tail(15).to_csv('docs/usage/pvt.csv', index=False)

.. csv-table:: Example PVT table (last 15 rows to show non-Nan data)
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/satfunc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ column.

..
import numpy as np
satfunc.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).iloc[np.r_[0:5, 37:42, -5:0]].to_csv('docs/usage/satfunc.csv', index=False)
satfunc.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).iloc[np.r_[0:5, 37:42, -5:0]].to_csv('docs/usage/satfunc.csv', index=False)
.. code-block:: python
from res2df import satfunc, EclFiles
from res2df import satfunc, ResFiles
eclfiles = EclFiles('MYDATADECK.DATA')
dframe = satfunc.df(eclfiles)
resfiles = ResFiles('MYDATADECK.DATA')
dframe = satfunc.df(resfiles)
.. csv-table:: Example satfunc table (only a subset of the rows are shown)
:file: satfunc.csv
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/summary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ This module extracts summary information from UNSMRY-files into
Pandas Dataframes.

..
summary.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'), column_keys="F*PT", time_index='yearly').to_csv("summary.csv")
summary.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA'), column_keys="F*PT", time_index='yearly').to_csv("summary.csv")
.. code-block:: python
from res2df import summary, EclFiles
from res2df import summary, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
dframe = summary.df(eclfiles, column_keys="F*PT", time_index="yearly")
resfiles = ResFiles("MYDATADECK.DATA")
dframe = summary.df(resfiles, column_keys="F*PT", time_index="yearly")
If you don't specify ``column_keys``, all included summary vectors will be
retrieved. Default for ``time_index`` is the report datetimes written by
Expand Down
20 changes: 10 additions & 10 deletions docs/usage/trans.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ connections

.. code-block:: python
from res2df import trans, EclFiles
from res2df import trans, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
dframe = res2df.trans.df(eclfiles)
resfiles = ResFiles("MYDATADECK.DATA")
dframe = res2df.trans.df(resfiles)
..
res2df.trans.df(res2df.EclFiles("2_R001_REEK-0.DATA")).sample(7)\
res2df.trans.df(res2df.ResFiles("2_R001_REEK-0.DATA")).sample(7)\
.to_csv("trans1.csv", float_format="%.2f", index=False)
.. csv-table:: Neighbour transmissibilities, sample rows from an example simulation.
Expand Down Expand Up @@ -79,12 +79,12 @@ like this. Example:

.. code-block:: python
dframe = res2df.trans.df(eclfiles, vectors="FIPNUM", boundaryfilter=True, addnnc=True)
dframe = res2df.trans.df(resfiles, vectors="FIPNUM", boundaryfilter=True, addnnc=True)
which gives the dataframe

..
res2df.trans.df(res2df.EclFiles("2_R001_REEK-0.DATA"), addnnc=True, vectors="FIPNUM", boundaryfilter=True).sample(10).to_csv("trans-boundaries.csv", index=False, float_format="%.2f")
res2df.trans.df(res2df.ResFiles("2_R001_REEK-0.DATA"), addnnc=True, vectors="FIPNUM", boundaryfilter=True).sample(10).to_csv("trans-boundaries.csv", index=False, float_format="%.2f")
.. csv-table:: Sample rows from connections where FIPNUM is changing
:file: trans-boundaries.csv
Expand All @@ -105,13 +105,13 @@ over a region interface. This is accomplished by adding the ``group=True`` optio

.. code-block:: python
from res2df import trans, EclFiles
from res2df import trans, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
dframe = res2df.trans.df(eclfiles, vectors="FIPNUM", addnnc=True, group=True)
resfiles = ResFiles("MYDATADECK.DATA")
dframe = res2df.trans.df(resfiles, vectors="FIPNUM", addnnc=True, group=True)
..
res2df.trans.df(res2df.EclFiles("2_R001_REEK-0.DATA"), addnnc=True, vectors="FIPNUM", group=True).to_csv("trans-group.csv", index=False, float_format="%.2f")
res2df.trans.df(res2df.ResFiles("2_R001_REEK-0.DATA"), addnnc=True, vectors="FIPNUM", group=True).to_csv("trans-group.csv", index=False, float_format="%.2f")
.. csv-table:: Transmissibilities summed over each FIPNUM interface
:file: trans-group.csv
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/wcon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This module extracts information from WCONHIST, WCONINJE, WCONINJH and
WCONPROD from an Eclipse deck.

..
wcon.df(EclFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head(15).to_csv('docs/usage/wcon.csv', index=False)
wcon.df(ResFiles('tests/data/reek/eclipse/model/2_R001_REEK-0.DATA')).head(15).to_csv('docs/usage/wcon.csv', index=False)
.. code-block:: python
from res2df import wcon, EclFiles
from res2df import wcon, ResFiles
eclfiles = EclFiles("MYDATADECK.DATA")
dframe = wcon.df(eclfiles)
resfiles = ResFiles("MYDATADECK.DATA")
dframe = wcon.df(resfiles)
.. csv-table:: Example WCON table
:file: wcon.csv
Expand Down
2 changes: 1 addition & 1 deletion res2df/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__version__ = "v0.0.0"

from .constants import MAGIC_STDOUT
from .eclfiles import EclFiles
from .resfiles import ResFiles

SUBMODULES: List[str] = [
"compdat",
Expand Down
14 changes: 7 additions & 7 deletions res2df/compdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
parse_opmio_tstep_rec,
write_dframe_stdout_file,
)
from .eclfiles import EclFiles
from .resfiles import ResFiles
from .grid import merge_initvectors

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -973,13 +973,13 @@ def compdat_main(args):
logger = getLogger_res2csv( # pylint: disable=redefined-outer-name
__name__, vars(args)
)
eclfiles = EclFiles(args.DATAFILE)
compdat_df = df(eclfiles, initvectors=args.initvectors)
resfiles = ResFiles(args.DATAFILE)
compdat_df = df(resfiles, initvectors=args.initvectors)
write_dframe_stdout_file(compdat_df, args.output, index=False, caller_logger=logger)


def df(
eclfiles: EclFiles,
resfiles: ResFiles,
initvectors: Optional[List[str]] = None,
zonemap: Optional[Dict[int, str]] = None,
) -> pd.DataFrame:
Expand All @@ -992,17 +992,17 @@ def df(
Returns:
pd.Dataframe with one row pr cell to well connection
"""
compdat_df = deck2dfs(eclfiles.get_ecldeck())["COMPDAT"]
compdat_df = deck2dfs(resfiles.get_ecldeck())["COMPDAT"]
compdat_df = unrolldf(compdat_df)

if initvectors:
compdat_df = merge_initvectors(
eclfiles, compdat_df, initvectors, ijknames=["I", "J", "K1"]
resfiles, compdat_df, initvectors, ijknames=["I", "J", "K1"]
)

if zonemap is None:
# If no zonemap is submitted, search for zonemap in default location
zonemap = eclfiles.get_zonemap()
zonemap = resfiles.get_zonemap()

if zonemap:
logger.info("Merging zonemap into compdat")
Expand Down
4 changes: 2 additions & 2 deletions res2df/eclfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
]


class EclFiles(object):
class ResFiles(object):
"""
Class for holding an Eclipse deck with result files
Expand Down Expand Up @@ -109,7 +109,7 @@ def str2deck(
@staticmethod
def file2deck(filename: Union[str, Path]) -> "opm.libopmcommon_python.Deck":
"""Try to convert standalone files into opm.io Deck objects"""
return EclFiles.str2deck(Path(filename).read_text(encoding="utf-8"))
return ResFiles.str2deck(Path(filename).read_text(encoding="utf-8"))

def get_egrid(self) -> Grid:
"""Find and return EGRID file as an Grid object"""
Expand Down
Loading

0 comments on commit b4d9303

Please sign in to comment.