Python package for reading and writing reservoir simulator result files including RESTART, INIT, RFT, Summary and GRID files in various formats.
npx @tessl/cli install tessl/pypi-resdata@5.1.0ResData is a comprehensive Python library for reading and writing result files from reservoir simulators. The library handles RESTART, INIT, RFT (Repeat Formation Tester), Summary, and GRID files in both unified and non-unified formats, as well as formatted and unformatted variants. Built with a hybrid architecture combining Python convenience with C++ performance through cwrap bindings, it provides high-performance data processing capabilities for large-scale reservoir simulation datasets.
pip install resdataimport resdataFor file operations:
from resdata.resfile import ResdataFile, ResdataKW, FortIOFor grid operations:
from resdata.grid import Grid, ResdataRegion, CellFor summary data:
from resdata.summary import Summary, SummaryVectorFor well data:
from resdata.well import WellInfo, WellState, WellConnectionFor RFT/PLT data:
from resdata.rft import ResdataRFTFile, ResdataRFT, ResdataRFTCell, ResdataPLTCellimport resdata
from resdata.resfile import ResdataFile, ResdataKW
from resdata.grid import Grid
from resdata.summary import Summary
# Read a restart file
restart_file = ResdataFile("SIMULATION.UNRST")
pressure_kw = restart_file.get_kw("PRESSURE")
print(f"Pressure data shape: {pressure_kw.array().shape}")
# Load grid file
grid = Grid("SIMULATION.EGRID")
print(f"Grid dimensions: {grid.get_cell_dims()}")
print(f"Active cells: {grid.num_active()}")
# Load summary data
summary = Summary.load("SIMULATION.SMSPEC", "SIMULATION.UNSMRY")
oil_prod = summary.get_vector("FOPT") # Field Oil Production Total
print(f"Final oil production: {oil_prod.last_value()}")
# Access well data
well_names = summary.wells()
for well in well_names[:3]: # First 3 wells
well_oil = summary.get_vector(f"WOPT:{well}")
print(f"{well} total oil: {well_oil.last_value()}")ResData's hybrid architecture provides optimal performance for large-scale reservoir data processing:
The library serves as a bridge between reservoir simulation outputs and Python's scientific computing ecosystem, enabling integration with NumPy, pandas, matplotlib, and other data analysis tools.
Comprehensive file I/O for reservoir simulation formats including binary Fortran files, keyword data containers, and specialized file readers for RESTART, INIT, and other format files.
class ResdataFile:
def __init__(self, filename: str): ...
def get_kw(self, kw_name: str, index: int = 0) -> ResdataKW: ...
def has_kw(self, kw_name: str) -> bool: ...
class ResdataKW:
def array(self) -> numpy.ndarray: ...
def name(self) -> str: ...
def numpy_copy(self) -> numpy.ndarray: ...
class FortIO:
def __init__(self, filename: str, mode: str = "r"): ...
def close(self): ...Grid structure analysis and manipulation including 3D grid processing, cell operations, region selection, and Local Grid Refinement (LGR) support.
class Grid:
def __init__(self, filename: str): ...
def get_cell_dims(self) -> tuple: ...
def num_active(self) -> int: ...
def get_xyz(self, i: int, j: int, k: int) -> tuple: ...
class ResdataRegion:
def select_equal(self, kw: ResdataKW, value: float): ...
def select_box(self, i1: int, i2: int, j1: int, j2: int, k1: int, k2: int): ...Time series data processing for production, injection, and field performance metrics with support for NPV calculations and data comparison.
class Summary:
@classmethod
def load(cls, smspec_file: str, unsmry_file: str) -> Summary: ...
def get_vector(self, key: str) -> SummaryVector: ...
def wells(self) -> list: ...
def pandas_frame(self) -> pandas.DataFrame: ...
class SummaryVector:
def last_value(self) -> float: ...
def numpy_vector(self) -> numpy.ndarray: ...Well state analysis, connection data, segment information, and production/injection rate processing with time-based well performance tracking.
class WellInfo:
def well_names(self) -> list: ...
def get_state_from_time(self, well_name: str, time: datetime) -> WellState: ...
class WellState:
def is_producer(self) -> bool: ...
def get_connections(self) -> list: ...
def get_production_rates(self) -> dict: ...Repeat Formation Tester (RFT) and Production Logging Tool (PLT) data processing for pressure analysis, saturation profiles, and flow rate evaluation.
class ResdataRFTFile:
def __init__(self, filename: str): ...
def get_rft(self, well_name: str, date: datetime) -> ResdataRFT: ...
def get_dates(self, well_name: str) -> list: ...
class ResdataRFT:
def get_pressure(self) -> numpy.ndarray: ...
def get_depth(self) -> numpy.ndarray: ...2D and 3D geometric operations including point sets, regions, polylines, surfaces, and spatial analysis tools for reservoir characterization.
class Surface:
def get_value(self, x: float, y: float) -> float: ...
def write(self, filename: str): ...
class GeoRegion:
def contains_point(self, x: float, y: float) -> bool: ...Gravity and subsidence modeling capabilities for time-lapse reservoir monitoring and geomechanical analysis.
class ResdataGrav:
def add_survey_GRAV(self, survey_name: str, ...): ...
def eval_grav(self) -> numpy.ndarray: ...
class ResdataSubsidence:
def add_survey_SUBSIDENCE(self, survey_name: str, ...): ...
def eval_subsidence(self) -> numpy.ndarray: ...Utility classes for vector operations, time handling, random number generation, and data type management supporting the core functionality.
class ResDataType:
RD_INT: ResDataType
RD_FLOAT: ResDataType
RD_DOUBLE: ResDataType
class IntVector:
def append(self, value: int): ...
def numpy_copy(self) -> numpy.ndarray: ...# File and data types
FileType = Literal["RESTART", "UNIFIED_RESTART", "SUMMARY", "UNIFIED_SUMMARY",
"GRID", "EGRID", "INIT", "RFT", "DATA"]
FileMode = Literal["DEFAULT", "CLOSE_STREAM", "WRITABLE"]
Phase = Literal["OIL", "GAS", "WATER"]
UnitSystem = Literal["METRIC", "FIELD", "LAB", "PVT_M"]
# Well types
WellType = Literal["PRODUCER", "WATER_INJECTOR", "GAS_INJECTOR", "OIL_INJECTOR"]
WellConnectionDirection = Literal["DIR_X", "DIR_Y", "DIR_Z", "DIR_FRACX", "DIR_FRACY"]
# Summary variable types
SummaryVarType = Literal["FIELD", "WELL", "GROUP", "REGION", "BLOCK", "CONNECTION"]