Skip to content

Commit

Permalink
Make merge_unrst_files available as ERT forward model.
Browse files Browse the repository at this point in the history
  • Loading branch information
rnyb committed Jan 4, 2024
1 parent 4becff6 commit 09e33ba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fmu_copy_revision ✅ ⛔️ ⛔️
fmuobs ✅ ⛔️ ✅
interp_relperm ✅ ✅ ⛔️
merge_rft_ertobs ✅ ✅ ⛔️
merge_unrst_files ✅ ✅ ⛔️
ofmvol2csv ✅ ✅ ⛔️
pack_sim ✅ ⛔️ ⛔️
params2csv ✅ ✅ ✅
Expand All @@ -38,5 +39,5 @@ welltest_dpds ✅ ✅ ⛔️
======================== === ================= ============

.. [*] ``convert_grid_format`` is the script that contains functionality
for the ``ECLGRID2ROFF``, ``ECLINIT2ROFF``, and ``ECLRST2ROFF`` forward
for the ``ECLGRID2ROFF``, ``ECLINIT2ROFF``, and ``ECLRST2ROFF`` forward
models.
11 changes: 11 additions & 0 deletions src/subscript/config_jobs/MERGE_UNRST_FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
EXECUTABLE merge_unrst_files

ARG_TYPE 0 STRING
ARG_TYPE 1 STRING
ARG_TYPE 2 STRING
DEFAULT <OUTPUT> "MERGED.UNRST"

ARGLIST <UNRST1> <UNRST2> "--output" <OUTPUT>

MIN_ARG 2
MAX_ARG 3
20 changes: 10 additions & 10 deletions src/subscript/merge_unrst_files/merge_unrst_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

DESCRIPTION = """Read two ``UNRST`` files and export a merged version. This is useful in
cases where history and prediction are run separately and one wants to calculate
differences across dates in the two files.
differences across dates in the two files. One should give hist file as first positional
argument and pred file as the second positional argument (i.e. in the order of smallest
to largest report step numbers).
"""

CATEGORY = "utility.eclipse"
Expand All @@ -34,10 +36,8 @@ def get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog="merge_unrst_files.py", description=DESCRIPTION
)
parser.add_argument("UNRST_HIST_FILE", type=str, help="UNRST file 1, history part")
parser.add_argument(
"UNRST_PRED_FILE", type=str, help="UNRST file 2, prediction part"
)
parser.add_argument("UNRST1", type=str, help="UNRST file 1, history part")
parser.add_argument("UNRST2", type=str, help="UNRST file 2, prediction part")
parser.add_argument(
"-o",
"--output",
Expand Down Expand Up @@ -69,9 +69,9 @@ def _check_report_number(

if current_report_number <= max_report_number_hist:
logger.warning(
f"{args.UNRST_PRED_FILE} file has a restart report number"
f"{args.UNRST2} file has a restart report number"
+ f" ({current_report_number}) which is smaller than largest report number"
+ f" in {args.UNRST_HIST_FILE} ({max_report_number_hist})"
+ f" in {args.UNRST1} ({max_report_number_hist})"
)
logger.warning(
"Check that you have entered arguments in correct order and/or"
Expand All @@ -84,9 +84,9 @@ def main() -> None:

args: argparse.Namespace = get_parser().parse_args()

logger.info(f"Merge unrst files {args.UNRST_HIST_FILE} and {args.UNRST_PRED_FILE}.")
unrst_hist = resfo.read(args.UNRST_HIST_FILE)
unrst_pred = resfo.read(args.UNRST_PRED_FILE)
logger.info(f"Merge unrst files {args.UNRST1} and {args.UNRST2}.")
unrst_hist = resfo.read(args.UNRST1)
unrst_pred = resfo.read(args.UNRST2)

max_first_seqnum: int = 1
max_first_solver_step: int = 1
Expand Down

0 comments on commit 09e33ba

Please sign in to comment.