Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support years > 2262 in CSV_EXPORT2 #568

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies=[
"xlrd",
"fmu-steaclient",
"pyscal>=0.4.0",
"fmu-ensemble",
"fmu-ensemble>1.6.5",
"segyio",
"xtgeo>=2.15",
]
Expand Down
3 changes: 0 additions & 3 deletions semeio/workflows/csv_export2/csv_export2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
requested in the Eclipse DATA file. A wildcard like ``W*`` can in certain cases
(e.g. Eclipse simulations with 100+ wells) produce thousands of vectors, and can
then be replaced by something more explicit like ``WOPT* WGPT* WWPT*``.

Dates beyond year 2262 are not supported. Use ecl2csv in combination with
merge_csv in such scenarios.
""" # noqa

EXAMPLES = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import os
import shutil
import subprocess
Expand All @@ -6,6 +7,7 @@
import pandas as pd
import pytest
import rstcheck_core.checker
from resdata.summary import Summary

from semeio.workflows.csv_export2 import csv_export2

Expand Down Expand Up @@ -142,6 +144,45 @@ def test_norne_ensemble_noparams():
)


def test_can_export_summary_files_beyond_2262(tmpdir, monkeypatch):
"""Pandas is/has been eager to use datetime64[ns] which overflows in year 2262,
ensure this limitation is sufficiently worked around."""
monkeypatch.chdir(tmpdir)
res_sum = Summary.from_pandas(
"TESTCASE",
pd.DataFrame(
[
{"DATE": datetime.date(2000, 1, 1), "FPR": 200},
{"DATE": datetime.date(2263, 1, 1), "FPR": 1},
]
).set_index("DATE"),
)

Path("realization-0/iter-0").mkdir(parents=True)
os.chdir("realization-0/iter-0")
# fwrite() can only write to cwd
Summary.fwrite(res_sum)
os.chdir("../..")

Path("runpathfile").write_text(
"0 realization-0/iter-0 TESTCASE 0", encoding="utf-8"
)
csv_export2.csv_exporter(
runpathfile="runpathfile",
time_index="yearly",
outputfile="unsmry--yearly.csv",
column_keys=["FPR"],
)
verify_exported_file(
"unsmry--yearly.csv",
["ENSEMBLE", "REAL", "DATE", "FPR"],
{
("iter-0", 0),
},
)
assert "2263-01-01" in Path("unsmry--yearly.csv").read_text(encoding="utf-8")


def verify_exported_file(exported_file_name, result_header, result_iter_rel):
"""Verify an exported CSV file with respect to:

Expand Down