本文整理汇总了Python中obspy.core.event.Event.picks方法的典型用法代码示例。如果您正苦于以下问题:Python Event.picks方法的具体用法?Python Event.picks怎么用?Python Event.picks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.Event
的用法示例。
在下文中一共展示了Event.picks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: outputOBSPY
# 需要导入模块: from obspy.core.event import Event [as 别名]
# 或者: from obspy.core.event.Event import picks [as 别名]
def outputOBSPY(hp, event=None, only_fm_picks=False):
"""
Make an Event which includes the current focal mechanism information from HASH
Use the 'only_fm_picks' flag to only include the picks HASH used for the FocalMechanism.
This flag will replace the 'picks' and 'arrivals' lists of existing events with new ones.
Inputs
-------
hp : hashpy.HashPype instance
event : obspy.core.event.Event
only_fm_picks : bool of whether to overwrite the picks/arrivals lists
Returns
-------
obspy.core.event.Event
Event will be new if no event was input, FocalMech added to existing event
"""
# Returns new (or updates existing) Event with HASH solution
n = hp.npol
if event is None:
event = Event(focal_mechanisms=[], picks=[], origins=[])
origin = Origin(arrivals=[])
origin.time = UTCDateTime(hp.tstamp)
origin.latitude = hp.qlat
origin.longitude = hp.qlon
origin.depth = hp.qdep
origin.creation_info = CreationInfo(version=hp.icusp)
origin.resource_id = ResourceIdentifier('smi:hash/Origin/{0}'.format(hp.icusp))
for _i in range(n):
p = Pick()
p.creation_info = CreationInfo(version=hp.arid[_i])
p.resource_id = ResourceIdentifier('smi:hash/Pick/{0}'.format(p.creation_info.version))
p.waveform_id = WaveformStreamID(network_code=hp.snet[_i], station_code=hp.sname[_i], channel_code=hp.scomp[_i])
if hp.p_pol[_i] > 0:
p.polarity = 'positive'
else:
p.polarity = 'negative'
a = Arrival()
a.creation_info = CreationInfo(version=hp.arid[_i])
a.resource_id = ResourceIdentifier('smi:hash/Arrival/{0}'.format(p.creation_info.version))
a.azimuth = hp.p_azi_mc[_i,0]
a.takeoff_angle = 180. - hp.p_the_mc[_i,0]
a.pick_id = p.resource_id
origin.arrivals.append(a)
event.picks.append(p)
event.origins.append(origin)
event.preferred_origin_id = str(origin.resource_id)
else: # just update the changes
origin = event.preferred_origin()
picks = []
arrivals = []
for _i in range(n):
ind = hp.p_index[_i]
a = origin.arrivals[ind]
p = a.pick_id.getReferredObject()
a.takeoff_angle = hp.p_the_mc[_i,0]
picks.append(p)
arrivals.append(a)
if only_fm_picks:
origin.arrivals = arrivals
event.picks = picks
# Use me double couple calculator and populate planes/axes etc
x = hp._best_quality_index
# Put all the mechanisms into the 'focal_mechanisms' list, mark "best" as preferred
for s in range(hp.nmult):
dc = DoubleCouple([hp.str_avg[s], hp.dip_avg[s], hp.rak_avg[s]])
ax = dc.axis
focal_mech = FocalMechanism()
focal_mech.creation_info = CreationInfo(creation_time=UTCDateTime(), author=hp.author)
focal_mech.triggering_origin_id = origin.resource_id
focal_mech.resource_id = ResourceIdentifier('smi:hash/FocalMechanism/{0}/{1}'.format(hp.icusp, s+1))
focal_mech.method_id = ResourceIdentifier('HASH')
focal_mech.nodal_planes = NodalPlanes()
focal_mech.nodal_planes.nodal_plane_1 = NodalPlane(*dc.plane1)
focal_mech.nodal_planes.nodal_plane_2 = NodalPlane(*dc.plane2)
focal_mech.principal_axes = PrincipalAxes()
focal_mech.principal_axes.t_axis = Axis(azimuth=ax['T']['azimuth'], plunge=ax['T']['dip'])
focal_mech.principal_axes.p_axis = Axis(azimuth=ax['P']['azimuth'], plunge=ax['P']['dip'])
focal_mech.station_polarity_count = n
focal_mech.azimuthal_gap = hp.magap
focal_mech.misfit = hp.mfrac[s]
focal_mech.station_distribution_ratio = hp.stdr[s]
focal_mech.comments.append(
Comment(hp.qual[s], resource_id=ResourceIdentifier(str(focal_mech.resource_id) + '/comment/quality'))
)
#----------------------------------------
event.focal_mechanisms.append(focal_mech)
if s == x:
event.preferred_focal_mechanism_id = str(focal_mech.resource_id)
return event
示例2: full_test_event
# 需要导入模块: from obspy.core.event import Event [as 别名]
# 或者: from obspy.core.event.Event import picks [as 别名]
def full_test_event():
"""
Function to generate a basic, full test event
"""
test_event = Event()
test_event.origins.append(Origin(
time=UTCDateTime("2012-03-26") + 1.2, latitude=45.0, longitude=25.0,
depth=15000))
test_event.event_descriptions.append(EventDescription())
test_event.event_descriptions[0].text = 'LE'
test_event.creation_info = CreationInfo(agency_id='TES')
test_event.magnitudes.append(Magnitude(
mag=0.1, magnitude_type='ML', creation_info=CreationInfo('TES'),
origin_id=test_event.origins[0].resource_id))
test_event.magnitudes.append(Magnitude(
mag=0.5, magnitude_type='Mc', creation_info=CreationInfo('TES'),
origin_id=test_event.origins[0].resource_id))
test_event.magnitudes.append(Magnitude(
mag=1.3, magnitude_type='Ms', creation_info=CreationInfo('TES'),
origin_id=test_event.origins[0].resource_id))
# Define the test pick
_waveform_id_1 = WaveformStreamID(station_code='FOZ', channel_code='SHZ',
network_code='NZ')
_waveform_id_2 = WaveformStreamID(station_code='WTSZ', channel_code='BH1',
network_code=' ')
# Pick to associate with amplitude - 0
test_event.picks = [
Pick(waveform_id=_waveform_id_1, phase_hint='IAML',
polarity='undecidable', time=UTCDateTime("2012-03-26") + 1.68,
evaluation_mode="manual"),
Pick(waveform_id=_waveform_id_1, onset='impulsive', phase_hint='PN',
polarity='positive', time=UTCDateTime("2012-03-26") + 1.68,
evaluation_mode="manual"),
Pick(waveform_id=_waveform_id_1, phase_hint='IAML',
polarity='undecidable', time=UTCDateTime("2012-03-26") + 1.68,
evaluation_mode="manual"),
Pick(waveform_id=_waveform_id_2, onset='impulsive', phase_hint='SG',
polarity='undecidable', time=UTCDateTime("2012-03-26") + 1.72,
evaluation_mode="manual"),
Pick(waveform_id=_waveform_id_2, onset='impulsive', phase_hint='PN',
polarity='undecidable', time=UTCDateTime("2012-03-26") + 1.62,
evaluation_mode="automatic")]
# Test a generic local magnitude amplitude pick
test_event.amplitudes = [
Amplitude(generic_amplitude=2.0, period=0.4,
pick_id=test_event.picks[0].resource_id,
waveform_id=test_event.picks[0].waveform_id, unit='m',
magnitude_hint='ML', category='point', type='AML'),
Amplitude(generic_amplitude=10,
pick_id=test_event.picks[1].resource_id,
waveform_id=test_event.picks[1].waveform_id, type='END',
category='duration', unit='s', magnitude_hint='Mc',
snr=2.3),
Amplitude(generic_amplitude=5.0, period=0.6,
pick_id=test_event.picks[2].resource_id,
waveform_id=test_event.picks[0].waveform_id, unit='m',
category='point', type='AML')]
test_event.origins[0].arrivals = [
Arrival(time_weight=0, phase=test_event.picks[1].phase_hint,
pick_id=test_event.picks[1].resource_id),
Arrival(time_weight=2, phase=test_event.picks[3].phase_hint,
pick_id=test_event.picks[3].resource_id,
backazimuth_residual=5, time_residual=0.2, distance=15,
azimuth=25),
Arrival(time_weight=2, phase=test_event.picks[4].phase_hint,
pick_id=test_event.picks[4].resource_id,
backazimuth_residual=5, time_residual=0.2, distance=15,
azimuth=25)]
# Add in error info (line E)
test_event.origins[0].quality = OriginQuality(
standard_error=0.01, azimuthal_gap=36)
# Origin uncertainty in Seisan is output as long-lat-depth, quakeML has
# semi-major and semi-minor
test_event.origins[0].origin_uncertainty = OriginUncertainty(
confidence_ellipsoid=ConfidenceEllipsoid(
semi_major_axis_length=3000, semi_minor_axis_length=1000,
semi_intermediate_axis_length=2000, major_axis_plunge=20,
major_axis_azimuth=100, major_axis_rotation=4))
test_event.origins[0].time_errors = QuantityError(uncertainty=0.5)
# Add in fault-plane solution info (line F) - Note have to check program
# used to determine which fields are filled....
test_event.focal_mechanisms.append(FocalMechanism(
nodal_planes=NodalPlanes(nodal_plane_1=NodalPlane(
strike=180, dip=20, rake=30, strike_errors=QuantityError(10),
dip_errors=QuantityError(10), rake_errors=QuantityError(20))),
method_id=ResourceIdentifier("smi:nc.anss.org/focalMechanism/FPFIT"),
creation_info=CreationInfo(agency_id="NC"), misfit=0.5,
station_distribution_ratio=0.8))
# Need to test high-precision origin and that it is preferred origin.
# Moment tensor includes another origin
test_event.origins.append(Origin(
time=UTCDateTime("2012-03-26") + 1.2, latitude=45.1, longitude=25.2,
depth=14500))
test_event.magnitudes.append(Magnitude(
mag=0.1, magnitude_type='MW', creation_info=CreationInfo('TES'),
origin_id=test_event.origins[-1].resource_id))
# Moment tensors go with focal-mechanisms
test_event.focal_mechanisms.append(FocalMechanism(
moment_tensor=MomentTensor(
#.........这里部分代码省略.........
示例3: stalta_pick
# 需要导入模块: from obspy.core.event import Event [as 别名]
# 或者: from obspy.core.event.Event import picks [as 别名]
def stalta_pick(stream, stalen, ltalen, trig_on, trig_off, freqmin=False,
freqmax=False, debug=0, show=False):
"""
Basic sta/lta picker, suggest using alternative in obspy.
Simple sta-lta (short-term average/long-term average) picker, using \
obspy's stalta routine to generate the characteristic function.
Currently very basic quick wrapper, there are many other (better) options \
in obspy, found \
`here <http://docs.obspy.org/packages/autogen/obspy.signal.trigger.html>`_.
:type stream: obspy.Stream
:param stream: The stream to pick on, can be any number of channels.
:type stalen: float
:param stalen: Length of the short-term average window in seconds.
:type ltalen: float
:param ltalen: Length of the long-term average window in seconds.
:type trig_on: float
:param trig_on: sta/lta ratio to trigger a detection/pick
:type trig_off: float
:param trig_off: sta/lta ratio to turn the trigger off - no further picks\
will be made between exceeding trig_on until trig_off is reached.
:type freqmin: float
:param freqmin: Low-cut frequency in Hz for bandpass filter
:type freqmax: float
:param freqmax: High-cut frequency in Hz for bandpass filter
:type debug: int
:param debug: Debug output level from 0-5.
:type show: bool
:param show: Show picks on waveform.
:returns: obspy.core.event.Event
.. rubric:: Example
>>> from obspy import read
>>> from eqcorrscan.utils.picker import stalta_pick
>>> st = read()
>>> event = stalta_pick(st, stalen=0.2, ltalen=4, trig_on=10,
... trig_off=1, freqmin=3.0, freqmax=20.0)
>>> event.creation_info.author
'EQcorrscan'
"""
from obspy.signal.trigger import classic_sta_lta, trigger_onset
from obspy.signal.trigger import plot_trigger
from obspy import UTCDateTime
from obspy.core.event import Event, Pick, WaveformStreamID
from obspy.core.event import CreationInfo, Comment, Origin
import eqcorrscan.utils.plotting as plotting
event = Event()
event.origins.append(Origin())
event.creation_info = CreationInfo(author='EQcorrscan',
creation_time=UTCDateTime())
event.comments.append(Comment(text='stalta'))
picks = []
for tr in stream:
# We are going to assume, for now, that if the pick is made on the
# horizontal channel then it is an S, otherwise we will assume it is
# a P-phase: obviously a bad assumption...
if tr.stats.channel[-1] == 'Z':
phase = 'P'
else:
phase = 'S'
if freqmin and freqmax:
tr.detrend('simple')
tr.filter('bandpass', freqmin=freqmin, freqmax=freqmax,
corners=3, zerophase=True)
df = tr.stats.sampling_rate
cft = classic_sta_lta(tr.data, int(stalen * df), int(ltalen * df))
if debug > 3:
plot_trigger(tr, cft, trig_on, trig_off)
triggers = trigger_onset(cft, trig_on, trig_off)
for trigger in triggers:
on = tr.stats.starttime + (trigger[0] / df)
# off = tr.stats.starttime + (trigger[1] / df)
wav_id = WaveformStreamID(station_code=tr.stats.station,
channel_code=tr.stats.channel,
network_code=tr.stats.network)
pick = Pick(waveform_id=wav_id, phase_hint=phase, time=on)
if debug > 2:
print('Pick made:')
print(pick)
picks.append(pick)
# QC picks
del pick
pick_stations = list(set([pick.waveform_id.station_code for pick in picks]))
for pick_station in pick_stations:
station_picks = [pick for pick in picks if
pick.waveform_id.station_code == pick_station]
# If P-pick is after S-picks, remove it.
p_time = [pick.time for pick in station_picks if pick.phase_hint == 'P']
s_time = [pick.time for pick in station_picks if pick.phase_hint == 'S']
if p_time > s_time:
p_pick = [pick for pick in station_picks if pick.phase_hint == 'P']
for pick in p_pick:
print('P pick after S pick, removing P pick')
picks.remove(pick)
if show:
plotting.pretty_template_plot(stream, picks=picks, title='Autopicks',
#.........这里部分代码省略.........