Skip to content

grdecl⚓︎

Read Schlumberger Eclipse grid input files.

Examples:

>>> import pyresito.io.grdecl as grdecl
>>> grid = grdecl.read ("FOO")

GrdEclError ⚓︎

Bases: Exception

Exception thrown if invalid syntax is encountered.

main(*args) ⚓︎

Read a data file to see if it parses OK.

read(filename) ⚓︎

Read an Eclipse input grid into a dictionary.

read_prop(fname, dims, typ=numpy.float64, prop=None, *, mask=None) ⚓︎

Read a property from a text file into a dictionary. This is akin to Petrel's Import onto selection popup menu choice.

Parameters:

Name Type Description Default
fname str

File name to load property from. Currently, this must be a file in the filesystem and cannot be a file-like object.

required
dims tuple of int

Dimensions of the data cube, in a format compatible with the return of the shape function, i.e. (nk, nj, ni).

required
typ dtype

Data type of the data to be loaded.

float64
prop dict

Dictionary where the keyword will be added. If this is None, then a new dictionary will be created.

None
mask ndarray

Existing mask for inactive elements; this will be combined with the mask inherent in the data, if specified. If you have loaded the grid, this should be the ACTNUM field.

None

Returns:

Type Description
dict

Dictionary where the property being read is added as a key.

shape(grdecl) ⚓︎

Get shape of field data cube.

Parameters:

Name Type Description Default
grdecl dict

Corner-point grid structure.

required

Returns:

Type Description
tuple of int

Shape of the field data cube as (num_k, num_j, num_i).

write(filename, grid, dialect='ecl', multi_file=True) ⚓︎

Write a grid to corner-point text format, formatted in such a way that it can easily be read again.

Parameters:

Name Type Description Default
filename str

Name of the filename containing a wrapper for all the properties. This will also serve as the stem for all individual property files.

required
grid dict

Grid object containing values for all properties.

required
dialect str

Name of the simulator that we are writing files for. Currently, this must be 'ecl'.

'ecl'
multi_file bool

Write properties in separate files, instead of putting everything in one large file.

True

Returns:

Type Description
None

write_compressed(fname, keyw, cube, *, fmt='12.6e') ⚓︎

Write a data field as a keyword that can be included into a grid file.

Parameters:

Name Type Description Default
fname str

Path to the output file to write to.

required
keyw str

Name of the keyword to put in the header; this should not be greater than eight characters.

required
cube ndarray

Data cube to be written.

required
fmt str

Format of a single item, in the form used to specify formats in the built-in routines, but without percent or braces.

'12.6e'

Returns:

Type Description
None