[add] remove automatic phases possible from pickDlg

This commit is contained in:
Marcel Paffrath 2017-08-09 15:10:36 +02:00
parent 5c6f1eb564
commit fd9e4f0c05

View File

@ -1733,16 +1733,20 @@ class PickDlg(QDialog):
ax.plot([mpp, mpp], ylims, colors[2], label='{}-Pick'.format(phase), picker=5) ax.plot([mpp, mpp], ylims, colors[2], label='{}-Pick'.format(phase), picker=5)
else: else:
ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase), picker=5) ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase), picker=5)
# append phase text (if textOnly: draw with current ylims)
self.phaseText.append(ax.text(mpp, ylims[1], phase))
elif picktype == 'auto':
if not textOnly:
ax.plot(mpp, ylims[1], colors[3],
mpp, ylims[0], colors[4])
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted',
picker=5, label='{}-Pick (auto)'.format(phase))
# append phase text (if textOnly: draw with current ylims) # append phase text (if textOnly: draw with current ylims)
self.phaseText.append(ax.text(mpp, ylims[1], phase)) self.phaseText.append(ax.text(mpp, ylims[1], phase))
elif picktype == 'auto':
ax.plot(mpp, ylims[1], colors[3],
mpp, ylims[0], colors[4])
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted')
else: else:
raise TypeError('Unknown picktype {0}'.format(picktype)) raise TypeError('Unknown picktype {0}'.format(picktype))
ax.legend() ax.legend(loc=1)
def connect_pick_delete(self): def connect_pick_delete(self):
self.cidpick = self.getPlotWidget().mpl_connect('pick_event', self.onpick_delete) self.cidpick = self.getPlotWidget().mpl_connect('pick_event', self.onpick_delete)
@ -1764,26 +1768,29 @@ class PickDlg(QDialog):
# init empty list and get station starttime # init empty list and get station starttime
X = [] X = []
starttime = self.getStartTime() starttime = self.getStartTime()
# init dictionarys to iterate through and iterate over them # init dictionaries to iterate through and iterate over them
allpicks = [self.picks, self.autopicks] allpicks = {'manual': self.picks,
for index_ptype, picks in enumerate(allpicks): 'auto': self.autopicks}
for picktype in allpicks.keys():
picks = allpicks[picktype]
for phase in picks: for phase in picks:
pick_rel = picks[phase]['mpp'] - starttime pick_rel = picks[phase]['mpp'] - starttime
# add relative pick time, phaseID and picktype index # add relative pick time, phaseID and picktype index
X.append((pick_rel, phase, index_ptype)) X.append((pick_rel, phase, picktype))
# find index and value closest to x # find index and value closest to x
index, value = min(enumerate([val[0] for val in X]), key=lambda y: abs(y[1] - x)) index, value = min(enumerate([val[0] for val in X]), key=lambda y: abs(y[1] - x))
# unpack the found value # unpack the found value
pick_rel, phase, index_ptype = X[index] pick_rel, phase, picktype = X[index]
# delete the value from corresponding dictionary # delete the value from corresponding dictionary
allpicks[index_ptype].pop(phase) allpicks[picktype].pop(phase)
# information output # information output
msg = 'Deleted pick for phase {}, {}[s] from starttime {}' msg = 'Deleted {} pick for phase {}, {}[s] from starttime {}'
print(msg.format(phase, pick_rel, starttime)) print(msg.format(picktype, phase, pick_rel, starttime))
self.setDirty(True) self.setDirty(True)
def drawPhaseText(self): def drawPhaseText(self):
return self.drawPicks(picktype='manual', textOnly=True) self.drawPicks(picktype='manual', textOnly=True)
self.drawPicks(picktype='auto', textOnly=True)
def removePhaseText(self): def removePhaseText(self):
for textItem in self.phaseText: for textItem in self.phaseText:
@ -1950,9 +1957,9 @@ class PickDlg(QDialog):
# print(pick, picks[pick]) # print(pick, picks[pick])
def discard(self): def discard(self):
picks = self._init_picks self.picks = self._init_picks
self.picks = picks self.autopicks = self._init_autopicks
self.update_picks.emit(picks) self.update_picks.emit(self.picks)
# for pick in picks: # for pick in picks:
# print(pick, picks[pick]) # print(pick, picks[pick])