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