CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-resdata

Python package for reading and writing reservoir simulator result files including RESTART, INIT, RFT, Summary and GRID files in various formats.

Pending
Overview
Eval results
Files

index.mddocs/

ResData

ResData 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.

Package Information

  • Package Name: resdata
  • Language: Python (with C++ extensions)
  • Installation: pip install resdata
  • License: GPL-3.0
  • Platform Support: Linux, macOS

Core Imports

import resdata

For file operations:

from resdata.resfile import ResdataFile, ResdataKW, FortIO

For grid operations:

from resdata.grid import Grid, ResdataRegion, Cell

For summary data:

from resdata.summary import Summary, SummaryVector

For well data:

from resdata.well import WellInfo, WellState, WellConnection

For RFT/PLT data:

from resdata.rft import ResdataRFTFile, ResdataRFT, ResdataRFTCell, ResdataPLTCell

Basic Usage

import 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()}")

Architecture

ResData's hybrid architecture provides optimal performance for large-scale reservoir data processing:

  • C++ Core: High-performance file I/O, data structures, and mathematical operations implemented in C++
  • Python Bindings: Convenient Python interface using cwrap for seamless integration
  • File Format Support: Native support for industry-standard formats (ECLIPSE, OPM, and similar simulators)
  • Memory Management: Efficient memory handling for large datasets with lazy loading and views
  • Cross-Platform: Consistent behavior across Linux and macOS environments

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.

Capabilities

File Operations

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): ...

File Operations

Grid Operations

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): ...

Grid Operations

Summary Data Analysis

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: ...

Summary Analysis

Well Data Processing

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: ...

Well Data

RFT and PLT Data

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: ...

RFT and PLT Processing

Geometry Operations

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: ...

Geometry Operations

Gravimetry and Subsidence

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: ...

Gravimetry and Subsidence

Utilities and Data Types

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: ...

Utilities

Core Types

# 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"]

Install with Tessl CLI

npx tessl i tessl/pypi-resdata

docs

file-operations.md

geometry-operations.md

gravimetry-subsidence.md

grid-operations.md

index.md

rft-plt-data.md

summary-analysis.md

utilities.md

well-data.md

tile.json