基于python的三维射线追踪库-ttcrpy详解(3)
继续研究ttcrpy二维射线追踪,实现多发射点,多接收点的射线追踪。
1、模型一
2、模型二
3、模型三
4、python代码
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 27 15:37:28 2022
@author: 86159
"""
import ttcrpy.rgrid as rg
import numpy as np
import matplotlib.pyplot as plt
import time
# 创建网格
x = np.arange(1,11.0)
z = np.arange(1,12.0)
# 创建速度模型
v = 2000*np.ones((x.size,z.size))
v1 = 4000*np.ones((4, 4))
# index = [2,3]
# v[5:7,5:8] = v1
v[2:6,2:6] = v1
fig, ax = plt.subplots()
cs = plt.pcolor(v,cmap='jet')
fig.colorbar(cs)
plt.show()
# 给定发射点和接收点的坐标
srcs = np.array([[1,1.5],
[1,2.5],
[1,3.5],
[1,4.5],
[1,5.5],
[1,6.5],
[1,7.5],
[1,8.5]])
# src = np.array([[1,1.5]])
rcv = np.array([[10,1.5],
[10,2.5],
[10,3.5],
[10,4.5],
[10,5.5],
[10,6.5],
[10,7.5],
[10,8.5]])
# 离散网格
grid = rg.Grid2d(x, z, cell_slowness=False)
# 速度转换为慢度
slowness = 1./v
tt_all = np.empty(0)
rays_all = list()
for s in srcs:
src = np.array([s])
tt, rays = grid.raytrace(src, rcv, slowness, return_rays=True)
tt_all = np.append(tt_all,tt)
rays_all = rays_all + rays
# print(src)
# print(rcv)
# tt, rays = grid.raytrace(src, rcv, slowness, return_rays=True)
# 绘制走时图
plt.figure(2)
plt.plot(tt_all, 'r-o')
plt.show()
plt.figure(3)
# 绘制射线路径图
for r in rays_all:
plt.plot(r[:,0],r[:,1],'r-*')
此代码在spyder上运行
搬砖不易,走过路过,点个赞可好
|