[update] plotting (added fill_between again now performance got increased)

This commit is contained in:
Marcel Paffrath 2018-07-16 17:56:17 +02:00
parent 469d91bfdc
commit 5b48b744fd
2 changed files with 54 additions and 70 deletions

View File

@ -1266,7 +1266,7 @@ class MainWindow(QMainWindow):
for phasename, pick in picks.items(): for phasename, pick in picks.items():
if not type(pick) in [dict, AttribDict]: if not type(pick) in [dict, AttribDict]:
continue continue
if getQualityFromUncertainty(pick.get('spe'), phaseErrors[self.getPhaseID(phasename)]) < 4: if pick.get('spe'):
ma_count[ma] += 1 ma_count[ma] += 1
ma_count_total[ma] += 1 ma_count_total[ma] += 1
@ -2697,11 +2697,9 @@ class MainWindow(QMainWindow):
lpp = None lpp = None
spe = picks['spe'] spe = picks['spe']
if not spe and epp and lpp:
spe = symmetrize_error(mpp - epp, lpp - mpp)
if self.pg: if self.pg:
if picktype == 'manual': if picktype == 'manual' or picktype == 'auto':
if spe:
if picks['epp'] and picks['lpp']: if picks['epp'] and picks['lpp']:
pen = make_pen(picktype, phaseID, 'epp', quality) pen = make_pen(picktype, phaseID, 'epp', quality)
pw.plot([epp, epp], ylims, pw.plot([epp, epp], ylims,
@ -2709,30 +2707,21 @@ class MainWindow(QMainWindow):
pen = make_pen(picktype, phaseID, 'lpp', quality) pen = make_pen(picktype, phaseID, 'lpp', quality)
pw.plot([lpp, lpp], ylims, pw.plot([lpp, lpp], ylims,
alpha=.25, pen=pen, name='LPP') alpha=.25, pen=pen, name='LPP')
pen = make_pen(picktype, phaseID, 'spe', quality)
spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=pen,
name='{}-SPE'.format(phase))
spe_r = pg.PlotDataItem([mpp + spe, mpp + spe], ylims, pen=pen)
try:
color = pen.color()
color.setAlpha(100.)
brush = pen.brush()
brush.setColor(color)
fill = pg.FillBetweenItem(spe_l, spe_r, brush=brush)
fb = pw.addItem(fill)
except:
print('Warning: drawPicks: Could not create fill for symmetric pick error.')
pen = make_pen(picktype, phaseID, 'mpp', quality) pen = make_pen(picktype, phaseID, 'mpp', quality)
if spe:
# pen = make_pen(picktype, phaseID, 'spe', quality)
# spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=pen,
# name='{}-SPE'.format(phase))
# spe_r = pg.PlotDataItem([mpp + spe, mpp + spe], ylims, pen=pen)
# pw.addItem(spe_l)
# pw.addItem(spe_r)
# try:
# color = pen.color()
# color.setAlpha(100.)
# brush = pen.brush()
# brush.setColor(color)
# fill = pg.FillBetweenItem(spe_l, spe_r, brush=brush)
# fb = pw.addItem(fill)
# except:
# print('Warning: drawPicks: Could not create fill for symmetric pick error.')
pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick'.format(phase)) pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick'.format(phase))
else:
pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick (NO PICKERROR)'.format(phase))
elif picktype == 'auto':
if quality < 4:
pen = make_pen(picktype, phaseID, 'mpp', quality)
pw.plot([mpp, mpp], ylims, pen=pen)
else: else:
raise TypeError('Unknown picktype {0}'.format(picktype)) raise TypeError('Unknown picktype {0}'.format(picktype))
else: else:
@ -2998,7 +2987,7 @@ class MainWindow(QMainWindow):
for phasename, pick in picks.items(): for phasename, pick in picks.items():
if not type(pick) in [dict, AttribDict]: if not type(pick) in [dict, AttribDict]:
continue continue
if getQualityFromUncertainty(pick.get('spe'), phaseErrors[self.getPhaseID(phasename)]) < 4: if pick.get('spe'):
ma_count[ma] += 1 ma_count[ma] += 1
ma_count_total[ma] += 1 ma_count_total[ma] += 1

