Skip to content
Open
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
32 changes: 32 additions & 0 deletions docs/scripts/prtvol2csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,38 @@ file has been supplied defining the map from zones and regions to FIPNUM:
:file: prtvol2csv.csv
:header-rows: 1

Note
----

Since introduction of the **date** argument (in Subscript version 1.14.8), the function
``currently_in_place_from_prt`` in the prtvol2csv script returns a
tuple with date information in addition to the DataFrame with in-place volumes:

.. code-block:: none

def currently_in_place_from_prt(
prt_file: str, fipname: str = "FIPNUM", date_str: str | None = None
) -> tuple[pd.DataFrame, np.ndarray, str]:

This is a change in function signature. Previously this function returned just the
DataFrame.

Similarly the function ``reservoir_volmes_from_from_prt`` must be called
with at least two arguments, a numpy array with date informtion in addition to the
PRT-file:

.. code-block:: none

def reservoir_volumes_from_prt(
prt_file: str,
dates_bal_report: np.ndarray,
fipname: str = "FIPNUM",
date_str: str = "",
) -> pd.DataFrame:

This is a change in function signature. Previously this function could be called with
only a string contaning name of the PRT-file.

See also
--------

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ ignore = [
"PLR0904", # too-many-public-methods
"PLR1702", # too-many-nested-blocks
"RUF067", # non empty init module
"RUF069", # unreliable-floating-point-equality
"PLC1901", # compare-to-empty-string
]

Expand Down
2 changes: 1 addition & 1 deletion src/subscript/eclcompress/eclcompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def file_is_binary(filename: str | Path) -> bool:
Args:
filename: File to check
"""
# https://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python # noqa
# https://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python
textchars = bytearray({7, 8, 9, 10, 12, 13, 27} | set(range(0x20, 0x100)) - {0x7F})
with open(filename, "rb") as filehandle:
return bool(filehandle.read(1024).translate(None, textchars))
Expand Down
11 changes: 10 additions & 1 deletion src/subscript/hook_implementations/forward_model_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,16 @@ def __init__(self) -> None:
"--rename2fipnum",
"--fipname",
"<FIPNAME>",
"--date",
"<REPORT_DATE>",
"<DATAFILE>",
],
default_mapping={
"<DIR>": "share/results/volumes",
"<OUTPUTFILENAME>": "simulator_volume_fipnum.csv",
"<REGIONS>": "",
"<FIPNAME>": "FIPNUM",
"<REPORT_DATE>": "first",
},
)

Expand All @@ -708,7 +711,8 @@ def documentation() -> ForwardModelStepDocumentation | None:
.. code-block:: console

FORWARD_MODEL PRTVOL2CSV(<DATAFILE>=<ECLBASE>, <REGIONS>=regions.yml, \
<FIPNAME>=FIPNUM, <DIR>=., <OUTPUTFILENAME>=simulator_volume_fipnum.csv)
<FIPNAME>=FIPNUM, <DATE>=first, <DIR>=., \
<OUTPUTFILENAME>=simulator_volume_fipnum.csv)

where ``ECLBASE`` is already defined in your ERT config, pointing to the Eclipse
basename relative to ``RUNPATH`` and ``regions.yml`` is a YAML file defining
Expand All @@ -724,6 +728,11 @@ def documentation() -> ForwardModelStepDocumentation | None:
``VolumetricAnalysis``. This renaming is not needed for ``Webviz-Sumo``. An additional
column with the actual FIPNAME is included for information.

The ``DATE`` argument is by default the first available BALANCE report
in the PRT file, but any valid date for existing BALANCE report can be
specified. Dates must be in ISO-8601 format (yyyy-mm-dd), or as one of the strings
"first" and "last".

Using anything else than "." in the ``DIR`` argument is deprecated. To write to a CSV
file in a specific directory, add the path in the ``OUTPUTFILENAME`` argument.
The directory to export to must exist.
Expand Down
Loading