[add] new colors appl. to matplot, added quality

This commit is contained in:
Marcel Paffrath 2017-08-14 16:59:39 +02:00
parent 37373864ce
commit 0f61799024
3 changed files with 73 additions and 28 deletions

View File

@ -73,7 +73,7 @@ from pylot.core.util.errors import FormatError, DatastructureError, \
from pylot.core.util.connection import checkurl
from pylot.core.util.dataprocessing import read_metadata, restitute_data
from pylot.core.util.utils import fnConstructor, getLogin, \
full_range, readFilterInformation, trim_station_components, check4gaps, make_pen
full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, pick_linestyle_plt
from pylot.core.util.event import Event
from pylot.core.io.location import create_creation_info, create_event
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
@ -2013,20 +2013,29 @@ class MainWindow(QMainWindow):
raise TypeError('Unknown picktype {0}'.format(picktype))
else:
if picktype == 'manual':
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
color = pick_color_plt(picktype, phase, quality)
if picks['epp'] and picks['lpp']:
ax.fill_between([epp, lpp], ylims[0], ylims[1],
alpha=.25, color=colors[0], label='EPP, LPP')
alpha=.25, color=color, label='EPP, LPP')
if spe:
ax.plot([mpp - spe, mpp - spe], ylims, colors[1], label='{}-SPE'.format(phase))
ax.plot([mpp + spe, mpp + spe], ylims, colors[1])
ax.plot([mpp, mpp], ylims, colors[2], label='{}-Pick'.format(phase))
linestyle_spe, width_spe = pick_linestyle_plt(picktype, 'spe')
ax.plot([mpp - spe, mpp - spe], ylims, color=color, linestyle=linestyle_spe,
linewidth=width_spe, label='{}-SPE'.format(phase))
ax.plot([mpp + spe, mpp + spe], ylims, color=color, linestyle=linestyle_spe,
linewidth=width_spe)
ax.plot([mpp, mpp], ylims, color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
label='{}-Pick (quality: {})'.format(phase, quality), picker=5)
else:
ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase))
ax.plot([mpp, mpp], ylims, color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
label='{}-Pick (NO PICKERROR)'.format(phase), picker=5)
elif picktype == 'auto':
if quality < 4:
ax.plot(mpp, ylims[1], colors[3],
mpp, ylims[0], colors[4])
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted')
color = pick_color_plt(picktype, phase, quality)
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
ax.plot(mpp, ylims[1], color=color, marker='v')
ax.plot(mpp, ylims[0], color=color, marker='^')
ax.vlines(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
picker=5, label='{}-Autopick (quality: {})'.format(phase, quality))
else:
raise TypeError('Unknown picktype {0}'.format(picktype))

View File

