为我将将第二张图的画图方式改为pcolor,并模拟运行结果# -- coding: utf-8 -- """ Created on Thu Jun 1 17:06:08 2023 @author: Rayquaza """ import numpy as np import matplotlib.pyplot as plt def ricker(f, length, dt): t = np.arange(-length/2,(length-dt)/2, dt) y = (1.0 - 2.0*(np.pi2)(f2)(t2)) * np.exp(-(np.pi2)(f2)(t2)) return t,y Frequency = 20 length = 0.128 dt = 0.001 t0, w0 = ricker(Frequency, length, dt) rho = np.array([1.6, 2.4, 1.8]) v = np.array([2000, 3000, 2200]) x = np.arange(0, 500, 1) t = np.arange(0, 0.3, dt) Z = rho*v d_model = np.zeros((2, 500)) for i in range(500): d_model[0, i] = 200 if i < 50: d_model[1, i] = 200 elif i < 250 and i >= 50: d_model[1, i] = 200 + (i-50) elif i >=250: d_model[1, i] = 400 t1 = np.zeros((2, 500)) t1[0, :] = d_model[0,:] / v[1] for i in range(500): t1[1, i] = (d_model[1, i] - d_model[0, i]) / v[2] + t1[0, i] L = np.zeros(2) for i in range(2): L[i] = (Z[i+1] - Z[i]) / (Z[i+1] + Z[i]) L1 = np.zeros([300, 500]) for i in range(2): for j in range(500): if j < 50: L1[int(np.round(t1[i,j]/dt)),j] = (Z[2]-Z[0]) / (Z[2]+Z[0]) else: L1[int(np.round(t1[i,j]/dt)),j] = L[i] syn = np.zeros((300, 500)) for j in range(500): syn[: , j] = np.convolve(L1[:,j], w0, 'same') fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(18, 9)) axes[0].plot(w0, t0, 'b-') axes[0].xaxis.set_ticks_position('top') axes[0].invert_yaxis() axes[0].set_title("Amplitude", fontsize = 12) axes[0].set_ylabel("Time(s)",fontsize = 12) X, T = np.meshgrid(x, t) c = axes[1].contour(X, T, L1) axes[1].xaxis.set_ticks_position('top') axes[1].invert_yaxis() axes[1].set_title("Reflection Coefficient", fontsize = 12) axes[1].set_ylabel("Eight-Way Travel Time(s)",fontsize = 12) c_map = axes[2].pcolormesh(X, T, syn, cmap='bwr', shading='auto') axes[2].xaxis.set_ticks_position('top') axes[2].invert_yaxis() axes[2].set_xlabel("Amplitude", fontsize = 12) axes[2].set_ylabel("Two-Way Travel Time(s)",fontsize = 12) fig.colorbar(c_map, ax=axes[2]) fig.suptitle('Two-Layer Synthetic Seismogram', fontsize = 18) plt.tight_layout() plt.show()
时间: 2024-01-30 08:03:13 浏览: 95
react-hooks-lifecycle:life:hourglass_not_done:React生命周期挂钩图
好的,我已经理解了你的要求。下面是修改后的代码:
```python
# -- coding: utf-8 --
"""
Created on Thu Jun 1 17:06:08 2023
@author: Rayquaza
"""
import numpy as np
import matplotlib.pyplot as plt
def ricker(f, length, dt):
t = np.arange(-length/2,(length-dt)/2, dt)
y = (1.0 - 2.0
阅读全文