Skip to content

Commit

Permalink
Fix ERT hook for csv2ecl summary, changing csv2ecl summary cli API
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Feb 25, 2021
1 parent 840bf75 commit a9fb0e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
7 changes: 5 additions & 2 deletions ecl2df/csv2ecl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
# String constants in use for generating ERT forward model documentation:
DESCRIPTION = """Convert CSV files into Eclipse include files. Uses the command
line utility ``csv2ecl``. Run ``csv2ecl --help`` to see which subcommands are supported.
No options other than the output file is possible when
used directly as a forward model."""
No options other than the output file is possible when used directly as a forward model.
When writing synthetic summary files, the ECLBASE with no filename suffix is expected
as the OUTPUT argument."""
CATEGORY = "utility.eclipse"
EXAMPLES = (
"``FORWARD_MODEL "
"CSV2ECL(<SUBCOMMAND>=equil, <CSVFILE>=equil.csv, "
"<OUTPUT>=eclipse/include/equil.inc)``"
"CSV2ECL(<SUBCOMMAND>=summary, <CSVFILE>=summary-monthly.csv, "
"<OUTPUT>=MONTHLYSUMMARY)``"
)


Expand Down
15 changes: 10 additions & 5 deletions ecl2df/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,15 @@ def fill_parser(parser):

def fill_reverse_parser(parser):
"""Fill a parser for the operation: dataframe -> eclsum files"""

parser.add_argument(
"-o",
"--output",
type=str,
help="Basename for Eclipse output files",
default="SYNTSMRY",
)
parser.add_argument("csvfile", help="Name of CSV file with summary data.")
parser.add_argument("ECLBASE", help="Basename for Eclipse output files")
parser.add_argument("-v", "--verbose", action="store_true", help="Be verbose")
parser.add_argument("--debug", action="store_true", help="Be verbose")
return parser
Expand Down Expand Up @@ -687,8 +694,6 @@ def summary_reverse_main(args):
summary_df = pd.read_csv(args.csvfile)
logger.info("Parsed %s", args.csvfile)

eclsum = df2eclsum(summary_df, args.ECLBASE)
eclsum = df2eclsum(summary_df, args.output)
EclSum.fwrite(eclsum)
logger.info(
"Wrote to %s and %s", args.ECLBASE + ".UNSMRY", args.ECLBASE + ".SMSPEC"
)
logger.info("Wrote to %s and %s", args.output + ".UNSMRY", args.output + ".SMSPEC")
4 changes: 4 additions & 0 deletions tests/test_ert_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def test_ecl2csv_through_ert(tmpdir):
+ "<SUBCOMMAND>={0}, <CSVFILE>={0}.csv, <OUTPUT>={0}.inc".format(subcommand)
+ ")"
)
ert_config.append(
"FORWARD_MODEL CSV2ECL(<SUBCOMMAND>=summary, <CSVFILE>=summary-yearly.csv), "
"<OUTPUT>=SUMYEARLY)"
)

ert_config_filename = "ecl2csv_test.ert"
Path(ert_config_filename).write_text("\n".join(ert_config), encoding="utf-8")
Expand Down
3 changes: 1 addition & 2 deletions tests/test_summary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""Test module for nnc2df"""

import os
import sys
import datetime
Expand Down Expand Up @@ -765,6 +763,7 @@ def test_csv2ecl_summary(tmpdir):
"summary",
"-v",
"summary.csv",
"--output",
"SYNTHETIC",
]
csv2ecl.main()
Expand Down

0 comments on commit a9fb0e4

Please sign in to comment.