本文整理汇总了Python中obspy.core.Stream.stats方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.stats方法的具体用法?Python Stream.stats怎么用?Python Stream.stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Stream
的用法示例。
在下文中一共展示了Stream.stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readSEGY
# 需要导入模块: from obspy.core import Stream [as 别名]
# 或者: from obspy.core.Stream import stats [as 别名]
def readSEGY(filename, headonly=False, byteorder=None,
textual_header_encoding=None, unpack_trace_headers=False,
**kwargs): # @UnusedVariable
"""
Reads a SEG Y file and returns an ObsPy Stream object.
.. warning::
This function should NOT be called directly, it registers via the
ObsPy :func:`~obspy.core.stream.read` function, call this instead.
:type filename: str
:param filename: SEG Y rev1 file to be read.
:type headonly: boolean, optional
:param headonly: If set to True, read only the header and omit the waveform
data.
:type byteorder: ``'<'``, ``'>'``, or ``None``
:param byteorder: Determines the endianness of the file. Either ``'>'`` for
big endian or ``'<'`` for little endian. If it is ``None``, it will try
to autodetect the endianness. The endianness is always valid for the
whole file. Defaults to ``None``.
:type textual_header_encoding: ``'EBCDIC'``, ``'ASCII'`` or ``None``
:param textual_header_encoding: The encoding of the textual header. If it
is ``None``, autodetection will be attempted. Defaults to ``None``.
:type unpack_trace_headers: bool, optional
:param unpack_trace_headers: Determines whether or not all trace header
values will be unpacked during reading. If ``False`` it will greatly
enhance performance and especially memory usage with large files. The
header values can still be accessed and will be calculated on the fly
but tab completion will no longer work. Look in the headers.py for a
list of all possible trace header values. Defaults to ``False``.
:returns: A ObsPy :class:`~obspy.core.stream.Stream` object.
.. rubric:: Example
>>> from obspy.core import read
>>> st = read("/path/to/00001034.sgy_first_trace")
>>> st # doctest: +ELLIPSIS
<obspy.core.stream.Stream object at 0x...>
>>> print(st) # doctest: +ELLIPSIS
1 Trace(s) in Stream:
Seq. No. in line: 1 | 2009-06-22T14:47:37.000000Z - ... 2001 samples
"""
# Read file to the internal segy representation.
segy_object = readSEGYrev1(filename, endian=byteorder,
textual_header_encoding=textual_header_encoding,
unpack_headers=unpack_trace_headers)
# Create the stream object.
stream = Stream()
# SEGY has several file headers that apply to all traces. They will be
# stored in Stream.stats.
stream.stats = AttribDict()
# Get the textual file header.
textual_file_header = segy_object.textual_file_header
# The binary file header will be a new AttribDict
binary_file_header = AttribDict()
for key, value in segy_object.binary_file_header.__dict__.iteritems():
setattr(binary_file_header, key, value)
# Get the data encoding and the endianness from the first trace.
data_encoding = segy_object.traces[0].data_encoding
endian = segy_object.traces[0].endian
textual_file_header_encoding = segy_object.textual_header_encoding.upper()
# Add the file wide headers.
stream.stats.textual_file_header = textual_file_header
stream.stats.binary_file_header = binary_file_header
# Also set the data encoding, endianness and the encoding of the
# textual_file_header.
stream.stats.data_encoding = data_encoding
stream.stats.endian = endian
stream.stats.textual_file_header_encoding = \
textual_file_header_encoding
# Loop over all traces.
for tr in segy_object.traces:
# Create new Trace object for every segy trace and append to the Stream
# object.
trace = Trace()
stream.append(trace)
# skip data if headonly is set
if headonly:
trace.stats.npts = tr.npts
else:
trace.data = tr.data
trace.stats.segy = AttribDict()
# If all values will be unpacked create a normal dictionary.
if unpack_trace_headers:
# Add the trace header as a new attrib dictionary.
header = AttribDict()
for key, value in tr.header.__dict__.iteritems():
setattr(header, key, value)
# Otherwise use the LazyTraceHeaderAttribDict.
else:
# Add the trace header as a new lazy attrib dictionary.
header = LazyTraceHeaderAttribDict(tr.header.unpacked_header,
tr.header.endian)
trace.stats.segy.trace_header = header
# The sampling rate should be set for every trace. It is a sample
# interval in microseconds. The only sanity check is that is should be
# larger than 0.
tr_header = trace.stats.segy.trace_header
if tr_header.sample_interval_in_ms_for_this_trace > 0:
trace.stats.delta = \
#.........这里部分代码省略.........