some pick plotting issues solved; replotting main window if picks have been changed, otherwise just plot additional/deleted picks
This commit is contained in:
parent
33164d4d1f
commit
3dc9bb3d06
25
QtPyLoT.py
25
QtPyLoT.py
@ -386,8 +386,8 @@ class MainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
raise DatastructureError('not specified')
|
raise DatastructureError('not specified')
|
||||||
return self.fnames
|
return self.fnames
|
||||||
except DatastructureError, e:
|
except DatastructureError as e:
|
||||||
print e
|
print(e)
|
||||||
props = PropertiesDlg(self)
|
props = PropertiesDlg(self)
|
||||||
if props.exec_() == QDialog.Accepted:
|
if props.exec_() == QDialog.Accepted:
|
||||||
return self.getWFFnames()
|
return self.getWFFnames()
|
||||||
@ -410,7 +410,7 @@ class MainWindow(QMainWindow):
|
|||||||
def saveData(self):
|
def saveData(self):
|
||||||
|
|
||||||
def getSavePath(e):
|
def getSavePath(e):
|
||||||
print 'warning: {0}'.format(e)
|
print('warning: {0}'.format(e))
|
||||||
directory = os.path.join(self.getRoot(), self.getEventFileName())
|
directory = os.path.join(self.getRoot(), self.getEventFileName())
|
||||||
file_filter = "QuakeML file (*.xml);;VELEST observation file format (*.cnv);;NonLinLoc observation file (*.obs)"
|
file_filter = "QuakeML file (*.xml);;VELEST observation file format (*.cnv);;NonLinLoc observation file (*.obs)"
|
||||||
fname = QFileDialog.getSaveFileName(self, 'Save event data ...',
|
fname = QFileDialog.getSaveFileName(self, 'Save event data ...',
|
||||||
@ -513,7 +513,7 @@ class MainWindow(QMainWindow):
|
|||||||
def plotWaveformData(self):
|
def plotWaveformData(self):
|
||||||
zne_text = {'Z': 'vertical', 'N': 'north-south', 'E': 'east-west'}
|
zne_text = {'Z': 'vertical', 'N': 'north-south', 'E': 'east-west'}
|
||||||
comp = self.getComponent()
|
comp = self.getComponent()
|
||||||
title = 'overview: {0} components'.format(zne_text[comp])
|
title = 'section: {0} components'.format(zne_text[comp])
|
||||||
wfst = self.getData().getWFData().select(component=comp)
|
wfst = self.getData().getWFData().select(component=comp)
|
||||||
self.getPlotWidget().plotWFData(wfdata=wfst, title=title)
|
self.getPlotWidget().plotWFData(wfdata=wfst, title=title)
|
||||||
self.draw()
|
self.draw()
|
||||||
@ -574,8 +574,8 @@ class MainWindow(QMainWindow):
|
|||||||
def getFilterOptions(self):
|
def getFilterOptions(self):
|
||||||
try:
|
try:
|
||||||
return self.filteroptions[self.getSeismicPhase()]
|
return self.filteroptions[self.getSeismicPhase()]
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
print e
|
print(e)
|
||||||
return FilterOptions(None, None, None)
|
return FilterOptions(None, None, None)
|
||||||
|
|
||||||
def getFilters(self):
|
def getFilters(self):
|
||||||
@ -592,12 +592,12 @@ class MainWindow(QMainWindow):
|
|||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
if settings.value("filterdefaults",
|
if settings.value("filterdefaults",
|
||||||
None) is None and not self.getFilters():
|
None) is None and not self.getFilters():
|
||||||
for key, value in FILTERDEFAULTS.iteritems():
|
for key, value in FILTERDEFAULTS.items():
|
||||||
self.setFilterOptions(FilterOptions(**value), key)
|
self.setFilterOptions(FilterOptions(**value), key)
|
||||||
elif settings.value("filterdefaults", None) is not None:
|
elif settings.value("filterdefaults", None) is not None:
|
||||||
for key, value in settings.value("filterdefaults"):
|
for key, value in settings.value("filterdefaults"):
|
||||||
self.setFilterOptions(FilterOptions(**value), key)
|
self.setFilterOptions(FilterOptions(**value), key)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.updateStatus('Error ...')
|
self.updateStatus('Error ...')
|
||||||
emsg = QErrorMessage(self)
|
emsg = QErrorMessage(self)
|
||||||
emsg.showMessage('Error: {0}'.format(e))
|
emsg.showMessage('Error: {0}'.format(e))
|
||||||
@ -636,7 +636,11 @@ class MainWindow(QMainWindow):
|
|||||||
if pickDlg.exec_():
|
if pickDlg.exec_():
|
||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
self.updateStatus('picks accepted ({0})'.format(station))
|
self.updateStatus('picks accepted ({0})'.format(station))
|
||||||
self.addPicks(station, pickDlg.getPicks())
|
replot = self.addPicks(station, pickDlg.getPicks())
|
||||||
|
if replot:
|
||||||
|
self.plotWaveformData()
|
||||||
|
self.drawPicks()
|
||||||
|
else:
|
||||||
self.drawPicks(station)
|
self.drawPicks(station)
|
||||||
else:
|
else:
|
||||||
self.updateStatus('picks discarded ({0})'.format(station))
|
self.updateStatus('picks discarded ({0})'.format(station))
|
||||||
@ -667,6 +671,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def addPicks(self, station, picks):
|
def addPicks(self, station, picks):
|
||||||
stat_picks = self.getPicksOnStation(station)
|
stat_picks = self.getPicksOnStation(station)
|
||||||
|
rval = False
|
||||||
if not stat_picks:
|
if not stat_picks:
|
||||||
stat_picks = picks
|
stat_picks = picks
|
||||||
else:
|
else:
|
||||||
@ -684,11 +689,13 @@ class MainWindow(QMainWindow):
|
|||||||
ret = msgBox.exec_()
|
ret = msgBox.exec_()
|
||||||
if ret == QMessageBox.Save:
|
if ret == QMessageBox.Save:
|
||||||
stat_picks = picks
|
stat_picks = picks
|
||||||
|
rval = True
|
||||||
elif ret == QMessageBox.Cancel:
|
elif ret == QMessageBox.Cancel:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise Exception('FATAL: Should never occur!')
|
raise Exception('FATAL: Should never occur!')
|
||||||
self.getPicks()[station] = stat_picks
|
self.getPicks()[station] = stat_picks
|
||||||
|
return rval
|
||||||
|
|
||||||
def updatePicks(self):
|
def updatePicks(self):
|
||||||
evt = self.getData().getEvtData()
|
evt = self.getData().getEvtData()
|
||||||
|
@ -240,7 +240,7 @@ class PickDlg(QDialog):
|
|||||||
home_icon = QIcon()
|
home_icon = QIcon()
|
||||||
home_icon.addPixmap(QPixmap(':/icons/zoom_0.png'))
|
home_icon.addPixmap(QPixmap(':/icons/zoom_0.png'))
|
||||||
del_icon = QIcon()
|
del_icon = QIcon()
|
||||||
del_icon.addPixmap(QPixmap(':/icon/delete.png'))
|
del_icon.addPixmap(QPixmap(':/icons/delete.png'))
|
||||||
|
|
||||||
# create actions
|
# create actions
|
||||||
self.filterAction = createAction(parent=self, text='Filter',
|
self.filterAction = createAction(parent=self, text='Filter',
|
||||||
@ -275,6 +275,8 @@ class PickDlg(QDialog):
|
|||||||
_dialtoolbar.addAction(self.zoomAction)
|
_dialtoolbar.addAction(self.zoomAction)
|
||||||
_dialtoolbar.addSeparator()
|
_dialtoolbar.addSeparator()
|
||||||
_dialtoolbar.addAction(self.resetZoomAction)
|
_dialtoolbar.addAction(self.resetZoomAction)
|
||||||
|
_dialtoolbar.addSeparator()
|
||||||
|
_dialtoolbar.addAction(self.resetPicksAction)
|
||||||
|
|
||||||
# layout the innermost widget
|
# layout the innermost widget
|
||||||
_innerlayout = QVBoxLayout()
|
_innerlayout = QVBoxLayout()
|
||||||
@ -376,7 +378,7 @@ class PickDlg(QDialog):
|
|||||||
traceIDs = []
|
traceIDs = []
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
channel = channel.upper()
|
channel = channel.upper()
|
||||||
for traceID, channelID in plotDict.iteritems():
|
for traceID, channelID in plotDict.items():
|
||||||
if channelID[1].upper().endswith(channel):
|
if channelID[1].upper().endswith(channel):
|
||||||
traceIDs.append(traceID)
|
traceIDs.append(traceID)
|
||||||
return traceIDs
|
return traceIDs
|
||||||
@ -427,6 +429,13 @@ class PickDlg(QDialog):
|
|||||||
def getPicks(self):
|
def getPicks(self):
|
||||||
return self.picks
|
return self.picks
|
||||||
|
|
||||||
|
def resetPicks(self):
|
||||||
|
self.picks = {}
|
||||||
|
|
||||||
|
def delPicks(self):
|
||||||
|
self.resetPicks()
|
||||||
|
self.resetPlot()
|
||||||
|
|
||||||
def setIniPick(self, gui_event):
|
def setIniPick(self, gui_event):
|
||||||
|
|
||||||
trace_number = round(gui_event.ydata)
|
trace_number = round(gui_event.ydata)
|
||||||
@ -677,8 +686,21 @@ class PickDlg(QDialog):
|
|||||||
zoomx=self.getXLims(),
|
zoomx=self.getXLims(),
|
||||||
zoomy=self.getYLims())
|
zoomy=self.getYLims())
|
||||||
self.setPlotLabels()
|
self.setPlotLabels()
|
||||||
|
self.drawPicks()
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
|
def resetPlot(self):
|
||||||
|
self.updateCurrentLimits()
|
||||||
|
data = self.getWFData().copy()
|
||||||
|
title = self.getPlotWidget().getAxes().get_title()
|
||||||
|
self.getPlotWidget().plotWFData(wfdata=data, title=title,
|
||||||
|
zoomx=self.getXLims(),
|
||||||
|
zoomy=self.getYLims())
|
||||||
|
self.setPlotLabels()
|
||||||
|
self.drawPicks()
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
|
||||||
def setPlotLabels(self):
|
def setPlotLabels(self):
|
||||||
|
|
||||||
# get channel labels
|
# get channel labels
|
||||||
@ -716,7 +738,7 @@ class PickDlg(QDialog):
|
|||||||
else:
|
else:
|
||||||
# deal with something that should never happen
|
# deal with something that should never happen
|
||||||
scale_factor = 1
|
scale_factor = 1
|
||||||
print gui_event.button
|
print(gui_event.button)
|
||||||
|
|
||||||
new_xlim = gui_event.xdata - \
|
new_xlim = gui_event.xdata - \
|
||||||
scale_factor * (gui_event.xdata - self.getXLims())
|
scale_factor * (gui_event.xdata - self.getXLims())
|
||||||
@ -747,7 +769,7 @@ class PickDlg(QDialog):
|
|||||||
def apply(self):
|
def apply(self):
|
||||||
picks = self.getPicks()
|
picks = self.getPicks()
|
||||||
for pick in picks:
|
for pick in picks:
|
||||||
print pick, picks[pick]
|
print(pick, picks[pick])
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.apply()
|
self.apply()
|
||||||
|
Loading…
Reference in New Issue
Block a user