@ -466,7 +466,7 @@ def find_horizontals(data):
def make_pen(picktype, phase, key, quality):
if pg:
rgba = pick_color(picktype, phase, quality)
linestyle, width = pick_linestyle(picktype, key)
linestyle, width = pick_linestyle_pg(picktype, key)
pen = pg.mkPen(rgba, width=width, style=linestyle)
return pen
@ -481,15 +481,36 @@ def pick_color(picktype, phase, quality=0):
return rgba
def pick_linestyle(picktype, key):
linestyles_manu = {'mpp': (QtCore.Qt.SolidLine, 3.),
def pick_color_plt(picktype, phase, quality=0):
rgba = list(pick_color(picktype, phase, quality))
for index, val in enumerate(rgba):
rgba[index] /= 255.
return rgba
def pick_linestyle_plt(picktype, key):
linestyles_manu = {'mpp': ('solid', 2.),
'epp': ('dashed', 1.),
'lpp': ('dashed', 1.),
'spe': ('dashed', 1.)}
linestyles_auto = {'mpp': ('dotted', 2.),
'epp': ('dashdot', 1.),
'lpp': ('dashdot', 1.),
'spe': ('dashdot', 1.)}
linestyles = {'manual': linestyles_manu,
'auto': linestyles_auto}
return linestyles[picktype][key]
def pick_linestyle_pg(picktype, key):
linestyles_manu = {'mpp': (QtCore.Qt.SolidLine, 2.),
'epp': (QtCore.Qt.DashLine, 1.),
'lpp': (QtCore.Qt.DashLine, 1.),
'spe': (QtCore.Qt.DashLine, 1.)}
linestyles_auto = {'mpp': (QtCore.Qt.DotLine, 3.),
'epp': (QtCore.Qt.DashDotDotLine, 1.),
'lpp': (QtCore.Qt.DashDotDotLine, 1.),
'spe': (QtCore.Qt.DashDotDotLine, 1.)}
linestyles_auto = {'mpp': (QtCore.Qt.DotLine, 2.),
'epp': (QtCore.Qt.DashDotLine, 1.),
'lpp': (QtCore.Qt.DashDotLine, 1.),
'spe': (QtCore.Qt.DashDotLine, 1.)}
linestyles = {'manual': linestyles_manu,
'auto': linestyles_auto}
return linestyles[picktype][key]

View File

@ -44,12 +44,12 @@ from obspy.taup.utils import get_phase_names
from pylot.core.io.data import Data
from pylot.core.io.inputs import FilterOptions, PylotParameter
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
getResolutionWindow
getResolutionWindow, getQualityfromUncertainty
from pylot.core.pick.compare import Comparison
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, \
SetChannelComponents
from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \
demeanTrace, isSorted, findComboBoxIndex, clims
demeanTrace, isSorted, findComboBoxIndex, clims, pick_linestyle_plt, pick_color_plt
from autoPyLoT import autoPyLoT
from pylot.core.util.thread import Thread
@ -1716,6 +1716,12 @@ class PickDlg(QDialog):
else:
return
# get quality classes
if phase[0] == 'P':
quality = getQualityfromUncertainty(picks['spe'], self.parameter['timeerrorsP'])
elif phase[0] == 'S':
quality = getQualityfromUncertainty(picks['spe'], self.parameter['timeerrorsS'])
mpp = picks['mpp'] - self.getStartTime()
if picks['epp'] and picks['lpp'] and not textOnly:
epp = picks['epp'] - self.getStartTime()
@ -1724,23 +1730,32 @@ class PickDlg(QDialog):
if picktype == 'manual':
if not textOnly:
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
color = pick_color_plt(picktype, phase, quality)
if picks['epp'] and picks['lpp']:
ax.fill_between([epp, lpp], ylims[0], ylims[1],
alpha=.25, color=colors[0], label='EPP, LPP')
alpha=.25, color=color, label='EPP, LPP')
if spe:
ax.plot([mpp - spe, mpp - spe], ylims, colors[1], label='{}-SPE'.format(phase))
ax.plot([mpp + spe, mpp + spe], ylims, colors[1])
ax.plot([mpp, mpp], ylims, colors[2], label='{}-Pick'.format(phase), picker=5)
linestyle_spe, width_spe = pick_linestyle_plt(picktype, 'spe')
ax.plot([mpp - spe, mpp - spe], ylims, color=color, linestyle=linestyle_spe,
linewidth=width_spe, label='{}-SPE'.format(phase))
ax.plot([mpp + spe, mpp + spe], ylims, color=color, linestyle=linestyle_spe,
linewidth=width_spe)
ax.plot([mpp, mpp], ylims, color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
label='{}-Pick (quality: {})'.format(phase, quality), picker=5)
else:
ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase), picker=5)
ax.plot([mpp, mpp], ylims, color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
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':
color = pick_color_plt(picktype, phase, quality)
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
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))
ax.plot(mpp, ylims[1], color=color, marker='v')
ax.plot(mpp, ylims[0], color=color, marker='^')
ax.vlines(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
picker=5, label='{}-Autopick (quality: {})'.format(phase, quality))
# append phase text (if textOnly: draw with current ylims)
self.phaseText.append(ax.text(mpp, ylims[1], phase))
else: