Skip to content

Commit

Permalink
Non-contiguous active FIPNUM
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe committed Feb 7, 2025
1 parent e2f1947 commit 93803c5
Show file tree
Hide file tree
Showing 3 changed files with 1,809 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/subscript/prtvol2csv/prtvol2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,16 @@ def prtvol2df(
# Remove extra empty 'regions' (from the reservoir volume table in .PRT)
# Concatenate dataframes horizontally. Both are/must be indexed by value
# of fipname (FIPNUM):

# Get maximum FIPNUM
sim_max_fipnum = simvolumes_df.index.max()
res_max_fipnum = resvolumes_df.loc[(resvolumes_df != 0).any(axis=1)].index.max()
max_fipnum = max(sim_max_fipnum, res_max_fipnum)
volumes = (
pd.concat([simvolumes_df, resvolumes_df[: len(simvolumes_df)]], axis=1)
pd.concat([simvolumes_df, resvolumes_df[:max_fipnum]], axis=1)
.apply(pd.to_numeric)
.fillna(value=0.0)
.sort_index()
)

# Rename the index to "FIPNUM", as required by webviz-subsurface, if requested
Expand Down
13 changes: 13 additions & 0 deletions tests/test_prtvol2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,19 @@ def test_fipxxx(tmp_path, mocker):
expected["FIPNAME"] = "FIPNUM"
pd.testing.assert_frame_equal(dframe, expected)

def test_inactive_fipnum(tmp_path, mocker):
"""Test the case with non-contiguous active FIPNUM"""

prtfile = TEST_PRT_DATADIR / "DROGON_INACTIVE_FIPNUM.PRT"

os.chdir(tmp_path)
with pytest.warns(FutureWarning, match="Output directories"):
mocker.patch("sys.argv", ["prtvol2csv", "--debug", str(prtfile)])
prtvol2csv.main()
dframe = pd.read_csv("share/results/volumes/simulator_volume_fipnum.csv")

assert dframe.loc[dframe["FIPNUM"].idxmax(), "HCPV_TOTAL"] != 0


def test_find_prtfile(tmp_path):
"""Test location service for PRT files"""
Expand Down
Loading

0 comments on commit 93803c5

Please sign in to comment.