-
Notifications
You must be signed in to change notification settings - Fork 58
/
grid3d_get_df.py
70 lines (48 loc) · 1.86 KB
/
grid3d_get_df.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Example on how to retrieve a dataframe (Pandas) from a 3D grid.
Explanation:
Both a GridProperties and a Grid instance can return a dataframe.
The `grd.gridprops` attribute below is the GridProperties, and
this will return a a dataframe by default which does not include
XYZ and ACTNUM, as this information is only from the Grid (geometry).
The grid itself can also return a dataframe, and in this case
XYZ and ACNUM will be returned by default. Also properties that
are "attached" to the Grid via a GridProperties attribute will
be shown.
"""
import pathlib
import tempfile
import xtgeo
EXPATH = pathlib.Path("../../xtgeo-testdata/3dgrids/reek")
GRIDFILEROOT = EXPATH / "REEK"
TMPDIR = pathlib.Path(tempfile.gettempdir())
INITS = ["PORO", "PERMX"]
RESTARTS = ["PRESSURE", "SWAT", "SOIL"]
MYDATES = [20001101, 20030101]
def extractdf():
"""Extract dataframe from Eclipse case"""
# gete dataframe from the grid only
grd = xtgeo.grid_from_file(GRIDFILEROOT.with_suffix(".EGRID"))
dataframe = grd.get_dataframe() # will not have any grid props
print(dataframe)
# load as Eclipse run; this will automatically look for EGRID, INIT, UNRST
grd = xtgeo.grid_from_file(
GRIDFILEROOT,
fformat="eclipserun",
initprops=INITS,
restartprops=RESTARTS,
restartdates=MYDATES,
)
# dataframe from a GridProperties instance, in this case grd.gridprops
dataframe = grd.gridprops.get_dataframe() # properties for all cells
print(dataframe)
# Get a dataframe for all cells, with ijk and xyz. In this case
# a grid key input is required:
dataframe = grd.get_dataframe()
print(dataframe) # default is for all cells
# For active cells only:
dataframe = grd.get_dataframe(activeonly=True)
print(dataframe)
dataframe.to_csv(TMPDIR / "reek_sim.csv")
if __name__ == "__main__":
extractdf()