本文整理汇总了Python中obspy.core.Stats.location方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.location方法的具体用法?Python Stats.location怎么用?Python Stats.location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Stats
的用法示例。
在下文中一共展示了Stats.location方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_trace
# 需要导入模块: from obspy.core import Stats [as 别名]
# 或者: from obspy.core.Stats import location [as 别名]
def create_trace(self, channel, stats, data):
"""Utility to create a new trace object.
Parameters
----------
channel : str
channel name.
stats : obspy.core.Stats
channel metadata to clone.
data : numpy.array
channel data.
Returns
-------
obspy.core.Trace
trace containing data and metadata.
"""
stats = Stats(stats)
if self.data_type is None:
stats.data_type = 'adjusted'
else:
stats.data_type = self.data_type
if self.data_type is None:
stats.location = 'A0'
else:
stats.location = self.location
trace = super(AdjustedAlgorithm, self).create_trace(channel, stats,
data)
return trace
示例2: get_obspy_trace
# 需要导入模块: from obspy.core import Stats [as 别名]
# 或者: from obspy.core.Stats import location [as 别名]
def get_obspy_trace(self):
"""
Return class contents as obspy.Trace object
"""
stat = Stats()
stat.network = self.net.split(b'\x00')[0].decode()
stat.station = self.sta.split(b'\x00')[0].decode()
location = self.loc.split(b'\x00')[0].decode()
if location == '--':
stat.location = ''
else:
stat.location = location
stat.channel = self.chan.split(b'\x00')[0].decode()
stat.starttime = UTCDateTime(self.start)
stat.sampling_rate = self.rate
stat.npts = len(self.data)
return Trace(data=self.data, header=stat)
示例3: readSLIST
# 需要导入模块: from obspy.core import Stats [as 别名]
# 或者: from obspy.core.Stats import location [as 别名]
def readSLIST(filename, headonly=False, **kwargs): # @UnusedVariable
"""
Reads a ASCII SLIST 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: ASCII file to be read.
:type headonly: bool, optional
:param headonly: If set to True, read only the head. This is most useful
for scanning available data in huge (temporary) data sets.
:rtype: :class:`~obspy.core.stream.Stream`
:return: A ObsPy Stream object.
.. rubric:: Example
>>> from obspy import read
>>> st = read('/path/to/slist.ascii')
"""
with open(filename, 'rt') as fh:
# read file and split text into channels
buf = []
key = False
for line in fh:
if line.isspace():
# blank line
continue
elif line.startswith('TIMESERIES'):
# new header line
key = True
buf.append((line, StringIO()))
elif headonly:
# skip data for option headonly
continue
elif key:
# data entry - may be written in multiple columns
buf[-1][1].write(line.strip() + ' ')
# create ObsPy stream object
stream = Stream()
for header, data in buf:
# create Stats
stats = Stats()
parts = header.replace(',', '').split()
temp = parts[1].split('_')
stats.network = temp[0]
stats.station = temp[1]
stats.location = temp[2]
stats.channel = temp[3]
stats.sampling_rate = parts[4]
# quality only used in MSEED
stats.mseed = AttribDict({'dataquality': temp[4]})
stats.ascii = AttribDict({'unit': parts[-1]})
stats.starttime = UTCDateTime(parts[6])
stats.npts = parts[2]
if headonly:
# skip data
stream.append(Trace(header=stats))
else:
data = _parse_data(data, parts[8])
stream.append(Trace(data=data, header=stats))
return stream
示例4: readTSPAIR
# 需要导入模块: from obspy.core import Stats [as 别名]
# 或者: from obspy.core.Stats import location [as 别名]
def readTSPAIR(filename, headonly=False, **kwargs): # @UnusedVariable
"""
Reads a ASCII TSPAIR 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: ASCII file to be read.
:type headonly: bool, optional
:param headonly: If set to True, read only the headers. This is most useful
for scanning available data in huge (temporary) data sets.
:rtype: :class:`~obspy.core.stream.Stream`
:return: A ObsPy Stream object.
.. rubric:: Example
>>> from obspy import read
>>> st = read('/path/to/tspair.ascii')
"""
fh = open(filename, "rt")
# read file and split text into channels
headers = {}
key = None
for line in fh:
if line.isspace():
# blank line
continue
elif line.startswith("TIMESERIES"):
# new header line
key = line
headers[key] = StringIO()
elif headonly:
# skip data for option headonly
continue
elif key:
# data entry - may be written in multiple columns
headers[key].write(line.strip().split()[-1] + " ")
fh.close()
# create ObsPy stream object
stream = Stream()
for header, data in headers.iteritems():
# create Stats
stats = Stats()
parts = header.replace(",", "").split()
temp = parts[1].split("_")
stats.network = temp[0]
stats.station = temp[1]
stats.location = temp[2]
stats.channel = temp[3]
stats.sampling_rate = parts[4]
# quality only used in MSEED
stats.mseed = AttribDict({"dataquality": temp[4]})
stats.ascii = AttribDict({"unit": parts[-1]})
stats.starttime = UTCDateTime(parts[6])
stats.npts = parts[2]
if headonly:
# skip data
stream.append(Trace(header=stats))
else:
data = _parse_data(data, parts[8])
stream.append(Trace(data=data, header=stats))
return stream