View File

@ -2359,43 +2359,38 @@ class PickDlg(QDialog):
lpp = picks['lpp'] - self.getStartTime() lpp = picks['lpp'] - self.getStartTime()
spe = picks['spe'] spe = picks['spe']
if not picktype in ['auto', 'manual']:
raise TypeError('Unknown picktype {0}'.format(picktype))
if picktype == 'manual': if picktype == 'manual':
baseorder = 5
elif picktype == 'auto':
baseorder = 0
color = pick_color_plt(picktype, phaseID, quality) color = pick_color_plt(picktype, phaseID, quality)
if not textOnly: if not textOnly:
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp') linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
vl = ax.axvline(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp, vl = ax.axvline(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
label='{}-Pick (quality: {})'.format(phase, quality), picker=5) label='{}-{}-Pick (quality: {})'.format(phase, picktype, quality), picker=5,
self.phaseLines[phase] = vl zorder=baseorder+9)
phaseLineKey = '{}-{}'.format(phase, picktype)
self.phaseLines[phaseLineKey] = vl
if spe: if spe:
ax.fill_between([mpp - spe, mpp + spe], ylims[0], ylims[1], ax.fill_between([mpp - spe, mpp + spe], ylims[0], ylims[1],
alpha=.25, color=color, label='{}-SPE'.format(phase)) alpha=.25, color=color, label='{}-{}-SPE'.format(phase, picktype), zorder=baseorder+1)
if picks['epp']: if picks['epp']:
linestyle_epp, width_epp = pick_linestyle_plt(picktype, 'epp') linestyle_epp, width_epp = pick_linestyle_plt(picktype, 'epp')
ax.axvline(epp, ylims[0], ylims[1], color=color, linestyle=linestyle_epp, ax.axvline(epp, ylims[0], ylims[1], color=color, linestyle=linestyle_epp,
linewidth=width_epp, label='{}-EPP'.format(phase)) linewidth=width_epp, label='{}-{}-EPP'.format(phase, picktype), zorder=baseorder+2)
if picks['lpp']: if picks['lpp']:
linestyle_lpp, width_lpp = pick_linestyle_plt(picktype, 'lpp') linestyle_lpp, width_lpp = pick_linestyle_plt(picktype, 'lpp')
ax.axvline(lpp, ylims[0], ylims[1], color=color, linestyle=linestyle_lpp, ax.axvline(lpp, ylims[0], ylims[1], color=color, linestyle=linestyle_lpp,
linewidth=width_lpp, label='{}-LPP'.format(phase)) linewidth=width_lpp, label='{}-{}-LPP'.format(phase, picktype), zorder=baseorder+2)
# else: if picktype == 'auto':
# ax.plot([mpp, mpp], ylims, color=color, linestyle=linestyle_mpp, linewidth=width_mpp, ax.plot(mpp, ylims[1], color=color, marker='v', zorder=baseorder+3)
# label='{}-Pick (NO PICKERROR)'.format(phase), picker=5) ax.plot(mpp, ylims[0], color=color, marker='^', zorder=baseorder+3)
# 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, color=color)) self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color, zorder=baseorder+10))
elif picktype == 'auto':
color = pick_color_plt(picktype, phaseID, quality)
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
if not textOnly:
ax.plot(mpp, ylims[1], color=color, marker='v')
ax.plot(mpp, ylims[0], color=color, marker='^')
vl = ax.axvline(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
picker=5, label='{}-Autopick (quality: {})'.format(phase, quality))
self.phaseLines[phase] = vl
# append phase text (if textOnly: draw with current ylims)
self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color))
else:
raise TypeError('Unknown picktype {0}'.format(picktype))
ax.legend(loc=1) ax.legend(loc=1)
def connect_mouse_motion(self): def connect_mouse_motion(self):