[adresses 195] preparing GUI elements for a new dialog widget for interactive comparison
This commit is contained in:
parent
de89fc83ce
commit
536019259e
38
QtPyLoT.py
38
QtPyLoT.py
@ -53,7 +53,7 @@ from pylot.core.util.utils import fnConstructor, getLogin, \
|
||||
getGlobalTimes
|
||||
from pylot.core.io.location import create_creation_info, create_event
|
||||
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
||||
MPLWidget, PropertiesDlg, HelpForm, createAction, PickDlg, getDataType
|
||||
WaveformWidget, PropertiesDlg, HelpForm, createAction, PickDlg, getDataType
|
||||
from pylot.core.util.structure import DATASTRUCTURE
|
||||
from pylot.core.util.thread import AutoPickThread
|
||||
from pylot.core.util.version import get_git_version as _getVersionString
|
||||
@ -142,8 +142,8 @@ class MainWindow(QMainWindow):
|
||||
plottitle = "Overview: {0} components ".format(self.getComponent())
|
||||
|
||||
# create central matplotlib figure canvas widget
|
||||
self.DataPlot = MPLWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
self.DataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
self.DataPlot.mpl_connect('button_press_event',
|
||||
self.pickOnStation)
|
||||
self.DataPlot.mpl_connect('axes_enter_event',
|
||||
@ -178,6 +178,8 @@ class MainWindow(QMainWindow):
|
||||
auto_icon.addPixmap(QPixmap(':/icons/sync.png'))
|
||||
locate_icon = QIcon()
|
||||
locate_icon.addPixmap(QPixmap(':/icons/locate.png'))
|
||||
compare_icon = QIcon()
|
||||
compare_icon.addPixmap(QPixmap(':/icons/compare.png'))
|
||||
|
||||
newEventAction = self.createAction(self, "&New event ...",
|
||||
self.createNewEvent,
|
||||
@ -244,6 +246,12 @@ class MainWindow(QMainWindow):
|
||||
"Alt+S",
|
||||
s_icon,
|
||||
"Toggle S phase", True)
|
||||
self.compare_action = self.createAction(self, "&Compare picks...",
|
||||
self.comparePicks, "Alt+C",
|
||||
compare_icon, "Comparison of "
|
||||
"manual and "
|
||||
"automatic pick "
|
||||
"data.", False)
|
||||
printAction = self.createAction(self, "&Print event ...",
|
||||
self.printEvent, QKeySequence.Print,
|
||||
print_icon,
|
||||
@ -318,7 +326,7 @@ class MainWindow(QMainWindow):
|
||||
' displayed!')
|
||||
|
||||
autoPickToolBar = self.addToolBar("autoPyLoT")
|
||||
autoPickActions = (auto_pick,)
|
||||
autoPickActions = (auto_pick, self.compare_action)
|
||||
self.addActions(autoPickToolBar, autoPickActions)
|
||||
|
||||
# pickToolBar = self.addToolBar("PickTools")
|
||||
@ -568,6 +576,10 @@ class MainWindow(QMainWindow):
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def comparePicks(self):
|
||||
if self.check4Comparison():
|
||||
compare_dlg = ComparisonDialog(self)
|
||||
|
||||
def getPlotWidget(self):
|
||||
return self.DataPlot
|
||||
|
||||
@ -828,6 +840,7 @@ class MainWindow(QMainWindow):
|
||||
self.picks.update(picks)
|
||||
elif type == 'auto':
|
||||
self.autopicks.update(picks)
|
||||
self.check4Comparison()
|
||||
|
||||
def drawPicks(self, station=None, picktype='manual'):
|
||||
# if picks to draw not specified, draw all picks available
|
||||
@ -882,9 +895,22 @@ class MainWindow(QMainWindow):
|
||||
def check4Loc(self):
|
||||
return self.picksNum() > 4
|
||||
|
||||
def picksNum(self):
|
||||
def check4Comparison(self):
|
||||
mpicks = self.getPicks()
|
||||
apicks = self.getPicks('auto')
|
||||
for station, phases in mpicks.items():
|
||||
try:
|
||||
aphases = apicks[station]
|
||||
for phase in phases.keys():
|
||||
if phase in aphases.keys():
|
||||
return True
|
||||
except KeyError:
|
||||
continue
|
||||
return False
|
||||
|
||||
def picksNum(self, type='manual'):
|
||||
num = 0
|
||||
for phases in self.getPicks().values():
|
||||
for phases in self.getPicks(type).values():
|
||||
num += len(phases)
|
||||
return num
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
<file>icons/locate.png</file>
|
||||
<file>icons/printer.png</file>
|
||||
<file>icons/delete.png</file>
|
||||
<file>icons/compare.png</file>
|
||||
<file>icons/key_E.png</file>
|
||||
<file>icons/key_N.png</file>
|
||||
<file>icons/key_P.png</file>
|
||||
|
BIN
icons/compare.png
Normal file
BIN
icons/compare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
File diff suppressed because one or more lines are too long
@ -8,6 +8,7 @@
|
||||
EVENT_DATA/LOCAL #datapath# %data path
|
||||
2013.02_Insheim #database# %name of data base
|
||||
e0019.048.13 #eventID# %certain evnt ID for processing
|
||||
True #apverbose#
|
||||
PILOT #datastructure# %choose data structure
|
||||
0 #iplot# %flag for plotting: 0 none, 1, partly, >1 everything
|
||||
AUTOPHASES_AIC_HOS4_ARH #phasefile# %name of autoPILOT output phase file
|
||||
|
@ -29,7 +29,10 @@ class Comparison(object):
|
||||
names = list()
|
||||
self._pdfs = dict()
|
||||
for name, fn in kwargs.items():
|
||||
self._pdfs[name] = PDFDictionary.from_quakeml(fn)
|
||||
if not isinstance(PDFDictionary, fn):
|
||||
self._pdfs[name] = PDFDictionary.from_quakeml(fn)
|
||||
else:
|
||||
self._pdfs[name] = fn
|
||||
names.append(name)
|
||||
if len(names) > 2:
|
||||
raise ValueError('Comparison is only defined for two '
|
||||
@ -101,14 +104,19 @@ class Comparison(object):
|
||||
|
||||
return compare_pdfs
|
||||
|
||||
def plot(self):
|
||||
nstations = self.nstations
|
||||
stations = self.stations
|
||||
def plot(self, stations=None):
|
||||
if stations is None:
|
||||
nstations = self.nstations
|
||||
stations = self.stations
|
||||
else:
|
||||
nstations = len(stations)
|
||||
istations = range(nstations)
|
||||
fig, axarr = plt.subplots(nstations, 2, sharex='col', sharey='row')
|
||||
|
||||
for n in istations:
|
||||
station = stations[n]
|
||||
if station not in self.comparison.keys():
|
||||
continue
|
||||
compare_pdf = self.comparison[station]
|
||||
for l, phase in enumerate(compare_pdf.keys()):
|
||||
axarr[n, l].plot(compare_pdf[phase].axis,
|
||||
|
@ -64,8 +64,86 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
class ComparsionDialog(QDialog):
|
||||
def __init__(self, c, parent=None):
|
||||
self._data = c
|
||||
self._stats = c.keys()
|
||||
self._canvas = PlotWidget(parent)
|
||||
super(ComparsionDialog, self).__init__(parent)
|
||||
self
|
||||
|
||||
class MPLWidget(FigureCanvas):
|
||||
def setupUI(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def canvas(self):
|
||||
return self._canvas
|
||||
|
||||
@property
|
||||
def stations(self):
|
||||
return self._stats
|
||||
|
||||
@stations.setter
|
||||
def stations(self, stations):
|
||||
self._stats = stations
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
|
||||
@data.setter
|
||||
def data(self, data):
|
||||
self.stations = data.keys()
|
||||
self._data = data
|
||||
|
||||
|
||||
class PlotWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
self._parent = parent
|
||||
self._fig = Figure()
|
||||
self._xl = xlabel
|
||||
self._yl = ylabel
|
||||
self._title = title
|
||||
super(PlotWidget, self).__init__(self.figure)
|
||||
|
||||
@property
|
||||
def figure(self):
|
||||
return self._fig
|
||||
|
||||
@figure.setter
|
||||
def figure(self, fig):
|
||||
self._fig = fig
|
||||
|
||||
@property
|
||||
def xlabel(self):
|
||||
return self._xl
|
||||
|
||||
@xlabel.setter
|
||||
def xlabel(self, label):
|
||||
self._xl = label
|
||||
|
||||
@property
|
||||
def ylabel(self):
|
||||
return self._yl
|
||||
|
||||
@ylabel.setter
|
||||
def ylabel(self, label):
|
||||
self._yl = label
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, title):
|
||||
self._title = title
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self._parent
|
||||
|
||||
|
||||
class WaveformWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
|
||||
self._parent = None
|
||||
@ -79,7 +157,7 @@ class MPLWidget(FigureCanvas):
|
||||
# clear axes each time plot is called
|
||||
self.axes.hold(True)
|
||||
# initialize super class
|
||||
super(MPLWidget, self).__init__(self.figure)
|
||||
super(WaveformWidget, self).__init__(self.figure)
|
||||
# add an cursor for station selection
|
||||
self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,),
|
||||
horizOn=True,
|
||||
@ -223,7 +301,7 @@ class PickDlg(QDialog):
|
||||
self.stime, self.etime = getGlobalTimes(self.getWFData())
|
||||
|
||||
# initialize plotting widget
|
||||
self.multicompfig = MPLWidget(self)
|
||||
self.multicompfig = WaveformWidget(self)
|
||||
|
||||
# setup ui
|
||||
self.setupUi()
|
||||
|
Loading…
Reference in New Issue
Block a user