Reservoir Fortran Output
raw JSON → 5.0.1 verified Fri May 01 auth: no python
A lazy parser and writer for reservoir simulator Fortran output format (unformatted and formatted). Current version 5.0.1 with strict typing and type stubs. Maintenance via Equinor, release cadence irregular.
pip install resfo Common errors
error TypeError: write() got an unexpected keyword argument 'fileformat' ↓
cause In older versions, fileformat was a positional argument; in v5 it is a keyword-only argument.
fix
Use write(filename, data, fileformat=Format.FORMATTED) instead of positional.
error ModuleNotFoundError: No module named 'resfo.lazy_read' ↓
cause lazy_read is a function, not a submodule; incorrect import path.
fix
Use 'from resfo import lazy_read'.
error ValueError: data parameter must be an iterable of Entry objects, not dict ↓
cause Version 5 no longer accepts dict for write(). Data must be a list/tuple of Entry.
fix
Construct a list of Entry objects with keyword and data (numpy array).
Warnings
breaking In version 5.0.0, write() no longer accepts a dict for the data argument. Use a list of Entry objects instead. ↓
fix Replace dict with a list of Entry objects: write(filename, [Entry('KEYWORD', numpy_array)], fileformat=Format.FORMATTED)
gotcha lazy_read returns an iterator, not a list. It reads data lazily; iterating multiple times will reset the file pointer or raise a StopIteration. ↓
fix If you need random access, use read() instead, which reads all entries into memory.
deprecated Passing a dict to write() is removed in v5. The old pattern write('file', {'KEY': [1,2]}) no longer works. ↓
fix Use a list of Entry objects: from resfo import Entry; write('file', [Entry('KEY', np.array([1,2]))])
gotcha Memory usage: lazy_read keeps only one entry in memory at a time, but the iterator must be consumed completely. If you stop early, the file handle may not be closed immediately. ↓
fix Always iterate fully or use a context manager if available (not yet, but wrap in try/finally).
Imports
- lazy_read wrong
from resfo.lazy_read import ...correctfrom resfo import lazy_read - read wrong
import resfo; resfo.read()correctfrom resfo import read - write
from resfo import write - Format
from resfo import Format - Entry
from resfo import Entry
Quickstart
from resfo import lazy_read, Format
# Path to a small .FEGRID file
filepath = 'sample.FEGRID' # replace with actual path
for entry in lazy_read(filepath, fileformat=Format.UNFORMATTED):
print(f"Keyword: {entry.keyword}, Size: {len(entry.data)}")