本文整理汇总了Python中obspy.core.Stats.sac['baz']方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.sac['baz']方法的具体用法?Python Stats.sac['baz']怎么用?Python Stats.sac['baz']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Stats
的用法示例。
在下文中一共展示了Stats.sac['baz']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: combine_stats
# 需要导入模块: from obspy.core import Stats [as 别名]
# 或者: from obspy.core.Stats import sac['baz'] [as 别名]
def combine_stats(tr1, tr2):
""" Combine the meta-information of two ObsPy Trace objects
This function returns a ObsPy :class:`~obspy.core.trace.Stats` object
obtained combining the two associated with the input Traces.
Namely ``tr1.stats`` and ``tr2.stats``.
The fields ['network','station','location','channel'] are combined in
a ``-`` separated fashion to create a "pseudo" SEED like ``id``.
For all the others fields, only "common" information are retained: This
means that only keywords that exist in both dictionaries will be included
in the resulting one.
:type tr1: :class:`~obspy.core.trace.Trace`
:param tr1: First Trace
:type tr2: :class:`~obspy.core.trace.Trace`
:param tr2: Second Trace
:rtype: :class:`~obspy.core.trace.Stats`
:return: **stats**: combined Stats object
"""
if not isinstance(tr1, Trace):
raise TypeError("tr1 must be an obspy Trace object.")
if not isinstance(tr2, Trace):
raise TypeError("tr2 must be an obspy Trace object.")
tr1_keys = tr1.stats.keys()
tr2_keys = tr2.stats.keys()
stats = Stats()
# Adjust the information to create a new SEED like id
keywords = ['network', 'station', 'location', 'channel']
sac_keywords = ['sac']
for key in keywords:
if key in tr1_keys and key in tr2_keys:
stats[key] = tr1.stats[key] + '-' + tr2.stats[key]
for key in tr1_keys:
if key not in keywords and key not in sac_keywords:
if key in tr2_keys:
if tr1.stats[key] == tr2.stats[key]:
# in the stats object there are read only objects
try:
stats[key] = tr1.stats[key]
except AttributeError:
pass
try:
stats['sac'] = {}
stats.sac['stla'] = tr1.stats.sac.stla
stats.sac['stlo'] = tr1.stats.sac.stlo
stats.sac['stel'] = tr1.stats.sac.stel
stats.sac['evla'] = tr2.stats.sac.stla
stats.sac['evlo'] = tr2.stats.sac.stlo
stats.sac['evel'] = tr2.stats.sac.stel
az, baz, dist = trace_calc_az_baz_dist(tr1, tr2)
stats.sac['dist'] = dist / 1000
stats.sac['az'] = az
stats.sac['baz'] = baz
except AttributeError:
stats.pop('sac')
print "No station coordinates provided."
return stats