forked from equinor/segyio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about.py
51 lines (39 loc) · 1.81 KB
/
about.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
import sys
from segyio import TraceField
import segyio
def list_byte_offset_names():
print("Available offsets and their corresponding byte value:")
for x in TraceField.enums():
print(" %s: %d" % (str(x), x))
if __name__ == '__main__':
if len(sys.argv) < 4:
list_byte_offset_names()
sys.exit("Usage: about.py [file] [inline] [crossline]")
# we need a way to convert from run-time inline/crossline argument (as
# text) to the internally used TraceField enum. Make a string -> TraceField
# map and look up into that. this dictionary comprehension creates that
fieldmap = {str(x).lower(): x for x in TraceField.enums()}
filename = sys.argv[1]
inline_name, crossline_name = sys.argv[2].lower(), sys.argv[3].lower()
# exit if inline or crossline are unknown
if inline_name not in fieldmap:
list_byte_offset_names()
sys.exit("Unknown inline field '%s'" % sys.argv[2])
if crossline_name not in fieldmap:
list_byte_offset_names()
sys.exit("Unknown crossline field '%s'" % sys.argv[3])
inline, crossline = fieldmap[inline_name], fieldmap[crossline_name]
with segyio.open(filename, "r", inline, crossline) as f:
print("About '%s':" % filename)
print("Format type: %s" % f.format)
print("Offset count: %d" % f.offsets)
print("ilines: %s" % ", ".join(map(str, f.ilines)))
print("xlines: %s" % ", ".join(map(str, f.xlines)))
print("+------+")
with segyio.open(filename, "r", crossline, inline) as f:
# with swapped inline/crossline
print("About '%s':" % filename)
print("Format type: %s" % f.format)
print("Offset count: %d" % f.offsets)
print("ilines: %s" % ", ".join(map(str, f.ilines)))
print("xlines: %s" % ", ".join(map(str, f.xlines)))