forked from gaia-up/shotwavemod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path001_example2dFDM.py
More file actions
57 lines (49 loc) · 1.88 KB
/
001_example2dFDM.py
File metadata and controls
57 lines (49 loc) · 1.88 KB
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
# This script performs 2D Seismic Wave and Shot Simulation using Finite Difference Method
# Tested under Ubuntu 18.04.5 LTS
# Developed by GAIA (Center for Geosciences Artifical Intelligence and Advanced Computing)
# Agus Abdullah, Ph.D. Waskito Pranowo, M.T. Dicky Ahmad Zaky, M.T.
# Universitas Pertamina - Indonesia 2021
# HOW TO RUN
# Step1: Define parameterization in seismic2dfdm.par (Parameters are from row 21 to 38 !)
# Step2: Run this Python script via Python IDE or Ubuntu Terminal: python 001_example2dFDM.py
# Input: seismic2dfdm.par and velocityoneshot2d.npy (size: nx,nz numpy format)
#Import required libraries
import subprocess
import numpy as np
import matplotlib.pyplot as plt
#step 1: define parameters in seismic2dfdm.par
filein = np.genfromtxt('seismic2dfdm.par', dtype=str, skip_header=20)
#step2: run the flow
subprocess.run(["./seismic2dfdm"])
#step3: visualize
xmax= float(filein[0])
zmax= float(filein[1])
dx= float(filein[2])
dz= float(filein[3])
model= filein[10]
path= filein[11]
shotfile= filein[17]
model = np.load(model)
nx = int(xmax / dx) # number of grid points in x-direction
nz = (int)(zmax / dz)
v = 0.0000001
shot = np.load('%s/%s.npy' % (path,shotfile))
plt.imshow(shot, aspect='auto', interpolation='bilinear', cmap='bwr', vmin=-v,vmax=v)
plt.suptitle('2D SHOT RECORD FINITE DIFFERENCE METHOD')
plt.ylim(300, 25)
plt.show()
fig = plt.figure(figsize=(7, 7))
plt.tight_layout()
extent = [0.0, xmax, zmax, 0.0]
plt.imshow(model.T, cmap='jet', interpolation='bilinear', extent=extent, alpha=1)
p = np.zeros((nx, nz))
image = plt.imshow(p.T, animated=True, cmap="Greys", extent=extent, interpolation='bilinear', vmin=-v, vmax=v,alpha=0.5)
plt.title('2D Wavefield')
plt.xlabel('x [m]')
plt.ylabel('z [m]')
plt.ion()
plt.show(block=False)
for i in range(300):
p = np.load('%s/wavefieldFDM_%s.npy' % (path, int(i+1)))
image.set_data(p.T)
fig.canvas.draw()