Skip to content

Commit 872742c

Browse files
authored
prtvol2csv Handle Eclipse dumping out July as JLY (#811)
1 parent 809fd41 commit 872742c

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/subscript/prtvol2csv/prtvol2csv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ def currently_in_place_from_prt(
211211
if date_matcher_ecl.search(line) is not None:
212212
line_split = line.split("*")
213213
initial_date_string = line_split[0].rstrip().split(" ")[-1]
214+
# Handle Eclipse dumping out July as JLY instead of JUL
215+
initial_date_string = initial_date_string.replace("JLY", "JUL")
214216
initial_date_object = datetime.strptime(
215217
initial_date_string, "%d %b %Y"
216218
).date()

tests/test_prtvol2csv.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,24 @@ def test_prtvol2csv(tmp_path, mocker):
183183
pd.testing.assert_frame_equal(dframe, expected)
184184

185185

186+
def test_correct_parsing_date(tmp_path):
187+
shutil.copy(TEST_PRT_DATADIR / "DROGON_FIPNUM.PRT", tmp_path / "DROGON_FIPNUM.PRT")
188+
os.chdir(tmp_path)
189+
# Replace "REPORT 0 1 JAN 2018" with "REPORT 0 5 JLY 2018"
190+
report_string = "REPORT 0 1 JLY 2018"
191+
prt_path = tmp_path / "DROGON_FIPNUM.PRT"
192+
prt_text = prt_path.read_text(encoding="utf8")
193+
prt_text = prt_text.replace("REPORT 0 1 JAN 2018", report_string)
194+
assert report_string in prt_text
195+
196+
prt_path.write_text(prt_text, encoding="utf8")
197+
198+
df_inplace = prtvol2csv.currently_in_place_from_prt(prt_path)
199+
expected_stoiip_oil = [1885827, 7179776, 2366384, 213993, 986924]
200+
201+
assert df_inplace["STOIIP_OIL"].head().to_list() == expected_stoiip_oil
202+
203+
186204
def test_rename_fip_column(tmp_path, mocker):
187205
"""Test renaming of the region column to FIPNUM"""
188206
prtfile = TEST_PRT_DATADIR / "DROGON_FIPZON.PRT"

0 commit comments

Comments
 (0)