Adding Bugfix from port-to-py3 port for incorrect picksdict to develop branch
This commit is contained in:
parent
30eb8fbbbd
commit
7f9d240d02
5
PyLoT.py
5
PyLoT.py
@ -2866,10 +2866,7 @@ class MainWindow(QMainWindow):
|
||||
event.pylot_autopicks = {}
|
||||
picksdict = picksdict_from_picks(evt=self.get_data().get_evt_data())
|
||||
event.addPicks(picksdict['manual'])
|
||||
if picksdict['auto'] == {}:
|
||||
event.addAutopicks(picksdict)
|
||||
else:
|
||||
event.addAutopicks(picksdict['auto'])
|
||||
event.addAutopicks(picksdict['auto'])
|
||||
|
||||
|
||||
def drawPicks(self, station=None, picktype=None, stime=None):
|
||||
|
@ -220,7 +220,7 @@ class Data(object):
|
||||
|
||||
def replacePicks(self, event, picktype):
|
||||
"""
|
||||
Replace own picks with the one in event
|
||||
Replace picks in event with own picks
|
||||
:param event: Event that supplies information for comparison
|
||||
:type event: pylot.core.util.event.Event
|
||||
:param picktype: 'auto' or 'manual' picks
|
||||
@ -228,20 +228,23 @@ class Data(object):
|
||||
:return:
|
||||
:rtype: None
|
||||
"""
|
||||
checkflag = 0
|
||||
checkflag = 1
|
||||
picks = event.picks
|
||||
# remove existing picks
|
||||
for j, pick in reversed(list(enumerate(picks))):
|
||||
try:
|
||||
if picktype in str(pick.method_id.id):
|
||||
picks.pop(j)
|
||||
checkflag = 1
|
||||
checkflag = 2
|
||||
except AttributeError as e:
|
||||
msg = '{}'.format(e)
|
||||
print(e)
|
||||
checkflag = 0
|
||||
if checkflag:
|
||||
print("Found %s pick(s), remove them and append new picks to catalog." % picktype)
|
||||
if checkflag > 0:
|
||||
if checkflag == 1:
|
||||
print("Write new %s picks to catalog." % picktype)
|
||||
if checkflag == 2:
|
||||
print("Found %s pick(s), remove them and append new picks to catalog." % picktype)
|
||||
|
||||
# append new picks
|
||||
for pick in self.get_evt_data().picks:
|
||||
@ -269,8 +272,11 @@ class Data(object):
|
||||
raise FormatError(errmsg)
|
||||
|
||||
if hasattr(self.get_evt_data(), 'notes'):
|
||||
with open(os.path.join(os.path.dirname(fnout), 'notes.txt'), 'w') as notes_file:
|
||||
notes_file.write(self.get_evt_data().notes)
|
||||
try:
|
||||
with open(os.path.join(os.path.dirname(fnout), 'notes.txt'), 'w') as notes_file:
|
||||
notes_file.write(self.get_evt_data().notes)
|
||||
except Exception as e:
|
||||
print('Warning: Could not save notes.txt: ', str(e))
|
||||
|
||||
# check for already existing xml-file
|
||||
if fnext == '.xml':
|
||||
@ -537,7 +543,7 @@ class Data(object):
|
||||
def setEvtData(self, event):
|
||||
self.evtdata = event
|
||||
|
||||
def applyEVTData(self, data, typ='pick', authority_id='rub'):
|
||||
def applyEVTData(self, data, typ='pick'):
|
||||
"""
|
||||
Either takes an `obspy.core.event.Event` object and applies all new
|
||||
information on the event to the actual data if typ is 'event or
|
||||
|
@ -244,13 +244,13 @@ def picksdict_from_picks(evt):
|
||||
else:
|
||||
filter_id = None
|
||||
try:
|
||||
picker = str(pick.method_id)
|
||||
if picker.startswith('smi:local/'):
|
||||
picker = picker.split('smi:local/')[1]
|
||||
pick_method = str(pick.method_id)
|
||||
if pick_method.startswith('smi:local/'):
|
||||
pick_method = pick_method.split('smi:local/')[1]
|
||||
except IndexError:
|
||||
picker = 'manual' # MP MP TODO maybe improve statement
|
||||
if picker == 'None':
|
||||
picker = 'manual'
|
||||
pick_method = 'manual' # MP MP TODO maybe improve statement
|
||||
if pick_method == 'None':
|
||||
pick_method = 'manual'
|
||||
try:
|
||||
#onsets = picksdict[picker][station]
|
||||
onsets = picksdict[station]
|
||||
@ -289,7 +289,7 @@ def picksdict_from_picks(evt):
|
||||
phase['weight'] = weight
|
||||
phase['channel'] = channel
|
||||
phase['network'] = network
|
||||
phase['picker'] = picker
|
||||
phase['picker'] = pick_method
|
||||
try:
|
||||
if pick.polarity == 'positive':
|
||||
phase['fm'] = 'U'
|
||||
@ -303,7 +303,7 @@ def picksdict_from_picks(evt):
|
||||
phase['filter_id'] = filter_id if filter_id is not None else ''
|
||||
|
||||
onsets[pick.phase_hint] = phase.copy()
|
||||
picksdict[station] = onsets.copy()
|
||||
picksdict[pick_method][station] = onsets.copy()
|
||||
return picksdict
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user