-
Notifications
You must be signed in to change notification settings - Fork 58
/
surface_slice_cube.py
141 lines (96 loc) · 3.67 KB
/
surface_slice_cube.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"""
Slice a Cube with a surface, and get attributes between two horizons
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 pathlib
import tempfile
import xtgeo
DEBUG = False
EXPATH1 = pathlib.Path("../../xtgeo-testdata/cubes/etc/")
EXPATH2 = pathlib.Path("../../xtgeo-testdata/surfaces/etc")
TMPDIR = pathlib.Path(tempfile.gettempdir())
def slice_a_cube_with_surface():
"""Slice a seismic cube with a surface on OW dat/map format"""
cubefile = EXPATH1 / "ib_test_cube2.segy"
surfacefile = EXPATH2 / "h1.dat"
mycube = xtgeo.cube_from_file(cubefile)
# import map/dat surface using cube as template (inline/xline
# must match)
mysurf = xtgeo.surface_from_file(surfacefile, fformat="ijxyz", template=mycube)
# sample cube values to mysurf (replacing current depth values)
mysurf.slice_cube(mycube, sampling="trilinear")
# export result
mysurf.to_file(TMPDIR / "slice.dat", fformat="ijxyz")
def attribute_around_surface_symmetric():
"""Get atttribute around a surface (symmetric)"""
cubefile = EXPATH1 / "ib_test_cube2.segy"
surfacefile = EXPATH2 / "h1.dat"
mycube = xtgeo.cube_from_file(cubefile)
mysurf = xtgeo.surface_from_file(surfacefile, fformat="ijxyz", template=mycube)
attrs = ["max", "mean"]
myattrs = mysurf.slice_cube_window(
mycube, attribute=attrs, sampling="trilinear", zrange=10.0
)
for attr in myattrs:
myattrs[attr].to_file(
TMPDIR / ("myfile_symmetric_" + attr + ".dat"), fformat="ijxyz"
)
def attribute_around_surface_asymmetric():
"""Get attribute around a surface (asymmetric)"""
cubefile = EXPATH1 / "ib_test_cube2.segy"
surfacefile = EXPATH2 / "h1.dat"
above = 10
below = 20
mycube = xtgeo.cube_from_file(cubefile)
mysurf = xtgeo.surface_from_file(surfacefile, fformat="ijxyz", template=mycube)
# instead of using zrange, we make some tmp surfaces that
# reflects the assymmetric
sabove = mysurf.copy()
sbelow = mysurf.copy()
sabove.values -= above
sbelow.values += below
if DEBUG:
sabove.describe()
sbelow.describe()
attrs = "all"
myattrs = mysurf.slice_cube_window(
mycube, attribute=attrs, sampling="trilinear", zsurf=sabove, other=sbelow
)
for attr in myattrs:
if DEBUG:
myattrs[attr].describe()
myattrs[attr].to_file(
TMPDIR / ("myfile_asymmetric_" + attr + ".dat"), fformat="ijxyz"
)
def attribute_around_constant_cube_slices():
"""Get attribute around a constant cube slices"""
cubefile = EXPATH1 / "ib_test_cube2.segy"
level1 = 1010
level2 = 1100
mycube = xtgeo.cube_from_file(cubefile)
# instead of using zrange, we make some tmp surfaces that
# reflects the assymmetric; here sample slices from cube
sabove = xtgeo.surface_from_cube(mycube, level1)
sbelow = xtgeo.surface_from_cube(mycube, level2)
if DEBUG:
sabove.describe()
sbelow.describe()
attrs = "all"
myattrs = sabove.slice_cube_window(
mycube, attribute=attrs, sampling="trilinear", zsurf=sabove, other=sbelow
)
for attr in myattrs:
if DEBUG:
myattrs[attr].describe()
myattrs[attr].to_file(
TMPDIR / ("myfile_constlevels_" + attr + ".dat"), fformat="ijxyz"
)
if __name__ == "__main__":
slice_a_cube_with_surface()
attribute_around_surface_symmetric()
attribute_around_surface_asymmetric()
attribute_around_constant_cube_slices()
print(f"Running example OK: {pathlib.Path(__file__).name}")