具有变量名称的键字符读取 segy 格式

Key character reading segy format with variable names

提问人:Pahan 提问时间:3/28/2023 更新时间:3/28/2023 访问量:17

问:

我有几次地震,格式为segy格式。我正在尝试为每个事件创建单独的 Streams(ObsPy),但这是不可能的,因为每个事件的名称根据日期而变化。

from obspy.io.segy.core import _read_segy
from obspy.core.util import get_example_file
# or 'from obspy import read' if file wide headers are of no interest
N=186
for i in range(N):
     stAll[i] = _read_segy("Event_" +str(N)+ "_*_surface.sgy")
print(st.__str__(extended=True))

对于根据日期的名称变体,我像往常一样使用键“*”(如您在代码中看到的那样)。但是,此密钥似乎无法识别。

这是我收到的错误:


OSError                                   Traceback (most recent call last)
C:\Users\pahan\AppData\Local\Temp/ipykernel_33276/2996703372.py in <module>
  5 stAll=[None]*186
  6 for i in range(N):
----> 7     stAll[i] = _read_segy("Event_" +str(N)+ "_*_surface.sgy")
  8 print(st.__str__(extended=True))

~\Anaconda3\lib\site-packages\obspy\io\segy\core.py in _read_segy(filename, headonly, 
byteorder, textual_header_encoding, unpack_trace_headers, **kwargs)
170     """
171     # Read file to the internal segy representation.
--> 172     segy_object = _read_segyrev1(
173         filename, endian=byteorder,
174         textual_header_encoding=textual_header_encoding,

~\Anaconda3\lib\site-packages\obspy\io\segy\segy.py in _read_segy(file, endian, 
textual_header_encoding, unpack_headers, headonly)
942     if not hasattr(file, 'read') or not hasattr(file, 'tell') or not \
943             hasattr(file, 'seek'):
--> 944         with open(file, 'rb') as open_file:
945             return _internal_read_segy(
946                 open_file, endian=endian,

OSError: [Errno 22] Invalid argument: 'Event_186_*_surface.sgy'

我将不胜感激任何帮助, 提前致谢!

python 无效参数 obspy

评论


答: 暂无答案