-
Notifications
You must be signed in to change notification settings - Fork 58
/
surface_slice_grid3d.py
61 lines (39 loc) · 1.62 KB
/
surface_slice_grid3d.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
"""
Slice a 3Grid property with a surface, e.g. a FLW map.
In this case 3 maps with constant depth are applied. The maps are refined
for smoother result, and output is exported as Roxar binary *.gri and
quickplots (png)
JRIV
"""
import os
import pathlib
import tempfile
import xtgeo
TMPDIR = pathlib.Path(tempfile.gettempdir())
def slice_a_grid():
"""Slice a 3D grid property with maps (looping)"""
expath1 = pathlib.Path("../../xtgeo-testdata/3dgrids/reek")
expath2 = pathlib.Path("../../xtgeo-testdata/surfaces/reek/1")
gridfileroot = expath1 / "REEK"
surfacefile = expath2 / "midreek_rota.gri"
initprops = ["PORO", "PERMX"]
grd = xtgeo.grid_from_file(gridfileroot, fformat="eclipserun", initprops=initprops)
# read a surface, which is used for "template"
surf = xtgeo.surface_from_file(surfacefile)
surf.refine(2) # make finer for nicer sampling (NB takes time then)
slices = [1700, 1720, 1740]
for myslice in slices:
print("Slice is {}".format(myslice))
for prp in grd.props:
sconst = surf.copy()
sconst.values = myslice # set constant value for surface
print("Work with {}, slice at {}".format(prp.name, myslice))
sconst.slice_grid3d(grd, prp)
fname = "{}_{}.gri".format(prp.name, myslice)
sconst.to_file(TMPDIR / fname)
fname = TMPDIR / ("{}_{}.png".format(prp.name, myslice))
if "SKIP_PLOT" not in os.environ:
sconst.quickplot(filename=fname)
if __name__ == "__main__":
slice_a_grid()
print(f"Running example OK: {pathlib.Path(__file__).name}")