-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgenerate_geometry.py
executable file
·48 lines (38 loc) · 1.53 KB
/
generate_geometry.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
import os, pickle
import numpy as np
import matplotlib.pyplot as plt
import sys
sys.path.append("../../..")
from seistorch.show import SeisShow
def write_pkl(path: str, data: list):
# Open the file in binary mode and write the list using pickle
with open(path, 'wb') as f:
pickle.dump(data, f)
show = SeisShow()
dtype = np.float32
nz = 151
nx = 301
# Generate the source and receiver list
# Please note that in Seistorch,
# the coordinates of source points and receiver points are
# specified in a grid coordinate system, not in real-world distance coordinates.
# This distinction is essential for accurate simulation and interpretation of results.
src_x = np.arange(0, nx, 4)
src_z = np.ones_like(src_x)*1
sources = [[src_x, src_z] for src_x, src_z in zip(src_x.tolist(), src_z.tolist())]
# Receivers: [[0, 1, ..., 255], [5, 5, ..., 5],
# [0, 1, ..., 255], [5, 5, ..., 5],
# [0, 1, ..., 255], [5, 5, ..., 5],
# ],
receiver_locx = np.arange(0, nx, 2)
receiver_locz = np.ones_like(receiver_locx)*1
# The receivers are fixed at the bottom of the model (z=5)
receivers = [[receiver_locx.tolist(), receiver_locz.tolist()]]*len(sources)
assert len(sources) == len(receivers), \
"The number of sources and receivers must be the same."
print(f"Number of sources: {len(sources)}")
# Save the source and receiver list
save_path = r"./geometry"
os.makedirs(save_path, exist_ok=True)
write_pkl(os.path.join(save_path, "sources.pkl"), sources)
write_pkl(os.path.join(save_path, "receivers.pkl"), receivers)