本文整理汇总了Python中obspy.core.AttribDict.update方法的典型用法代码示例。如果您正苦于以下问题:Python AttribDict.update方法的具体用法?Python AttribDict.update怎么用?Python AttribDict.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.AttribDict
的用法示例。
在下文中一共展示了AttribDict.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rfstats
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import update [as 别名]
def rfstats(obj=None, event=None, station=None,
phase='P', dist_range='default', tt_model='iasp91',
pp_depth=None, pp_phase=None, model='iasp91'):
"""
Calculate ray specific values like slowness for given event and station.
:param obj: `~obspy.core.trace.Stats` object with event and/or station
attributes. Can be None if both event and station are given.
It is possible to specify a stream object, too. Then, rfstats will be
called for each Trace.stats object and traces outside dist_range will
be discarded.
:param event: ObsPy `~obspy.core.event.event.Event` object
:param station: dictionary like object with items latitude, longitude and
elevation
:param phase: string with phase. Usually this will be 'P' or
'S' for P and S receiver functions, respectively.
:type dist_range: tuple of length 2
:param dist_range: if epicentral of event is not in this intervall, None
is returned by this function,\n
if phase == 'P' defaults to (30, 90),\n
if phase == 'S' defaults to (50, 85)
:param tt_model: model for travel time calculation.
(see the `obspy.taup` module, default: iasp91)
:param pp_depth: Depth for piercing point calculation
(in km, default: None -> No calculation)
:param pp_phase: Phase for pp calculation (default: 'S' for P-receiver
function and 'P' for S-receiver function)
:param model: Path to model file for pp calculation
(see `.SimpleModel`, default: iasp91)
:return: `~obspy.core.trace.Stats` object with event and station
attributes, distance, back_azimuth, inclination, onset and
slowness or None if epicentral distance is not in the given interval.
Stream instance if stream was specified instead of stats.
"""
if isinstance(obj, (Stream, RFStream)):
stream = obj
kwargs = {'event': event, 'station': station,
'phase': phase, 'dist_range': dist_range,
'tt_model': tt_model, 'pp_depth': pp_depth,
'pp_phase': pp_phase, 'model': model}
traces = []
for tr in stream:
if rfstats(tr.stats, **kwargs) is not None:
traces.append(tr)
stream.traces = traces
return stream
if dist_range == 'default' and phase.upper() in 'PS':
dist_range = (30, 90) if phase.upper() == 'P' else (50, 85)
stats = AttribDict({}) if obj is None else obj
if event is not None and station is not None:
stats.update(obj2stats(event=event, station=station))
dist, baz, _ = gps2dist_azimuth(stats.station_latitude,
stats.station_longitude,
stats.event_latitude,
stats.event_longitude)
dist = dist / 1000 / DEG2KM
if dist_range and not dist_range[0] <= dist <= dist_range[1]:
return
tt_model = TauPyModel(model=tt_model)
arrivals = tt_model.get_travel_times(stats.event_depth, dist, (phase,))
if len(arrivals) == 0:
raise Exception('TauPy does not return phase %s at distance %s' %
(phase, dist))
if len(arrivals) > 1:
msg = ('TauPy returns more than one arrival for phase %s at '
'distance -> take first arrival')
warnings.warn(msg % (phase, dist))
arrival = arrivals[0]
onset = stats.event_time + arrival.time
inc = arrival.incident_angle
slowness = arrival.ray_param_sec_degree
stats.update({'distance': dist, 'back_azimuth': baz, 'inclination': inc,
'onset': onset, 'slowness': slowness, 'phase': phase})
if pp_depth is not None:
model = load_model(model)
if pp_phase is None:
pp_phase = 'S' if phase.upper().endswith('P') else 'P'
model.ppoint(stats, pp_depth, phase=pp_phase)
return stats