[Bugfix]: Check for key S and be sure to get element weight for pick

dictionary.
This commit is contained in:
Ludger Küperkoch 2020-07-29 12:14:42 +02:00
parent b7795ca562
commit e64135c7a8
2 changed files with 22 additions and 13 deletions

View File

@ -269,6 +269,14 @@ def picksdict_from_picks(evt):
msg = str(e) + ',\n falling back to symmetric uncertainties' msg = str(e) + ',\n falling back to symmetric uncertainties'
lpp = mpp + spe lpp = mpp + spe
epp = mpp - spe epp = mpp - spe
warnings.warn(msg)
phase['mpp'] = mpp
phase['epp'] = epp
phase['lpp'] = lpp
phase['spe'] = spe
try:
phase['weight'] = weight
except:
# get onset weight from uncertainty # get onset weight from uncertainty
infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in') infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
print('Using default input file {}'.format(infile)) print('Using default input file {}'.format(infile))
@ -278,11 +286,6 @@ def picksdict_from_picks(evt):
elif pick.phase_hint == 'S': elif pick.phase_hint == 'S':
errors = parameter['timeerrorsS'] errors = parameter['timeerrorsS']
weight = get_quality_class(spe, errors) weight = get_quality_class(spe, errors)
warnings.warn(msg)
phase['mpp'] = mpp
phase['epp'] = epp
phase['lpp'] = lpp
phase['spe'] = spe
phase['weight'] = weight phase['weight'] = weight
phase['channel'] = channel phase['channel'] = channel
phase['network'] = network phase['network'] = network
@ -782,6 +785,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
Ponset = arrivals[key]['P']['mpp'] Ponset = arrivals[key]['P']['mpp']
Prt = Ponset - stime # onset time relative to source time Prt = Ponset - stime # onset time relative to source time
fid.write('%s %6.3f 1 P\n' % (key, Prt)) fid.write('%s %6.3f 1 P\n' % (key, Prt))
if arrivals[key].has_key('S'):
# S onsets # S onsets
if arrivals[key]['S']['weight'] < 4: if arrivals[key]['S']['weight'] < 4:
Sonset = arrivals[key]['S']['mpp'] Sonset = arrivals[key]['S']['mpp']

View File

@ -316,8 +316,13 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None, linecolor='k'):
islope2 = np.where((t >= Pick) & (t <= Pick + t[imax2])) islope2 = np.where((t >= Pick) & (t <= Pick + t[imax2]))
# calculate slope as polynomal fit of order 1 # calculate slope as polynomal fit of order 1
xslope2 = np.arange(0, len(xfilt[islope2]), 1) xslope2 = np.arange(0, len(xfilt[islope2]), 1)
try:
P2 = np.polyfit(xslope2, xfilt[islope2], 1) P2 = np.polyfit(xslope2, xfilt[islope2], 1)
datafit2 = np.polyval(P2, xslope2) datafit2 = np.polyval(P2, xslope2)
except ValueError as e:
emsg = 'fmpicker: polyfit failed: {}'.format(e)
print(emsg)
return FM
# compare results # compare results
if P1 is not None and P2 is not None: if P1 is not None and P2 is not None: