[Bugfix] Export of picks did not work because dictionary key pickmethod
was not taken into account.
This commit is contained in:
parent
7f9d240d02
commit
15cad42868
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import pdb
|
||||||
import glob
|
import glob
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -252,8 +252,7 @@ def picksdict_from_picks(evt):
|
|||||||
if pick_method == 'None':
|
if pick_method == 'None':
|
||||||
pick_method = 'manual'
|
pick_method = 'manual'
|
||||||
try:
|
try:
|
||||||
#onsets = picksdict[picker][station]
|
onsets = picksdict[pick_method][station]
|
||||||
onsets = picksdict[station]
|
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
# print(e)
|
# print(e)
|
||||||
onsets = {}
|
onsets = {}
|
||||||
@ -764,30 +763,38 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
||||||
evt.picks = arrivals
|
evt.picks = arrivals
|
||||||
arrivals = picksdict_from_picks(evt)
|
arrivals = picksdict_from_picks(evt)
|
||||||
for key in arrivals:
|
# check for automatic and manual picks
|
||||||
|
# prefer manual picks
|
||||||
|
if arrivals['auto'] and arrivals['manual']:
|
||||||
|
usedarrivals = arrivals['manual']
|
||||||
|
elif arrivals['auto']:
|
||||||
|
usedarrivals = arrivals['auto']
|
||||||
|
elif arrivals['manual']:
|
||||||
|
usedarrivals = arrivals['manual']
|
||||||
|
for key in usedarrivals:
|
||||||
# P onsets
|
# P onsets
|
||||||
if arrivals[key].has_key('P'):
|
if usedarrivals[key].has_key('P'):
|
||||||
if arrivals[key]['P']['weight'] < 4:
|
if usedarrivals[key]['P']['weight'] < 4:
|
||||||
n += 1
|
n += 1
|
||||||
stat = key
|
stat = key
|
||||||
if len(stat) > 4: # VELEST handles only 4-string station IDs
|
if len(stat) > 4: # VELEST handles only 4-string station IDs
|
||||||
stat = stat[1:5]
|
stat = stat[1:5]
|
||||||
Ponset = arrivals[key]['P']['mpp']
|
Ponset = usedarrivals[key]['P']['mpp']
|
||||||
Pweight = arrivals[key]['P']['weight']
|
Pweight = usedarrivals[key]['P']['weight']
|
||||||
Prt = Ponset - stime # onset time relative to source time
|
Prt = Ponset - stime # onset time relative to source time
|
||||||
if n % 6 is not 0:
|
if n % 6 is not 0:
|
||||||
fid.write('%-4sP%d%6.2f' % (stat, Pweight, Prt))
|
fid.write('%-4sP%d%6.2f' % (stat, Pweight, Prt))
|
||||||
else:
|
else:
|
||||||
fid.write('%-4sP%d%6.2f\n' % (stat, Pweight, Prt))
|
fid.write('%-4sP%d%6.2f\n' % (stat, Pweight, Prt))
|
||||||
# S onsets
|
# S onsets
|
||||||
if arrivals[key].has_key('S'):
|
if usedarrivals[key].has_key('S'):
|
||||||
if arrivals[key]['S']['weight'] < 4:
|
if usedarrivals[key]['S']['weight'] < 4:
|
||||||
n += 1
|
n += 1
|
||||||
stat = key
|
stat = key
|
||||||
if len(stat) > 4: # VELEST handles only 4-string station IDs
|
if len(stat) > 4: # VELEST handles only 4-string station IDs
|
||||||
stat = stat[1:5]
|
stat = stat[1:5]
|
||||||
Sonset = arrivals[key]['S']['mpp']
|
Sonset = usedarrivals[key]['S']['mpp']
|
||||||
Sweight = arrivals[key]['S']['weight']
|
Sweight = usedarrivals[key]['S']['weight']
|
||||||
Srt = Ponset - stime # onset time relative to source time
|
Srt = Ponset - stime # onset time relative to source time
|
||||||
if n % 6 is not 0:
|
if n % 6 is not 0:
|
||||||
fid.write('%-4sS%d%6.2f' % (stat, Sweight, Srt))
|
fid.write('%-4sS%d%6.2f' % (stat, Sweight, Srt))
|
||||||
@ -818,17 +825,25 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
||||||
evt.picks = arrivals
|
evt.picks = arrivals
|
||||||
arrivals = picksdict_from_picks(evt)
|
arrivals = picksdict_from_picks(evt)
|
||||||
for key in arrivals:
|
# check for automatic and manual picks
|
||||||
if arrivals[key].has_key('P'):
|
# prefer manual picks
|
||||||
|
if arrivals['auto'] and arrivals['manual']:
|
||||||
|
usedarrivals = arrivals['manual']
|
||||||
|
elif arrivals['auto']:
|
||||||
|
usedarrivals = arrivals['auto']
|
||||||
|
elif arrivals['manual']:
|
||||||
|
usedarrivals = arrivals['manual']
|
||||||
|
for key in usedarrivals:
|
||||||
|
if usedarrivals[key].has_key('P'):
|
||||||
# P onsets
|
# P onsets
|
||||||
if arrivals[key]['P']['weight'] < 4:
|
if usedarrivals[key]['P']['weight'] < 4:
|
||||||
Ponset = arrivals[key]['P']['mpp']
|
Ponset = usedarrivals[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'):
|
if usedarrivals[key].has_key('S'):
|
||||||
# S onsets
|
# S onsets
|
||||||
if arrivals[key]['S']['weight'] < 4:
|
if usedarrivals[key]['S']['weight'] < 4:
|
||||||
Sonset = arrivals[key]['S']['mpp']
|
Sonset = usedarrivals[key]['S']['mpp']
|
||||||
Srt = Sonset - stime # onset time relative to source time
|
Srt = Sonset - stime # onset time relative to source time
|
||||||
fid.write('%-5s %6.3f 1 S\n' % (key, Srt))
|
fid.write('%-5s %6.3f 1 S\n' % (key, Srt))
|
||||||
|
|
||||||
@ -866,9 +881,17 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
evt = ope.Event(resource_id=eventinfo['resource_id'])
|
||||||
evt.picks = arrivals
|
evt.picks = arrivals
|
||||||
arrivals = picksdict_from_picks(evt)
|
arrivals = picksdict_from_picks(evt)
|
||||||
for key in arrivals:
|
# check for automatic and manual picks
|
||||||
if arrivals[key].has_key('P'):
|
# prefer manual picks
|
||||||
if arrivals[key]['P']['weight'] < 4 and arrivals[key]['P']['fm'] is not None:
|
if arrivals['auto'] and arrivals['manual']:
|
||||||
|
usedarrivals = arrivals['manual']
|
||||||
|
elif arrivals['auto']:
|
||||||
|
usedarrivals = arrivals['auto']
|
||||||
|
elif arrivals['manual']:
|
||||||
|
usedarrivals = arrivals['manual']
|
||||||
|
for key in usedarrivals:
|
||||||
|
if usedarrivals[key].has_key('P'):
|
||||||
|
if usedarrivals[key]['P']['weight'] < 4 and usedarrivals[key]['P']['fm'] is not None:
|
||||||
stat = key
|
stat = key
|
||||||
for i in range(len(picks)):
|
for i in range(len(picks)):
|
||||||
station = picks[i].waveform_id.station_code
|
station = picks[i].waveform_id.station_code
|
||||||
@ -887,7 +910,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
fid.write('%-4s %6.2f %6.2f%s \n' % (stat,
|
fid.write('%-4s %6.2f %6.2f%s \n' % (stat,
|
||||||
az,
|
az,
|
||||||
inz,
|
inz,
|
||||||
arrivals[key]['P']['fm']))
|
usedarrivals[key]['P']['fm']))
|
||||||
break
|
break
|
||||||
|
|
||||||
fid.close()
|
fid.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user