forked from SPECFEM/specfem3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_ASDF_data_info.py
executable file
·106 lines (88 loc) · 2.33 KB
/
plot_ASDF_data_info.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
#!/usr/bin/env python
#
# reads in an ASDF-format file and outputs infos about content and checks validity
# see: http://seismicdata.github.io/pyasdf/tutorial.html
#
from __future__ import print_function
import sys
try:
import pyasdf
except:
print("Error importing pyasdf, check if pyasdf module is installed")
print("")
# python version
print("python version:")
print(sys.version)
print("")
# import module paths
print("module paths:")
for path in sys.path:
print(path)
print("")
sys.exit(1)
def plot_ASDF_data_info(file,show_plot):
print("")
print("reading file: ",filename)
print("")
ds = pyasdf.ASDFDataSet(filename)
# file info
print("file info...")
print(ds)
print("")
# validate
print("validate...")
ds.validate()
print("")
# event info
print("event info...")
print(" number of events: ",len(ds.events))
print("")
type(ds.events)
print(ds.events)
for event in ds.events:
print(event)
print("")
# station info
print("")
print("station list...")
print(" number of stations: ",len(ds.waveforms))
print("")
print(ds.waveforms.list())
print("")
for station in ds.waveforms.list():
print("")
print("station:")
print("")
print(station)
# how to get station name and associated waveform?
# waveforms
sta = ds.waveforms[station]
type(sta)
print(sta.synthetic)
print("")
print("waveform list:",sta.list())
print("waveform tags:",sta.get_waveform_tags())
print("")
# plotting
if show_plot:
print("plotting stream...")
st = sta.synthetic
st.plot()
def usage():
print("usage: ./plot_ASDF_data_info.py filename[e.g. synthetic.h5] [show]")
print(" with")
print(" filename - e.g. OUTPUT_FILES/synthetic.h5")
print(" show - (optional) plot waveforms")
sys.exit(1)
if __name__ == "__main__":
# gets arguments
do_plot_waveforms = False
if len(sys.argv) == 2:
filename = sys.argv[1]
elif len(sys.argv) == 3:
filename = sys.argv[1]
if sys.argv[2] == "show": do_plot_waveforms = True
else:
usage()
sys.exit(1)
plot_ASDF_data_info(filename,do_plot_waveforms)