or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/pypi-resdata

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

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/resdata@5.1.x

To install, run

npx @tessl/cli install tessl/pypi-resdata@5.1.0

0

# ResData

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: resdata

7

- **Language**: Python (with C++ extensions)

8

- **Installation**: `pip install resdata`

9

- **License**: GPL-3.0

10

- **Platform Support**: Linux, macOS

11

12

## Core Imports

13

14

```python

15

import resdata

16

```

17

18

For file operations:

19

```python

20

from resdata.resfile import ResdataFile, ResdataKW, FortIO

21

```

22

23

For grid operations:

24

```python

25

from resdata.grid import Grid, ResdataRegion, Cell

26

```

27

28

For summary data:

29

```python

30

from resdata.summary import Summary, SummaryVector

31

```

32

33

For well data:

34

```python

35

from resdata.well import WellInfo, WellState, WellConnection

36

```

37

38

For RFT/PLT data:

39

```python

40

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

41

```

42

43

## Basic Usage

44

45

```python

46

import resdata

47

from resdata.resfile import ResdataFile, ResdataKW

48

from resdata.grid import Grid

49

from resdata.summary import Summary

50

51

# Read a restart file

52

restart_file = ResdataFile("SIMULATION.UNRST")

53

pressure_kw = restart_file.get_kw("PRESSURE")

54

print(f"Pressure data shape: {pressure_kw.array().shape}")

55

56

# Load grid file

57

grid = Grid("SIMULATION.EGRID")

58

print(f"Grid dimensions: {grid.get_cell_dims()}")

59

print(f"Active cells: {grid.num_active()}")

60

61

# Load summary data

62

summary = Summary.load("SIMULATION.SMSPEC", "SIMULATION.UNSMRY")

63

oil_prod = summary.get_vector("FOPT") # Field Oil Production Total

64

print(f"Final oil production: {oil_prod.last_value()}")

65

66

# Access well data

67

well_names = summary.wells()

68

for well in well_names[:3]: # First 3 wells

69

well_oil = summary.get_vector(f"WOPT:{well}")

70

print(f"{well} total oil: {well_oil.last_value()}")

71

```

72

73

## Architecture

74

75

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

76

77

- **C++ Core**: High-performance file I/O, data structures, and mathematical operations implemented in C++

78

- **Python Bindings**: Convenient Python interface using cwrap for seamless integration

79

- **File Format Support**: Native support for industry-standard formats (ECLIPSE, OPM, and similar simulators)

80

- **Memory Management**: Efficient memory handling for large datasets with lazy loading and views

81

- **Cross-Platform**: Consistent behavior across Linux and macOS environments

82

83

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.

84

85

## Capabilities

86

87

### File Operations

88

89

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.

90

91

```python { .api }

92

class ResdataFile:

93

def __init__(self, filename: str): ...

94

def get_kw(self, kw_name: str, index: int = 0) -> ResdataKW: ...

95

def has_kw(self, kw_name: str) -> bool: ...

96

97

class ResdataKW:

98

def array(self) -> numpy.ndarray: ...

99

def name(self) -> str: ...

100

def numpy_copy(self) -> numpy.ndarray: ...

101

102

class FortIO:

103

def __init__(self, filename: str, mode: str = "r"): ...

104

def close(self): ...

105

```

106

107

[File Operations](./file-operations.md)

108

109

### Grid Operations

110

111

Grid structure analysis and manipulation including 3D grid processing, cell operations, region selection, and Local Grid Refinement (LGR) support.

112

113

```python { .api }

114

class Grid:

115

def __init__(self, filename: str): ...

116

def get_cell_dims(self) -> tuple: ...

117

def num_active(self) -> int: ...

118

def get_xyz(self, i: int, j: int, k: int) -> tuple: ...

119

120

class ResdataRegion:

121

def select_equal(self, kw: ResdataKW, value: float): ...

122

def select_box(self, i1: int, i2: int, j1: int, j2: int, k1: int, k2: int): ...

123

```

124

125

[Grid Operations](./grid-operations.md)

126

127

### Summary Data Analysis

128

129

Time series data processing for production, injection, and field performance metrics with support for NPV calculations and data comparison.

130

131

