Skip to content

Commit

Permalink
Refer to .DATA file from py code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen committed Nov 17, 2023
1 parent d457a55 commit 033c798
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 43 deletions.
2 changes: 1 addition & 1 deletion res2df/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def generic_deck_table(
renamer: Optional[Dict[str, str]] = None,
drop_trailing_columns: bool = True,
) -> str:
"""Construct string contents of a .DATA file table.
"""Construct string contents of a :term:`.DATA file` table.
This function will *not* add a final slash after all rows, as
this is keyword dependent. Some keywords require it, some keywords
Expand Down
4 changes: 2 additions & 2 deletions res2df/compdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def deck2dfs(
Args:
deck: A deck representing the schedule
Does not have to be a full .DATA file, an include file is sufficient
Does not have to be a full :term:`.DATA file`, an include file is sufficient
start_date: The default date to use for
events where the DATE or START keyword is not found in advance.
Default: None
Expand Down Expand Up @@ -950,7 +950,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
Arguments:
parser: parser to fill with arguments
"""
parser.add_argument("DATAFILE", help="Name of .DATA file.")
parser.add_argument("DATAFILE", help="Name of :term:`.DATA file`.")
parser.add_argument(
"-o",
"--output",
Expand Down
4 changes: 2 additions & 2 deletions res2df/equil.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Extract EQUIL from a .DATA file as Pandas DataFrame
Extract EQUIL from a :term:`.DATA file` as Pandas DataFrame
"""

import argparse
Expand Down Expand Up @@ -92,7 +92,7 @@ def df(
are possibly already removed by the OPM parser in resdatafiles.str2deck().
Arguments:
deck: .DATA file or string with deck. If
deck: :term:`.DATA file` or string with deck. If
not string, EQLDIMS must be present in the deck.
keywords: Requested keywords for which to extract data.
ntequl: If not None, should state the NTEQUL in EQLDIMS. If
Expand Down
2 changes: 1 addition & 1 deletion res2df/faults.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def df(deck: Union[ResdataFiles, "opm.libopmcommon_python.Deck"]) -> pd.DataFram
All data for the keyword FAULTS will be returned.
Args:
deck: .DATA file
deck: :term:`.DATA file`
"""
if isinstance(deck, ResdataFiles):
deck = deck.get_deck()
Expand Down
2 changes: 1 addition & 1 deletion res2df/fipreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def df(prtfile: Union[str, ResdataFiles], fipname: str = "FIPNUM") -> pd.DataFra
prtfile: filename (PRT) or an ResdataFiles object
fipname: The name of the regport regions, FIPNUM, FIPZON or whatever
Max length of the string is 8, the first three characters must be FIP,
and the next 3 characters must be unique for a given .DATA file.
and the next 3 characters must be unique for a given :term:`.DATA file`.
"""
if isinstance(prtfile, ResdataFiles):
prtfile = prtfile.get_prtfilename()
Expand Down
2 changes: 1 addition & 1 deletion res2df/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def df2res(
) -> str:
"""
Write an include file with grid data keyword, like PERMX, PORO,
FIPNUM etc, for the GRID section of the .DATA file.
FIPNUM etc, for the GRID section of the :term:`.DATA file`.
Output (returned as string and optionally written to file) will then
contain f.ex::
Expand Down
2 changes: 1 addition & 1 deletion res2df/gruptree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Extract GRUPTREE information from a .DATA file"""
"""Extract GRUPTREE information from a :term:`.DATA file`"""

import argparse
import collections
Expand Down
2 changes: 1 addition & 1 deletion res2df/inferdims.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def guess_dim(deckstring: str, dimkeyword: str, dimitem: int = 0) -> int:
stricter mode, to detect the correct table dimensionality
Arguments:
deck: String containing a .DATA file or only a few resdata keywords
deck: String containing a :term:`.DATA file` or only a few resdata keywords
dimkeyword: Either TABDIMS or EQLDIMS
dimitem: The element number in TABDIMS/EQLDIMS to modify
Returns:
Expand Down
6 changes: 3 additions & 3 deletions res2df/pvt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Extract the PVT data from a .DATA file as Pandas Dataframes
Extract the PVT data from a :term:`.DATA file` as Pandas Dataframes
Data can be extracted from a full .DATA file or from individual files.
Data can be extracted from a full :term:`.DATA file` or from individual files.
"""

import argparse
Expand Down Expand Up @@ -239,7 +239,7 @@ def df(


def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
"""Set up sys.argv parsers for parsing .DATA file or
"""Set up sys.argv parsers for parsing :term:`.DATA file` or
include files into dataframes
Arguments:
Expand Down
4 changes: 2 additions & 2 deletions res2df/res2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
CATEGORY: str = "utility.eclipse"
EXAMPLES: str = """
Outputting the EQUIL data from a .DATA file. This is implicitly
Outputting the EQUIL data from a :term:`.DATA file`. This is implicitly
supplied in ERT configs::
FORWARD_MODEL res2csv(<SUBCOMMAND>=equil, <OUTPUT>=equil.csv)
Expand Down Expand Up @@ -130,7 +130,7 @@ def get_parser() -> argparse.ArgumentParser:
"pvt",
help="Extract PVT data",
description=(
"Extract data for the PVT keywords in a .DATA file "
"Extract data for the PVT keywords in a :term:`.DATA file` "
"and merge all data into a single dataframe. "
"Supported keywords are PVTO, PVDO, PVTG, PVDG, PVTW, "
"ROCK and DENSITY. Gas phase pressure and oil phase "
Expand Down
7 changes: 4 additions & 3 deletions res2df/satfunc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Extract saturation function data (SWOF, SGOF, SWFN, etc.)
from a .DATA file as Pandas DataFrame.
from a :term:`.DATA file` as Pandas DataFrame.
Data can be extracted from a full .DATA file (`*.DATA`)
Data can be extracted from a full :term:`.DATA file` (`*.DATA`)
or from individual files.
Note that when parsing from individual files, it is
Expand Down Expand Up @@ -129,7 +129,8 @@ def df(

def interpolate_defaults(dframe: pd.DataFrame) -> pd.DataFrame:
"""Interpolate NaN's linearly in saturation.
Saturation function tables in .DATA files can have certain values defaulted.
Saturation function tables in :term:`.DATA files <.DATA file>`
can have certain values defaulted.
When parsed by common.res2df, these values are returned as np.nan.
The incoming dataframe must be associated to one keyword only, but
can consist of multiple SATNUMs.
Expand Down
4 changes: 2 additions & 2 deletions res2df/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def df(
is always named "DATE".
Arguments:
resdatafiles: ResdataFiles object representing a .DATA file. Alternatively
an Summary object.
resdatafiles: ResdataFiles object representing a :term:`.DATA file`.
Alternatively a Summary object.
time_index: string indicating a resampling frequency,
'yearly', 'monthly', 'daily', 'last' or 'raw', the latter will
return the simulated report steps (also default).
Expand Down
10 changes: 5 additions & 5 deletions res2df/vfp/_vfp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Extract the VFPPROD/VFPINJ data from an Eclipse (input) deck as Pandas Dataframes
Data can be extracted from a full .DATA file or from individual files. Supports
Data can be extracted from a full :term:`.DATA file` or from individual files. Supports
output both in csv format as a pandas DataFrame or in pyarrow and pyarrow.table
"""

Expand Down Expand Up @@ -45,7 +45,7 @@ def basic_data(
BASIC_DATA_KEYS in _vfpprod and _vfpinj.
Args:
deck: .DATA file or string with deck
deck: :term:`.DATA file` or string with deck
keyword: VFP table type, i.e. 'VFPPROD' or 'VFPINJ'
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
Expand Down Expand Up @@ -250,7 +250,7 @@ def dfs(
Data for the keyword VFPPROD or VFPINJ will be returned as separate item in list
Args:
deck: .DATA file or string with deck
deck: :term:`.DATA file` or string with deck
keyword: VFP table type, i.e. 'VFPPROD' or 'VFPINJ'
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
Expand Down Expand Up @@ -293,7 +293,7 @@ def pyarrow_tables(
Data for the keyword VFPPROD or VFPINJ will be returned as separate item in list
Args:
deck: .DATA file or string with deck
deck: :term:`.DATA file` or string with deck
keyword: VFP table type, i.e. 'VFPPROD' or 'VFPINJ'
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
Expand Down Expand Up @@ -418,7 +418,7 @@ def df(
All data for the keywords VFPPROD/VFPINJ will be returned.
Args:
deck: .DATA file or string wit deck
deck: :term:`.DATA file` or string wit deck
keyword: VFP table type, i.e. 'VFPPROD' or 'VFPINJ'
vfpnumbers_str: str with list of VFP table numbers to extract
"""
Expand Down
2 changes: 1 addition & 1 deletion res2df/vfp/_vfpcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
deck to extract the VFPPROD/VFPINJ data from an Eclipse (input) deck as Pandas
Dataframes
Data can be extracted from a full .DATA file or from individual files. Supports
Data can be extracted from a full :term:`.DATA file` or from individual files. Supports
output both in csv format as a pandas DataFrame or in pyarrow and pyarrow.table
"""

Expand Down
12 changes: 6 additions & 6 deletions res2df/vfp/_vfpinj.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
basic_data (dictionary with basic data types), df (pandas DataFrame) or
pyarrow_tables (pyarrow.Tables).
Data can be extracted from a full .DATA file or from individual files.
Data can be extracted from a full :term:`.DATA file` or from individual files.
Supports output both in csv format as a pandas DataFrame or in pyarrow
a pyarrow.Table. Also functionality to write pandas DataFrame and
pyarrow.Table to file as Eclipse .Ecl format
Expand Down Expand Up @@ -74,7 +74,7 @@ def basic_data(
Empty string returned if vfp table number does not match any number in list
Args:
keyword: .DATA file keyword
keyword: :term:`.DATA file` keyword
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds
"""
Expand Down Expand Up @@ -473,12 +473,12 @@ def df(
keyword: "opm.libopmcommon_python.DeckKeyword",
vfpnumbers_str: Optional[str] = None,
) -> Union[pd.DataFrame, None]:
"""Return a dataframes of a single VFPINJ table from a .DATA file
"""Return a dataframes of a single VFPINJ table from a :term:`.DATA file`
Data from the VFPINJ keyword are stacked into a Pandas Dataframe
Args:
keyword: .DATA file keyword
keyword: :term:`.DATA file` keyword
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
"""
Expand Down Expand Up @@ -510,11 +510,11 @@ def pyarrow(
keyword: "opm.libopmcommon_python.DeckKeyword",
vfpnumbers_str: Optional[str] = None,
) -> Union[pa.Table, None]:
"""Return a pyarrow Table of a single VFPINJ table from a .DATA file
"""Return a pyarrow Table of a single VFPINJ table from a :term:`.DATA file`
If no VFPINJ table found, return None
Args:
keyword: .DATA file keyword
keyword: :term:`.DATA file` keyword
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
"""
Expand Down
12 changes: 6 additions & 6 deletions res2df/vfp/_vfpprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
basic_data (dictionary with basic data types), df (pandas DataFrame) or
pyarrow_tables (pyarrow.Tables).
Data can be extracted from a full .DATA file or from individual files.
Data can be extracted from a full :term:`.DATA file` or from individual files.
Supports output both in csv format as a pandas DataFrame or in pyarrow
as pyarrow.Table. Also functionality to write pandas DataFrame and
pyarrow.Table to file as Eclipse .Ecl format.
Expand Down Expand Up @@ -86,7 +86,7 @@ def basic_data(
Empty string returned if vfp table number does not match any number in list
Args:
keyword: .DATA file keyword
keyword: :term:`.DATA file` keyword
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds
"""
Expand Down Expand Up @@ -720,10 +720,10 @@ def df(
vfpnumbers_str: Optional[str] = None,
) -> Union[pd.DataFrame, None]:
"""Return a dataframe or pyarrow Table of a single VFPPROD table
from a .DATA file.
from a :term:`.DATA file`.
Args:
keyword: .DATA file keyword
keyword: :term:`.DATA file` keyword
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
"""
Expand Down Expand Up @@ -764,11 +764,11 @@ def pyarrow(
keyword: "opm.libopmcommon_python.DeckKeyword",
vfpnumbers_str: Optional[str] = None,
) -> Union[pa.Table, None]:
"""Return a pyarrow Table of a single VFPPROD table from a .DATA file.
"""Return a pyarrow Table of a single VFPPROD table from a :term:`.DATA file`.
If no VFPPROD curve found, return None
Args:
keyword: .DATA file keyword
keyword: :term:`.DATA file` keyword
vfpnumbers_str: String with list of vfp table numbers to extract.
Syntax "[0,1,8:11]" corresponds to [0,1,8,9,10,11].
"""
Expand Down
2 changes: 1 addition & 1 deletion res2df/wcon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Extract WCON* from a .DATA file"""
"""Extract WCON* from a :term:`.DATA file`"""

import argparse
import datetime
Expand Down
2 changes: 1 addition & 1 deletion res2df/wellcompletiondata.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def df(


def _get_unit_system(resdatafiles: ResdataFiles) -> UnitSystem:
"""Returns the unit system of a .DATA file. The options are \
"""Returns the unit system of a :term:`.DATA file`. The options are \
METRIC, FIELD, LAB and PVT-M.
If none of these are found, the function returns METRIC which is the
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gruptree.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def test_emptytree_strdeck():


def test_emptytree_commandlinetool(tmp_path, mocker, caplog):
"""Test the command line tool on a .DATA file which is empty"""
"""Test the command line tool on a :term:`.DATA file` which is empty"""
os.chdir(tmp_path)
Path("EMPTY.DATA").write_text("", encoding="utf8")
mocker.patch("sys.argv", ["res2csv", "gruptree", "--prettyprint", "EMPTY.DATA"])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_satfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def test_deck_to_satfunc_dframe():
"""Test that dataframes can be produced from a full .DATA file (the
"""Test that dataframes can be produced from a full :term:`.DATA file` (the
example Reek case)"""
resdatafiles = ResdataFiles(REEK)
satdf = satfunc.df(resdatafiles.get_deck())
Expand Down
4 changes: 3 additions & 1 deletion tests/test_welopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,9 @@ def test_welopen_df():
],
)
def test_welopen_complump(test_input, expected):
"""Test the welopen_complump functionality through .DATA files"""
"""Test the welopen_complump functionality through
:term:`.DATA files <.DATA file>`
"""
deck = ResdataFiles.str2deck(test_input)
dfs = compdat.deck2dfs(deck)
pd.testing.assert_frame_equal(dfs["COMPDAT"][expected.columns], expected)
Expand Down

0 comments on commit 033c798

Please sign in to comment.