Skip to content

Commit a303383

Browse files
committed
Use resfo for parsing headers in UNRST file
Using resdata to ask for headers implies reading the entire file which requires excessive memory. Porting more of res2df to use resfo is postponed to a future issue. Before this commit, obtaining the RST information for one particular date in a 118GB UNRST file was not possible (requires at least more than 118GB of available memory). With this commit, the same operation can be done in arund 6 GB of used memory.
1 parent 31ee271 commit a303383

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
[mypy-resdata.*]
44
ignore_missing_imports = True
55

6+
[mypy-resfo.*]
7+
ignore_missing_imports = True
8+
69
[mypy-opm.*]
710
ignore_missing_imports = True
811

res2df/grid.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import pandas as pd
2424
import pyarrow
2525
import pyarrow.feather
26+
import resfo
2627
from resdata.resfile import ResdataFile
2728

2829
from .__version__ import __version__
@@ -199,11 +200,12 @@ def rst2df(
199200
# for all active cells:
200201
activecells = resdatafiles.get_egrid().getNumActive()
201202
rstvectors = []
202-
for vec in resdatafiles.get_rstfile().headers:
203-
if vec[1] == activecells and any(
204-
fnmatch.fnmatch(vec[0], key) for key in vectors
203+
for vec in resfo.lazy_read(resdatafiles.get_rstfilename()):
204+
keyword_name = vec.read_keyword().strip()
205+
if vec.read_length() == activecells and any(
206+
fnmatch.fnmatch(keyword_name, key) for key in vectors
205207
):
206-
rstvectors.append(vec[0])
208+
rstvectors.append(keyword_name)
207209
rstvectors = list(set(rstvectors)) # Make unique list
208210
# Note that all of these might not exist at all timesteps.
209211

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
SETUP_REQUIREMENTS = ["setuptools>=28", "setuptools_scm"]
1818
REQUIREMENTS = [
1919
"resdata>=5.0.0-b0",
20+
"resfo",
2021
"numpy",
2122
"opm>=2020.10.2",
2223
"pandas",

0 commit comments

Comments
 (0)