```python { .api }

132

class Summary:

133

@classmethod

134

def load(cls, smspec_file: str, unsmry_file: str) -> Summary: ...

135

def get_vector(self, key: str) -> SummaryVector: ...

136

def wells(self) -> list: ...

137

def pandas_frame(self) -> pandas.DataFrame: ...

138

139

class SummaryVector:

140

def last_value(self) -> float: ...

141

def numpy_vector(self) -> numpy.ndarray: ...

142

```

143

144

[Summary Analysis](./summary-analysis.md)

145

146

### Well Data Processing

147

148

Well state analysis, connection data, segment information, and production/injection rate processing with time-based well performance tracking.

149

150

```python { .api }

151

class WellInfo:

152

def well_names(self) -> list: ...

153

def get_state_from_time(self, well_name: str, time: datetime) -> WellState: ...

154

155

class WellState:

156

def is_producer(self) -> bool: ...

157

def get_connections(self) -> list: ...

158

def get_production_rates(self) -> dict: ...

159

```

160

161

[Well Data](./well-data.md)

162

163

### RFT and PLT Data

164

165

Repeat Formation Tester (RFT) and Production Logging Tool (PLT) data processing for pressure analysis, saturation profiles, and flow rate evaluation.

166

167

```python { .api }

168

class ResdataRFTFile:

169

def __init__(self, filename: str): ...

170

def get_rft(self, well_name: str, date: datetime) -> ResdataRFT: ...

171

def get_dates(self, well_name: str) -> list: ...

172

173

class ResdataRFT:

174

def get_pressure(self) -> numpy.ndarray: ...

175

def get_depth(self) -> numpy.ndarray: ...

176

```

177

178

[RFT and PLT Processing](./rft-plt-data.md)

179

180

### Geometry Operations

181

182

2D and 3D geometric operations including point sets, regions, polylines, surfaces, and spatial analysis tools for reservoir characterization.

183

184

```python { .api }

185

class Surface:

186

def get_value(self, x: float, y: float) -> float: ...

187

def write(self, filename: str): ...

188

189

class GeoRegion:

190

def contains_point(self, x: float, y: float) -> bool: ...

191

```

192

193

[Geometry Operations](./geometry-operations.md)

194

195

### Gravimetry and Subsidence

196

197

Gravity and subsidence modeling capabilities for time-lapse reservoir monitoring and geomechanical analysis.

198

199

```python { .api }

200

class ResdataGrav:

201

def add_survey_GRAV(self, survey_name: str, ...): ...

202

def eval_grav(self) -> numpy.ndarray: ...

203

204

class ResdataSubsidence:

205

def add_survey_SUBSIDENCE(self, survey_name: str, ...): ...

206

def eval_subsidence(self) -> numpy.ndarray: ...

207

```

208

209

[Gravimetry and Subsidence](./gravimetry-subsidence.md)

210

211

### Utilities and Data Types

212

213

Utility classes for vector operations, time handling, random number generation, and data type management supporting the core functionality.

214

215

```python { .api }

216

class ResDataType:

217

RD_INT: ResDataType

218

RD_FLOAT: ResDataType

219

RD_DOUBLE: ResDataType

220

221

class IntVector:

222

def append(self, value: int): ...

223

def numpy_copy(self) -> numpy.ndarray: ...

224

```

225

226

[Utilities](./utilities.md)

227

228

## Core Types

229

230

```python { .api }

231

# File and data types

232

FileType = Literal["RESTART", "UNIFIED_RESTART", "SUMMARY", "UNIFIED_SUMMARY",

233

"GRID", "EGRID", "INIT", "RFT", "DATA"]

234

FileMode = Literal["DEFAULT", "CLOSE_STREAM", "WRITABLE"]

235

Phase = Literal["OIL", "GAS", "WATER"]

236

UnitSystem = Literal["METRIC", "FIELD", "LAB", "PVT_M"]

237

238

# Well types

239

WellType = Literal["PRODUCER", "WATER_INJECTOR", "GAS_INJECTOR", "OIL_INJECTOR"]

240

WellConnectionDirection = Literal["DIR_X", "DIR_Y", "DIR_Z", "DIR_FRACX", "DIR_FRACY"]

241

242

# Summary variable types

243

SummaryVarType = Literal["FIELD", "WELL", "GROUP", "REGION", "BLOCK", "CONNECTION"]

244

```