-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathshow_gathers.py
38 lines (37 loc) · 1.13 KB
/
show_gathers.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
import numpy as np
import matplotlib.pyplot as plt
import os
from yaml import load
from yaml import CLoader as Loader
np.random.seed(20240825)
import h5py
"""
Configures
"""
config_path = "./configs/tti.yml"
obsPath = "./shot_gather_tti.hdf5"
name = os.path.basename(obsPath).split('.')[0]
# Load the configure file
with open(config_path, 'r') as ymlfile:
cfg = load(ymlfile, Loader=Loader)
# show 5 shots randomly
showshots = np.random.randint(0, 76, 3)
# Plot the data
fig, axes = plt.subplots(nrows=1, ncols=showshots.size, figsize=(6, 4))
for ax, shot_no in zip(axes.ravel(), showshots.tolist()):
with h5py.File(obsPath, 'r') as f:
d = f[f'shot_{shot_no}'][:]
nsamples, ntraces, nc = d.shape
vmin, vmax = np.percentile(d, [2, 98])
kwargs = {"cmap": "seismic",
"aspect": "auto",
"vmin": vmin,
"vmax": vmax,
"extent": [0, ntraces*cfg['geom']['h'], nsamples*cfg['geom']['dt'], 0]}
ax.imshow(d[..., 0], **kwargs)
ax.set_xlabel("x (m)")
ax.set_ylabel("t (s)")
ax.set_title(f"Shot {shot_no}")
plt.tight_layout()
plt.savefig(f"{name}.png", dpi=300)
plt.show()