gpt4 book ai didi

python地震数据可视化详解

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 32 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章python地震数据可视化详解由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

本文实例为大家分享了python地震数据可视化的具体代码,供大家参考,具体内容如下 。

参考源码:seisplot 。

准备工作:

在windows10下安装python3.7,下载参考源码到本地.

1. demo绘图测试 。

demo绘图指令 。

cmd> python seisplot.py --demo 。

问题1)缺少依赖包 。

?
1
2
3
4
5
6
7
file "d:/desktop/python可视化/seisplot/seisplot.py" , line 16 , in <module>
  import yaml
modulenotfounderror: no module named 'yaml'
 
>pip3 install yaml
  could not find a version that satisfies the requirement yaml ( from versions: )
no matching distribution found for yaml

查看environment.yml

?
1
2
3
4
5
6
7
8
9
channels:
- defaults
- conda - forge
dependencies:
- matplotlib
- numpy
- obspy
- pillow
- pyyaml

安装相关依赖包,如 obspy pillow pyyaml  。

cmd> pip3 install obspy 。

出现proxy error, 添加选项 --proxy server:port 。

安装ok 。

问题2)配置文件的编码异常 。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
d:\desktop\python可视化\seisplot>python seisplot.py - - demo
[ 91m
  welcome to
  ┌─┐┌─┐┬┌─┐┌─┐┬ ┌─┐┌┬┐
  └─┐├┤ │└─┐├─┘│ │ │ │
  └─┘└─┘┴└─┘┴ ┴─┘└─┘ ┴
     good luck[ 0m
traceback (most recent call last):
  file "seisplot.py" , line 421 , in <module>
  cfg = yaml.load(f)
  file "d:\programfiles\python36\lib\site-packages\yaml\__init__.py" , line 70 , in load
  loader = loader(stream)
  file "d:\programfiles\python36\lib\site-packages\yaml\loader.py" , line 34 , in __init__
  reader.__init__( self , stream)
  file "d:\programfiles\python36\lib\site-packages\yaml\reader.py" , line 85 , in __init__
  self .determine_encoding()
  file "d:\programfiles\python36\lib\site-packages\yaml\reader.py" , line 124 , in determine_encoding
  self .update_raw()
  file "d:\programfiles\python36\lib\site-packages\yaml\reader.py" , line 178 , in update_raw
  data = self .stream.read(size)
unicodedecodeerror: 'gbk' codec can't decode byte 0x99 in position 2003 : illegal multibyte sequence

分析源码中参数传递情况:

?
1
2
3
4
5
6
7
8
9
10
11
def load(stream, loader = loader):
  """
  parse the first yaml document in a stream
  and produce the corresponding python object.
  """
  print (stream) ## debug by huanying03
  loader = loader(stream)
  try :
   return loader.get_single_data()
  finally :
   loader.dispose()

打印结果如下:

?
1
<_io.textiowrapper name = 'config.yml' mode = 'r' encoding = 'cp936' >

编码不对?

65001  :utf-8代码页 。

936 :默认的gbk 。

437 :是美国英语 。

仔细检查发现config.yml中有异常字符,更正config.yml中错误字符:ok 。

问题3)python调试打印语句 。

print ("value=%d"%value) 。

demo数据绘图结果 。

如下:

python地震数据可视化详解

2. 本地数据绘图测试 。

应用指令 。

cmd > python seisplot.py data/my.sgy 。

问题1)数据道的采样值异常 。

?
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
filename data2 / t10.sgy
seismic.py: 104 :dt = 4000
seismic.py: 104 :ns = 512
seismic.py: 144 :header = b 'c 1 client'
n_traces 500
n_samples 512
dt   0.004
t_start 0
t_end  2.044
max_val inf
min_val - inf
clip_val 180462501764003194804057887685476352
read data in 0.4 s
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
plotting
plot width 17.00 in
plot height 11.00 in
traceback (most recent call last):
  file "seisplot.py" , line 442 , in <module>
  main(t, cfg)
  file "seisplot.py" , line 214 , in main
  cfg)
  file "d:\desktop\python可视化\seisplot\plotter.py" , line 123 , in plot_histogram
  y, x, _ = ax.hist(np.ravel(data), bins = int ( 100.0 / (clip_val / largest)),
overflowerror: cannot convert float infinity to integer

解决办法:将数据做归一化处理 。

问题2)数据文件的卷头异常 。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
filename data2 / marmousi_vel.segy.hdrs.sgy.cdp.sgy
seismic.py: 104 :dt = 10000
seismic.py: 104 :ns = 350
seismic.py: 144 :header = b '\xc3@\xf1@\xc3\xd3\xc9\xc5\xd5\xe3'
traceback (most recent call last):
  file "seisplot.py" , line 442 , in <module>
  main(t, cfg)
  file "seisplot.py" , line 40 , in main
  s = seismic.from_segy(target, params = { 'ndim' : cfg[ 'ndim' ]})
  file "d:\desktop\python可视化\seisplot\seismic.py" , line 164 , in from_segy
  return cls .from_obspy(stream, params = params)
  file "d:\desktop\python可视化\seisplot\seismic.py" , line 147 , in from_obspy
  x = np.array( list (stream.textual_file_header.decode()))
unicodedecodeerror: 'utf-8' codec can't decode byte 0xc3 in position 0 : invalid continuation byte

解决办法:重写3200字节的segy卷头 。

marmousi相关数据绘图 。

速度模型绘图结果如下:

python地震数据可视化详解

marmousi模型正演的炮集数据绘图结果如下:

python地震数据可视化详解

测试备忘 。

1 。

cygwin执行指令,可以看到反馈信息为彩色,分析信息很方便.

相比之下,cmd终端执行指令后的反馈信息可读性较差.

2 。

本地数据出现异常后,通过cwp中的segyread, sushw, sugain, segywrite等程序进行修改,满足绘图程序要求.

1)3200字节的卷头必须规范 。

2)道头字中的cdpt取值必须规范(xline) 。

3)道采样值最好归一化处理.

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.

原文链接:https://blog.csdn.net/sinat_27917465/article/details/86517738 。

最后此篇关于python地震数据可视化详解的文章就讲到这里了,如果你想了解更多关于python地震数据可视化详解的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com