res2df 1.3.8__py3-none-any.whl → 1.3.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- res2df/__init__.py +43 -4
- res2df/__version__.py +1 -1
- res2df/common.py +22 -22
- res2df/compdat.py +7 -8
- res2df/csv2res.py +1 -1
- res2df/equil.py +60 -60
- res2df/faults.py +3 -7
- res2df/fipreports.py +1 -1
- res2df/grid.py +5 -5
- res2df/gruptree.py +4 -6
- res2df/hook_implementations/forward_model_steps.py +11 -8
- res2df/inferdims.py +1 -4
- res2df/nnc.py +1 -1
- res2df/pillars.py +2 -2
- res2df/pvt.py +8 -11
- res2df/py.typed +0 -0
- res2df/res2csv.py +3 -5
- res2df/resdatafiles.py +20 -27
- res2df/rft.py +2 -3
- res2df/satfunc.py +4 -7
- res2df/summary.py +9 -14
- res2df/trans.py +1 -1
- res2df/version.py +2 -2
- res2df/vfp/__init__.py +18 -1
- res2df/vfp/_vfp.py +8 -12
- res2df/vfp/_vfpcommon.py +21 -19
- res2df/wcon.py +3 -6
- res2df/wellcompletiondata.py +7 -2
- res2df/wellconnstatus.py +1 -1
- res2df-1.3.10.dist-info/METADATA +94 -0
- {res2df-1.3.8.dist-info → res2df-1.3.10.dist-info}/RECORD +35 -34
- res2df-1.3.8.dist-info/METADATA +0 -768
- {res2df-1.3.8.dist-info → res2df-1.3.10.dist-info}/WHEEL +0 -0
- {res2df-1.3.8.dist-info → res2df-1.3.10.dist-info}/entry_points.txt +0 -0
- {res2df-1.3.8.dist-info → res2df-1.3.10.dist-info}/licenses/LICENSE +0 -0
- {res2df-1.3.8.dist-info → res2df-1.3.10.dist-info}/top_level.txt +0 -0
res2df/__init__.py
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
from . import compdat as compdat
|
|
2
|
+
from . import csv2res as csv2res
|
|
3
|
+
from . import equil as equil
|
|
4
|
+
from . import faults as faults
|
|
5
|
+
from . import fipreports as fipreports
|
|
6
|
+
from . import grid as grid
|
|
7
|
+
from . import gruptree as gruptree
|
|
8
|
+
from . import nnc as nnc
|
|
9
|
+
from . import pillars as pillars
|
|
10
|
+
from . import pvt as pvt
|
|
11
|
+
from . import res2csv as res2csv
|
|
12
|
+
from . import rft as rft
|
|
13
|
+
from . import satfunc as satfunc
|
|
14
|
+
from . import summary as summary
|
|
15
|
+
from . import trans as trans
|
|
16
|
+
from . import vfp as vfp
|
|
17
|
+
from . import wcon as wcon
|
|
18
|
+
from . import wellcompletiondata as wellcompletiondata
|
|
19
|
+
from . import wellconnstatus as wellconnstatus
|
|
3
20
|
from .__version__ import __version__ as __version__
|
|
4
21
|
from .res2csvlogger import getLogger_res2csv as getLogger_res2csv
|
|
5
22
|
from .resdatafiles import ResdataFiles as ResdataFiles
|
|
@@ -25,5 +42,27 @@ SUBMODULES: list[str] = [
|
|
|
25
42
|
]
|
|
26
43
|
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
__all__ = [
|
|
46
|
+
"ResdataFiles",
|
|
47
|
+
"__version__",
|
|
48
|
+
"compdat",
|
|
49
|
+
"csv2res",
|
|
50
|
+
"equil",
|
|
51
|
+
"faults",
|
|
52
|
+
"fipreports",
|
|
53
|
+
"getLogger_res2csv",
|
|
54
|
+
"grid",
|
|
55
|
+
"gruptree",
|
|
56
|
+
"nnc",
|
|
57
|
+
"pillars",
|
|
58
|
+
"pvt",
|
|
59
|
+
"res2csv",
|
|
60
|
+
"rft",
|
|
61
|
+
"satfunc",
|
|
62
|
+
"summary",
|
|
63
|
+
"trans",
|
|
64
|
+
"vfp",
|
|
65
|
+
"wcon",
|
|
66
|
+
"wellcompletiondata",
|
|
67
|
+
"wellconnstatus",
|
|
68
|
+
]
|
res2df/__version__.py
CHANGED
res2df/common.py
CHANGED
|
@@ -11,28 +11,24 @@ import shlex
|
|
|
11
11
|
import signal
|
|
12
12
|
import sys
|
|
13
13
|
from collections import defaultdict
|
|
14
|
+
from collections.abc import Mapping
|
|
14
15
|
from importlib import resources
|
|
15
16
|
from pathlib import Path
|
|
16
17
|
from typing import Any, cast
|
|
17
18
|
|
|
18
19
|
import dateutil.parser
|
|
19
20
|
import numpy as np
|
|
21
|
+
import opm.io.deck
|
|
20
22
|
import pandas as pd
|
|
21
23
|
import pyarrow as pa
|
|
24
|
+
|
|
25
|
+
# This import is seemingly not used, but necessary for some attributes
|
|
26
|
+
# to be included in DeckItem objects.
|
|
27
|
+
from opm.io.deck import DeckKeyword # noqa: F401
|
|
22
28
|
from pyarrow import (
|
|
23
29
|
feather, # necessary as this module is not loaded unless explicitly imported
|
|
24
30
|
)
|
|
25
31
|
|
|
26
|
-
try:
|
|
27
|
-
import opm.io.deck
|
|
28
|
-
|
|
29
|
-
# This import is seemingly not used, but necessary for some attributes
|
|
30
|
-
# to be included in DeckItem objects.
|
|
31
|
-
from opm.io.deck import DeckKeyword # noqa: F401
|
|
32
|
-
except ImportError:
|
|
33
|
-
# Allow parts of res2df to work without OPM:
|
|
34
|
-
pass
|
|
35
|
-
|
|
36
32
|
from .__version__ import __version__
|
|
37
33
|
from .constants import MAGIC_STDOUT
|
|
38
34
|
|
|
@@ -189,9 +185,9 @@ def datetime_to_ecldate(timestamp: str | datetime.datetime | datetime.date) -> s
|
|
|
189
185
|
|
|
190
186
|
|
|
191
187
|
def keyworddata_to_df(
|
|
192
|
-
deck,
|
|
188
|
+
deck: "opm.opmcommon_python.Deck",
|
|
193
189
|
keyword: str,
|
|
194
|
-
renamer:
|
|
190
|
+
renamer: Mapping[str, str | list[str]] | None = None,
|
|
195
191
|
recordcountername: str | None = None,
|
|
196
192
|
emptyrecordcountername: str | None = None,
|
|
197
193
|
) -> pd.DataFrame:
|
|
@@ -275,7 +271,7 @@ def parse_opmio_deckrecord(
|
|
|
275
271
|
keyword: str,
|
|
276
272
|
itemlistname: str = "items",
|
|
277
273
|
recordindex: int | None = None,
|
|
278
|
-
renamer:
|
|
274
|
+
renamer: Mapping[str, str | list[str]] | None = None,
|
|
279
275
|
) -> dict[str, Any]:
|
|
280
276
|
"""
|
|
281
277
|
Parse an opm.io.DeckRecord belonging to a certain keyword
|
|
@@ -344,8 +340,9 @@ def parse_opmio_deckrecord(
|
|
|
344
340
|
if renamer:
|
|
345
341
|
renamed_dict: dict[str, Any] = {}
|
|
346
342
|
for key, value in rec_dict.items():
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
renamed_key = renamer.get(key)
|
|
344
|
+
if isinstance(renamed_key, str):
|
|
345
|
+
renamed_dict[renamed_key] = value
|
|
349
346
|
else:
|
|
350
347
|
renamed_dict[key] = value
|
|
351
348
|
return renamed_dict
|
|
@@ -470,7 +467,7 @@ def handle_wanted_keywords(
|
|
|
470
467
|
|
|
471
468
|
def fill_reverse_parser(
|
|
472
469
|
parser: argparse.ArgumentParser, modulename: str, defaultoutputfile: str
|
|
473
|
-
):
|
|
470
|
+
) -> argparse.ArgumentParser:
|
|
474
471
|
"""A standardized submodule parser for the command line utility
|
|
475
472
|
to produce :term:`include files <include file>` from a CSV file.
|
|
476
473
|
|
|
@@ -543,6 +540,7 @@ def df2res(
|
|
|
543
540
|
"""
|
|
544
541
|
from_module = inspect.stack()[1]
|
|
545
542
|
calling_module = inspect.getmodule(from_module[0])
|
|
543
|
+
assert calling_module is not None
|
|
546
544
|
if dataframe.empty:
|
|
547
545
|
raise ValueError("Empty dataframe")
|
|
548
546
|
if (
|
|
@@ -580,7 +578,7 @@ def df2res(
|
|
|
580
578
|
if not_supported:
|
|
581
579
|
logger.warning(
|
|
582
580
|
"Requested keyword(s) not supported by %s: %s",
|
|
583
|
-
calling_module.__name__,
|
|
581
|
+
calling_module.__name__,
|
|
584
582
|
not_supported,
|
|
585
583
|
)
|
|
586
584
|
# Warn if some requested keywords are not in frame:
|
|
@@ -601,7 +599,7 @@ def df2res(
|
|
|
601
599
|
string = ""
|
|
602
600
|
res2df_header = (
|
|
603
601
|
"Output file printed by "
|
|
604
|
-
+ calling_module.__name__
|
|
602
|
+
+ calling_module.__name__
|
|
605
603
|
+ " "
|
|
606
604
|
+ __version__
|
|
607
605
|
+ "\n"
|
|
@@ -631,7 +629,7 @@ def generic_deck_table(
|
|
|
631
629
|
dframe: pd.DataFrame,
|
|
632
630
|
keyword: str,
|
|
633
631
|
comment: str | None = None,
|
|
634
|
-
renamer:
|
|
632
|
+
renamer: Mapping[str, str] | None = None,
|
|
635
633
|
drop_trailing_columns: bool = True,
|
|
636
634
|
) -> str:
|
|
637
635
|
"""Construct string contents of a :term:`.DATA file` table.
|
|
@@ -855,7 +853,7 @@ def is_color(input_string: str) -> bool:
|
|
|
855
853
|
return bool(re.match(regex, input_string))
|
|
856
854
|
|
|
857
855
|
|
|
858
|
-
def parse_lyrfile(filename: str) -> list[dict[str, Any]] | None:
|
|
856
|
+
def parse_lyrfile(filename: str | Path) -> list[dict[str, Any]] | None:
|
|
859
857
|
"""Return a list of dicts representation of the lyr file.
|
|
860
858
|
|
|
861
859
|
The lyr file contains data of the following format,
|
|
@@ -927,7 +925,9 @@ def parse_lyrfile(filename: str) -> list[dict[str, Any]] | None:
|
|
|
927
925
|
return lyrlist
|
|
928
926
|
|
|
929
927
|
|
|
930
|
-
def convert_lyrlist_to_zonemap(
|
|
928
|
+
def convert_lyrlist_to_zonemap(
|
|
929
|
+
lyrlist: list[dict[str, Any]] | None,
|
|
930
|
+
) -> dict[int, str] | None:
|
|
931
931
|
"""Returns a layer to zone map as a dictionary
|
|
932
932
|
|
|
933
933
|
Args:
|
|
@@ -949,7 +949,7 @@ def convert_lyrlist_to_zonemap(lyrlist: list[dict[str, Any]]) -> dict[int, str]:
|
|
|
949
949
|
return zonemap
|
|
950
950
|
|
|
951
951
|
|
|
952
|
-
def get_wells_matching_template(template: str, wells: list):
|
|
952
|
+
def get_wells_matching_template(template: str, wells: list[str]) -> list[str]:
|
|
953
953
|
"""Returns the wells in the list that is matching the template
|
|
954
954
|
containing wilcard characters. The wildcard charachters supported
|
|
955
955
|
are * to match zero or more charachters and ? to match a single
|
res2df/compdat.py
CHANGED
|
@@ -11,16 +11,14 @@
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
import argparse
|
|
14
|
-
import contextlib
|
|
15
14
|
import datetime
|
|
16
15
|
import logging
|
|
16
|
+
from typing import Any
|
|
17
17
|
|
|
18
18
|
import numpy as np
|
|
19
|
+
import opm.io.deck
|
|
19
20
|
import pandas as pd
|
|
20
21
|
|
|
21
|
-
with contextlib.suppress(ImportError):
|
|
22
|
-
import opm.io.deck
|
|
23
|
-
|
|
24
22
|
from .common import (
|
|
25
23
|
get_wells_matching_template,
|
|
26
24
|
merge_zones,
|
|
@@ -97,6 +95,7 @@ def deck2dfs(
|
|
|
97
95
|
complumprecords = []
|
|
98
96
|
welspecs = {}
|
|
99
97
|
date = start_date # DATE column will always be there, but can contain NaN/None
|
|
98
|
+
rec_data: dict[str, Any]
|
|
100
99
|
for idx, kword in enumerate(deck):
|
|
101
100
|
if kword.name in ["DATES", "START"]:
|
|
102
101
|
for rec in kword:
|
|
@@ -752,7 +751,7 @@ def expand_complump_in_welopen_df(
|
|
|
752
751
|
exp_welopens.append(cell_row)
|
|
753
752
|
|
|
754
753
|
dframe = pd.DataFrame(exp_welopens)
|
|
755
|
-
return dframe.astype(object).where(pd.notna(dframe), None)
|
|
754
|
+
return dframe.astype(object).where(pd.notna(dframe), None) # type: ignore[call-overload]
|
|
756
755
|
|
|
757
756
|
|
|
758
757
|
def expand_wlist_in_welopen_df(
|
|
@@ -786,7 +785,7 @@ def expand_wlist_in_welopen_df(
|
|
|
786
785
|
# Explicit wellname was used, no expansion to happen:
|
|
787
786
|
exp_welopens.append(row)
|
|
788
787
|
dframe = pd.DataFrame(exp_welopens)
|
|
789
|
-
return dframe.astype(object).where(pd.notna(dframe), None)
|
|
788
|
+
return dframe.astype(object).where(pd.notna(dframe), None) # type: ignore[call-overload]
|
|
790
789
|
|
|
791
790
|
|
|
792
791
|
def applywelopen(
|
|
@@ -845,7 +844,7 @@ def applywelopen(
|
|
|
845
844
|
"The WLIST dataframe must be expanded through expand_wlist()"
|
|
846
845
|
)
|
|
847
846
|
|
|
848
|
-
welopen_df = welopen_df.astype(object).where(pd.notna(welopen_df), None)
|
|
847
|
+
welopen_df = welopen_df.astype(object).where(pd.notna(welopen_df), None) # type: ignore[call-overload]
|
|
849
848
|
if wlist_df is not None:
|
|
850
849
|
welopen_df = expand_wlist_in_welopen_df(welopen_df, wlist_df)
|
|
851
850
|
if complump_df is not None:
|
|
@@ -951,7 +950,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
|
951
950
|
return parser
|
|
952
951
|
|
|
953
952
|
|
|
954
|
-
def compdat_main(args):
|
|
953
|
+
def compdat_main(args: argparse.Namespace) -> None:
|
|
955
954
|
"""Entry-point for module, for command line utility"""
|
|
956
955
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
957
956
|
resdatafiles = ResdataFiles(args.DATAFILE)
|
res2df/csv2res.py
CHANGED
|
@@ -34,7 +34,7 @@ def get_parser() -> argparse.ArgumentParser:
|
|
|
34
34
|
version=f"%(prog)s {__version__}",
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
subparsers = parser.add_subparsers(
|
|
37
|
+
subparsers = parser.add_subparsers(
|
|
38
38
|
required=True,
|
|
39
39
|
dest="subcommand",
|
|
40
40
|
parser_class=argparse.ArgumentParser,
|
res2df/equil.py
CHANGED
|
@@ -3,11 +3,12 @@ Extract EQUIL from a :term:`.DATA file` as Pandas DataFrame
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
|
-
import contextlib
|
|
7
6
|
import logging
|
|
8
7
|
from collections.abc import Container
|
|
9
8
|
from pathlib import Path
|
|
9
|
+
from typing import Final
|
|
10
10
|
|
|
11
|
+
import opm.io
|
|
11
12
|
import pandas as pd
|
|
12
13
|
|
|
13
14
|
from .common import (
|
|
@@ -24,57 +25,56 @@ from .inferdims import DIMS_POS, inject_xxxdims_ntxxx
|
|
|
24
25
|
from .res2csvlogger import getLogger_res2csv
|
|
25
26
|
from .resdatafiles import ResdataFiles
|
|
26
27
|
|
|
27
|
-
with contextlib.suppress(ImportError):
|
|
28
|
-
import opm.io
|
|
29
|
-
|
|
30
|
-
|
|
31
28
|
logger = logging.getLogger(__name__)
|
|
32
29
|
|
|
33
|
-
SUPPORTED_KEYWORDS: list[str] = ["EQUIL", "PBVD", "PDVD", "RSVD", "RVVD"]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
RENAMERS["oil-water-gas"] = {
|
|
40
|
-
"DATUM_DEPTH": "Z",
|
|
41
|
-
"DATUM_PRESSURE": "PRESSURE",
|
|
42
|
-
"OWC": "OWC",
|
|
43
|
-
"PC_OWC": "PCOWC",
|
|
44
|
-
"GOC": "GOC",
|
|
45
|
-
"PC_GOC": "PCGOC",
|
|
46
|
-
"BLACK_OIL_INIT": "INITRS",
|
|
47
|
-
"BLACK_OIL_INIT_WG": "INITRV",
|
|
48
|
-
}
|
|
49
|
-
RENAMERS["gas-water"] = {
|
|
50
|
-
"DATUM_DEPTH": "Z",
|
|
51
|
-
"DATUM_PRESSURE": "PRESSURE",
|
|
52
|
-
"OWC": "GWC",
|
|
53
|
-
"PC_OWC": "PCGWC",
|
|
54
|
-
"GOC": "IGNORE1",
|
|
55
|
-
"PC_GOC": "IGNORE2",
|
|
56
|
-
"BLACK_OIL_INIT": "IGNORE3",
|
|
57
|
-
"BLACK_OIL_INIT_WG": "IGNORE4",
|
|
58
|
-
}
|
|
59
|
-
RENAMERS["oil-water"] = {
|
|
60
|
-
"DATUM_DEPTH": "Z",
|
|
61
|
-
"DATUM_PRESSURE": "PRESSURE",
|
|
62
|
-
"OWC": "OWC",
|
|
63
|
-
"PC_OWC": "PCOWC",
|
|
64
|
-
"GOC": "IGNORE1",
|
|
65
|
-
"PC_GOC": "IGNORE2",
|
|
66
|
-
"BLACK_OIL_INIT": "IGNORE3",
|
|
67
|
-
"BLACK_OIL_INIT_WG": "IGNORE4",
|
|
30
|
+
SUPPORTED_KEYWORDS: Final[list[str]] = ["EQUIL", "PBVD", "PDVD", "RSVD", "RVVD"]
|
|
31
|
+
TABLE_RENAMERS: Final[dict[str, dict[str, list[str]]]] = {
|
|
32
|
+
"PBVD": {"DATA": ["Z", "PB"]},
|
|
33
|
+
"PDVD": {"DATA": ["Z", "PD"]},
|
|
34
|
+
"RSVD": {"DATA": ["Z", "RS"]},
|
|
35
|
+
"RVVD": {"DATA": ["Z", "RV"]},
|
|
68
36
|
}
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
37
|
+
PHASE_RENAMERS: Final[dict[str, dict[str, str]]] = {
|
|
38
|
+
"oil-water-gas": {
|
|
39
|
+
"DATUM_DEPTH": "Z",
|
|
40
|
+
"DATUM_PRESSURE": "PRESSURE",
|
|
41
|
+
"OWC": "OWC",
|
|
42
|
+
"PC_OWC": "PCOWC",
|
|
43
|
+
"GOC": "GOC",
|
|
44
|
+
"PC_GOC": "PCGOC",
|
|
45
|
+
"BLACK_OIL_INIT": "INITRS",
|
|
46
|
+
"BLACK_OIL_INIT_WG": "INITRV",
|
|
47
|
+
},
|
|
48
|
+
"gas-water": {
|
|
49
|
+
"DATUM_DEPTH": "Z",
|
|
50
|
+
"DATUM_PRESSURE": "PRESSURE",
|
|
51
|
+
"OWC": "GWC",
|
|
52
|
+
"PC_OWC": "PCGWC",
|
|
53
|
+
"GOC": "IGNORE1",
|
|
54
|
+
"PC_GOC": "IGNORE2",
|
|
55
|
+
"BLACK_OIL_INIT": "IGNORE3",
|
|
56
|
+
"BLACK_OIL_INIT_WG": "IGNORE4",
|
|
57
|
+
},
|
|
58
|
+
"oil-water": {
|
|
59
|
+
"DATUM_DEPTH": "Z",
|
|
60
|
+
"DATUM_PRESSURE": "PRESSURE",
|
|
61
|
+
"OWC": "OWC",
|
|
62
|
+
"PC_OWC": "PCOWC",
|
|
63
|
+
"GOC": "IGNORE1",
|
|
64
|
+
"PC_GOC": "IGNORE2",
|
|
65
|
+
"BLACK_OIL_INIT": "IGNORE3",
|
|
66
|
+
"BLACK_OIL_INIT_WG": "IGNORE4",
|
|
67
|
+
},
|
|
68
|
+
"oil-gas": {
|
|
69
|
+
"DATUM_DEPTH": "Z",
|
|
70
|
+
"DATUM_PRESSURE": "PRESSURE",
|
|
71
|
+
"OWC": "IGNORE1",
|
|
72
|
+
"PC_OWC": "IGNORE2",
|
|
73
|
+
"GOC": "GOC",
|
|
74
|
+
"PC_GOC": "PCGOC",
|
|
75
|
+
"BLACK_OIL_INIT": "IGNORE3",
|
|
76
|
+
"BLACK_OIL_INIT_WG": "IGNORE4",
|
|
77
|
+
},
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
|
|
@@ -149,7 +149,7 @@ def rsvd_fromdeck(
|
|
|
149
149
|
if "EQLDIMS" not in deck:
|
|
150
150
|
deck = inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
|
|
151
151
|
return keyworddata_to_df(
|
|
152
|
-
deck, "RSVD", renamer=
|
|
152
|
+
deck, "RSVD", renamer=TABLE_RENAMERS["RSVD"], recordcountername="EQLNUM"
|
|
153
153
|
)
|
|
154
154
|
|
|
155
155
|
|
|
@@ -166,7 +166,7 @@ def rvvd_fromdeck(
|
|
|
166
166
|
if "EQLDIMS" not in deck:
|
|
167
167
|
deck = inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
|
|
168
168
|
return keyworddata_to_df(
|
|
169
|
-
deck, "RVVD", renamer=
|
|
169
|
+
deck, "RVVD", renamer=TABLE_RENAMERS["RVVD"], recordcountername="EQLNUM"
|
|
170
170
|
)
|
|
171
171
|
|
|
172
172
|
|
|
@@ -183,7 +183,7 @@ def pbvd_fromdeck(
|
|
|
183
183
|
if "EQLDIMS" not in deck:
|
|
184
184
|
deck = inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
|
|
185
185
|
return keyworddata_to_df(
|
|
186
|
-
deck, "PBVD", renamer=
|
|
186
|
+
deck, "PBVD", renamer=TABLE_RENAMERS["PBVD"], recordcountername="EQLNUM"
|
|
187
187
|
)
|
|
188
188
|
|
|
189
189
|
|
|
@@ -200,7 +200,7 @@ def pdvd_fromdeck(
|
|
|
200
200
|
if "EQLDIMS" not in deck:
|
|
201
201
|
deck = inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
|
|
202
202
|
return keyworddata_to_df(
|
|
203
|
-
deck, "PDVD", renamer=
|
|
203
|
+
deck, "PDVD", renamer=TABLE_RENAMERS["PDVD"], recordcountername="EQLNUM"
|
|
204
204
|
)
|
|
205
205
|
|
|
206
206
|
|
|
@@ -267,9 +267,9 @@ def equil_fromdeck(
|
|
|
267
267
|
deck = inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
|
|
268
268
|
|
|
269
269
|
phases = phases_from_deck(deck)
|
|
270
|
-
if not phases or phases not in
|
|
270
|
+
if not phases or phases not in PHASE_RENAMERS:
|
|
271
271
|
raise ValueError(f"Could not determine phase configuration, got '{phases}'")
|
|
272
|
-
columnrenamer =
|
|
272
|
+
columnrenamer = PHASE_RENAMERS[phases]
|
|
273
273
|
|
|
274
274
|
dataframe = keyworddata_to_df(
|
|
275
275
|
deck, "EQUIL", renamer=columnrenamer, recordcountername="EQLNUM"
|
|
@@ -318,7 +318,7 @@ def fill_reverse_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentPar
|
|
|
318
318
|
return common_fill_reverse_parser(parser, "EQUIL, RSVD++", "solution.inc")
|
|
319
319
|
|
|
320
320
|
|
|
321
|
-
def equil_main(args) -> None:
|
|
321
|
+
def equil_main(args: argparse.Namespace) -> None:
|
|
322
322
|
"""Read from disk and write CSV back to disk"""
|
|
323
323
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
324
324
|
resdatafiles = ResdataFiles(args.DATAFILE)
|
|
@@ -348,7 +348,7 @@ def equil_main(args) -> None:
|
|
|
348
348
|
)
|
|
349
349
|
|
|
350
350
|
|
|
351
|
-
def equil_reverse_main(args) -> None:
|
|
351
|
+
def equil_reverse_main(args: argparse.Namespace) -> None:
|
|
352
352
|
"""Entry-point for module, for command line utility
|
|
353
353
|
for CSV to reservoir simulator :term:`include files <include file>`
|
|
354
354
|
"""
|
|
@@ -424,7 +424,7 @@ def df2res_equil(dframe: pd.DataFrame, comment: str | None = None) -> str:
|
|
|
424
424
|
return generic_deck_table(
|
|
425
425
|
subset,
|
|
426
426
|
"EQUIL",
|
|
427
|
-
renamer=
|
|
427
|
+
renamer=PHASE_RENAMERS[phases],
|
|
428
428
|
comment=comment,
|
|
429
429
|
drop_trailing_columns=False,
|
|
430
430
|
)
|
|
@@ -471,7 +471,7 @@ def df2res_pbvd(dframe: pd.DataFrame, comment: str | None = None) -> str:
|
|
|
471
471
|
return _df2res_equilfuncs("PBVD", dframe, comment)
|
|
472
472
|
|
|
473
473
|
|
|
474
|
-
def df2res_pdvd(dframe: pd.DataFrame, comment: str | None = None):
|
|
474
|
+
def df2res_pdvd(dframe: pd.DataFrame, comment: str | None = None) -> str:
|
|
475
475
|
"""Create string with :term:`include file` contents for PDVD keyword.
|
|
476
476
|
|
|
477
477
|
Dew-point versus depth.
|
|
@@ -494,7 +494,7 @@ def _df2res_equilfuncs(
|
|
|
494
494
|
return "-- No data!"
|
|
495
495
|
string = f"{keyword}\n"
|
|
496
496
|
string += comment_formatter(comment)
|
|
497
|
-
col_headers =
|
|
497
|
+
col_headers = TABLE_RENAMERS[keyword]["DATA"]
|
|
498
498
|
|
|
499
499
|
string += f"-- {'DEPTH':^21} {col_headers[1]:^21} \n"
|
|
500
500
|
# Use everything if KEYWORD not in dframe..
|
res2df/faults.py
CHANGED
|
@@ -6,20 +6,16 @@ a DataFrame
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import argparse
|
|
9
|
-
import contextlib
|
|
10
9
|
import logging
|
|
11
10
|
|
|
11
|
+
# Needed for mypy
|
|
12
|
+
import opm.io
|
|
12
13
|
import pandas as pd
|
|
13
14
|
|
|
14
15
|
from .common import parse_opmio_deckrecord, write_dframe_stdout_file
|
|
15
16
|
from .res2csvlogger import getLogger_res2csv
|
|
16
17
|
from .resdatafiles import ResdataFiles
|
|
17
18
|
|
|
18
|
-
with contextlib.suppress(ImportError):
|
|
19
|
-
# Needed for mypy
|
|
20
|
-
import opm.io
|
|
21
|
-
|
|
22
|
-
|
|
23
19
|
logger = logging.getLogger(__name__)
|
|
24
20
|
|
|
25
21
|
RECORD_COLUMNS = ["NAME", "IX1", "IX2", "IY1", "IY2", "IZ1", "IZ2", "FACE"]
|
|
@@ -80,7 +76,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
|
80
76
|
return parser
|
|
81
77
|
|
|
82
78
|
|
|
83
|
-
def faults_main(args) -> None:
|
|
79
|
+
def faults_main(args: argparse.Namespace) -> None:
|
|
84
80
|
"""Read from disk and write CSV back to disk"""
|
|
85
81
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
86
82
|
resdatafiles = ResdataFiles(args.DATAFILE)
|
res2df/fipreports.py
CHANGED
|
@@ -207,7 +207,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
|
207
207
|
return parser
|
|
208
208
|
|
|
209
209
|
|
|
210
|
-
def fipreports_main(args) -> None:
|
|
210
|
+
def fipreports_main(args: argparse.Namespace) -> None:
|
|
211
211
|
"""Command line API"""
|
|
212
212
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
213
213
|
if args.PRTFILE.endswith(".PRT"):
|
res2df/grid.py
CHANGED
|
@@ -216,10 +216,10 @@ def rst2df(
|
|
|
216
216
|
# Filter the rst vectors once more, all of them
|
|
217
217
|
# might not be available at all timesteps:
|
|
218
218
|
present_rstvectors = []
|
|
219
|
-
for
|
|
219
|
+
for rst_vec in rstvectors:
|
|
220
220
|
try:
|
|
221
|
-
if resdatafiles.get_rstfile().iget_named_kw(
|
|
222
|
-
present_rstvectors.append(
|
|
221
|
+
if resdatafiles.get_rstfile().iget_named_kw(rst_vec, rstindex):
|
|
222
|
+
present_rstvectors.append(rst_vec)
|
|
223
223
|
except IndexError:
|
|
224
224
|
pass
|
|
225
225
|
logger.info(
|
|
@@ -481,7 +481,7 @@ def df(
|
|
|
481
481
|
dateinheaders: bool = False,
|
|
482
482
|
stackdates: bool = False,
|
|
483
483
|
zonemap: dict[int, str] | None = None,
|
|
484
|
-
):
|
|
484
|
+
) -> pd.DataFrame:
|
|
485
485
|
"""Produce a dataframe with grid information
|
|
486
486
|
|
|
487
487
|
Grid information (center coordinates x, y, z), cell
|
|
@@ -759,7 +759,7 @@ def df2res(
|
|
|
759
759
|
return string
|
|
760
760
|
|
|
761
761
|
|
|
762
|
-
def grid_main(args) -> None:
|
|
762
|
+
def grid_main(args: argparse.Namespace) -> None:
|
|
763
763
|
"""This is the command line API"""
|
|
764
764
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
765
765
|
resdatafiles = ResdataFiles(args.DATAFILE)
|
res2df/gruptree.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
4
|
import collections
|
|
5
|
-
import contextlib
|
|
6
5
|
import datetime
|
|
7
6
|
import logging
|
|
8
7
|
import sys
|
|
@@ -10,13 +9,12 @@ import warnings
|
|
|
10
9
|
from typing import Any
|
|
11
10
|
|
|
12
11
|
import numpy as np
|
|
12
|
+
|
|
13
|
+
# Needed for mypy
|
|
14
|
+
import opm.io
|
|
13
15
|
import pandas as pd
|
|
14
16
|
import treelib
|
|
15
17
|
|
|
16
|
-
with contextlib.suppress(ImportError):
|
|
17
|
-
# Needed for mypy
|
|
18
|
-
import opm.io
|
|
19
|
-
|
|
20
18
|
from .common import (
|
|
21
19
|
OPMKEYWORDS,
|
|
22
20
|
parse_opmio_date_rec,
|
|
@@ -457,7 +455,7 @@ def prettyprint(dframe: pd.DataFrame) -> str:
|
|
|
457
455
|
return output
|
|
458
456
|
|
|
459
457
|
|
|
460
|
-
def gruptree_main(args) -> None:
|
|
458
|
+
def gruptree_main(args: argparse.Namespace) -> None:
|
|
461
459
|
"""Entry-point for module, for command line utility."""
|
|
462
460
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
463
461
|
if not args.output and not args.prettyprint:
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
import shutil
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import Any, ParamSpec
|
|
2
4
|
|
|
5
|
+
P = ParamSpec("P")
|
|
3
6
|
try:
|
|
4
|
-
from ert import (
|
|
7
|
+
from ert import (
|
|
5
8
|
ForwardModelStepDocumentation,
|
|
6
9
|
ForwardModelStepJSON,
|
|
7
10
|
ForwardModelStepPlugin,
|
|
8
11
|
ForwardModelStepValidationError,
|
|
9
12
|
)
|
|
10
|
-
from ert import plugin as ert_plugin
|
|
13
|
+
from ert import plugin as ert_plugin
|
|
11
14
|
except ModuleNotFoundError:
|
|
12
15
|
# ert is not installed, use dummy/transparent function decorator:
|
|
13
|
-
def ert_plugin(name: str = ""):
|
|
14
|
-
def decorator(func):
|
|
16
|
+
def ert_plugin(name: str = "") -> Callable[[Callable[P, Any]], Callable[P, Any]]:
|
|
17
|
+
def decorator(func: Callable[P, Any]) -> Callable[P, Any]:
|
|
15
18
|
return func
|
|
16
19
|
|
|
17
20
|
return decorator
|
|
18
21
|
|
|
19
|
-
class ForwardModelStepDocumentation: # type: ignore
|
|
22
|
+
class ForwardModelStepDocumentation: # type: ignore[no-redef]
|
|
20
23
|
pass
|
|
21
24
|
|
|
22
|
-
class ForwardModelStepJSON: # type: ignore
|
|
25
|
+
class ForwardModelStepJSON: # type: ignore[no-redef]
|
|
23
26
|
pass
|
|
24
27
|
|
|
25
|
-
class ForwardModelStepPlugin: # type: ignore
|
|
28
|
+
class ForwardModelStepPlugin: # type: ignore[no-redef]
|
|
26
29
|
pass
|
|
27
30
|
|
|
28
|
-
class ForwardModelStepValidationError: # type: ignore
|
|
31
|
+
class ForwardModelStepValidationError: # type: ignore[no-redef]
|
|
29
32
|
pass
|
|
30
33
|
|
|
31
34
|
|
res2df/inferdims.py
CHANGED
|
@@ -3,12 +3,9 @@ Support module for inferring EQLDIMS and TABDIMS from incomplete
|
|
|
3
3
|
reservoir simulator decks (typically single include-files)
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
import contextlib
|
|
7
6
|
import logging
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
import opm.io
|
|
11
|
-
# Let parts of res2df work without OPM:
|
|
8
|
+
import opm.io
|
|
12
9
|
|
|
13
10
|
from .resdatafiles import ResdataFiles
|
|
14
11
|
|
res2df/nnc.py
CHANGED
|
@@ -280,7 +280,7 @@ def df2res_editnnc(
|
|
|
280
280
|
return string
|
|
281
281
|
|
|
282
282
|
|
|
283
|
-
def nnc_main(args) -> None:
|
|
283
|
+
def nnc_main(args: argparse.Namespace) -> None:
|
|
284
284
|
"""Command line access point from main() or from res2csv via subparser"""
|
|
285
285
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
286
286
|
resdatafiles = ResdataFiles(args.DATAFILE)
|
res2df/pillars.py
CHANGED
|
@@ -109,7 +109,7 @@ def df(
|
|
|
109
109
|
|
|
110
110
|
aggregators = {
|
|
111
111
|
key: AGGREGATORS[key.split("@")[0]]
|
|
112
|
-
for key in grid_df
|
|
112
|
+
for key in grid_df.columns
|
|
113
113
|
if key.split("@")[0] in AGGREGATORS
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -406,7 +406,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
|
406
406
|
return parser
|
|
407
407
|
|
|
408
408
|
|
|
409
|
-
def pillars_main(args) -> None:
|
|
409
|
+
def pillars_main(args: argparse.Namespace) -> None:
|
|
410
410
|
"""This is the command line API"""
|
|
411
411
|
logger = getLogger_res2csv(__name__, vars(args))
|
|
412
412
|
|