Python读取segy格式数据
文章目录
Marmousi模型
以marmousi模型为例,读取结果如下:
python代码分享
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 6 18:32:49 2022
@author: gongxian
E_mail: xiangshang1104@gmail.com
To: Stay hungry! Stay foolish!!
"""
# 此程序是读取segy格式文件
import os
import segyio
import numpy as np
import matplotlib.pyplot as plt
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
# 选择segy文件
filename = filedialog.askopenfilename()
# 初始化一个列表存数据,最后再转为矩阵
data_list = []
with segyio.open(filename) as f:
for i in range(len(f.trace)):
data_list.append(f.trace[i])
# 转为矩阵
data_numpy = np.array(data_list)
data_numpy = data_numpy.T
# plt.pcolor(data_numpy,cmap = 'jet')
plt.contourf(data_numpy,cmap = 'jet')
plt.colorbar()
plt.xlabel('position[m]')
ax = plt.gca()
# ax.xaxis.set_ticks_position('top')
ax.invert_yaxis()
ax.xaxis.tick_top()