[bugfix] several bugfixes mostly refering to plotting from plotWaveformDataThread, now only plot data are generated from within thread
This commit is contained in:
parent
909e2241a7
commit
d6dd8bfaa8
58
QtPyLoT.py
58
QtPyLoT.py
@ -1201,7 +1201,7 @@ class MainWindow(QMainWindow):
|
||||
self.connect_mpl()
|
||||
|
||||
def connect_pg(self):
|
||||
self.poS_id = self.dataPlot.plotWidget.scene().sigMouseClicked.connect(self.pickOnStation)
|
||||
self.poS_id = self.dataPlot.plotWidget.scene().sigMouseClicked.connect(self.pickOnStation)
|
||||
|
||||
def connect_mpl(self):
|
||||
if not self.poS_id:
|
||||
@ -1226,7 +1226,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def disconnect_pg(self):
|
||||
if self.poS_id:
|
||||
self.dataPlot.plotWidget.scene().sigMouseClicked.disconnect(self.poS_id)
|
||||
self.dataPlot.plotWidget.scene().sigMouseClicked.disconnect()
|
||||
|
||||
def disconnect_mpl(self):
|
||||
if self.poS_id:
|
||||
@ -1240,8 +1240,22 @@ class MainWindow(QMainWindow):
|
||||
self.scroll_id = None
|
||||
|
||||
def finishWaveformDataPlot(self):
|
||||
if pg:
|
||||
self.getPlotWidget().updateWidget()
|
||||
if self.pg:
|
||||
self.getPlotWidget().updateWidget()
|
||||
plots = self.wfp_thread.data
|
||||
for times, data in plots:
|
||||
self.dataPlot.plotWidget.getPlotItem().plot(times, data, pen='k')
|
||||
self.dataPlot.reinitMoveProxy()
|
||||
plotWidget = self.getPlotWidget()
|
||||
plotDict = plotWidget.getPlotDict()
|
||||
pos = plotDict.keys()
|
||||
labels = [plotDict[n][2]+'.'+plotDict[n][0] for n in pos]
|
||||
plotWidget.setYTickLabels(pos, labels)
|
||||
try:
|
||||
plotWidget.figure.tight_layout()
|
||||
except:
|
||||
pass
|
||||
#self._max_xlims = self.dataPlot.getXLims()
|
||||
self.connectWFplotEvents()
|
||||
self.loadlocationaction.setEnabled(True)
|
||||
self.auto_tune.setEnabled(True)
|
||||
@ -1266,7 +1280,7 @@ class MainWindow(QMainWindow):
|
||||
def clearWaveformDataPlot(self):
|
||||
self.disconnectWFplotEvents()
|
||||
if self.pg:
|
||||
self.dataPlot.plotWidgetitem.clear()
|
||||
self.dataPlot.plotWidget.getPlotItem().clear()
|
||||
else:
|
||||
self.dataPlot.getAxes().cla()
|
||||
self.loadlocationaction.setEnabled(False)
|
||||
@ -1285,11 +1299,11 @@ class MainWindow(QMainWindow):
|
||||
'''
|
||||
Open a modal thread to plot current waveform data.
|
||||
'''
|
||||
#self.plotWaveformData()
|
||||
wfp_thread = Thread(self, self.plotWaveformData,
|
||||
progressText='Plotting waveform data...')
|
||||
wfp_thread.finished.connect(self.finishWaveformDataPlot)
|
||||
wfp_thread.start()
|
||||
self.clearWaveformDataPlot()
|
||||
self.wfp_thread = Thread(self, self.plotWaveformData,
|
||||
progressText='Plotting waveform data...')
|
||||
self.wfp_thread.finished.connect(self.finishWaveformDataPlot)
|
||||
self.wfp_thread.start()
|
||||
|
||||
def plotWaveformData(self):
|
||||
'''
|
||||
@ -1307,16 +1321,8 @@ class MainWindow(QMainWindow):
|
||||
# wfst += self.get_data().getWFData().select(component=alter_comp)
|
||||
plotWidget = self.getPlotWidget()
|
||||
self.adjustPlotHeight()
|
||||
plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False, component=comp, nth_sample=int(nth_sample))
|
||||
plotDict = plotWidget.getPlotDict()
|
||||
pos = plotDict.keys()
|
||||
labels = [plotDict[n][2]+'.'+plotDict[n][0] for n in pos]
|
||||
plotWidget.setYTickLabels(pos, labels)
|
||||
try:
|
||||
plotWidget.figure.tight_layout()
|
||||
except:
|
||||
pass
|
||||
#self._max_xlims = self.dataPlot.getXLims()
|
||||
plots = plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False, component=comp, nth_sample=int(nth_sample))
|
||||
return plots
|
||||
|
||||
def adjustPlotHeight(self):
|
||||
if self.pg:
|
||||
@ -1331,20 +1337,20 @@ class MainWindow(QMainWindow):
|
||||
def plotZ(self):
|
||||
self.setComponent('Z')
|
||||
self.plotWaveformDataThread()
|
||||
self.drawPicks()
|
||||
self.draw()
|
||||
# self.drawPicks()
|
||||
# self.draw()
|
||||
|
||||
def plotN(self):
|
||||
self.setComponent('N')
|
||||
self.plotWaveformDataThread()
|
||||
self.drawPicks()
|
||||
self.draw()
|
||||
# self.drawPicks()
|
||||
# self.draw()
|
||||
|
||||
def plotE(self):
|
||||
self.setComponent('E')
|
||||
self.plotWaveformDataThread()
|
||||
self.drawPicks()
|
||||
self.draw()
|
||||
# self.drawPicks()
|
||||
# self.draw()
|
||||
|
||||
def pushFilterWF(self, param_args):
|
||||
self.get_data().filterWFData(param_args)
|
||||
|
@ -1 +1 @@
|
||||
a071-dirty
|
||||
909e-dirty
|
||||
|
@ -418,6 +418,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
self.main_layout.addWidget(self.plotWidget)
|
||||
#self.plotWidget.setMouseEnabled(False, False)
|
||||
self.plotWidget.showGrid(x=False, y=True, alpha=0.2)
|
||||
self.reinitMoveProxy()
|
||||
self._proxy = pg.SignalProxy(self.plotWidget.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved)
|
||||
|
||||
def reinitMoveProxy(self):
|
||||
@ -455,7 +456,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
noiselevel=None, scaleddata=False, mapping=True,
|
||||
component='*', nth_sample=1, iniPick=None):
|
||||
self.title = title
|
||||
self.plotWidget.getPlotItem().clear()
|
||||
#self.plotWidget.clear()
|
||||
self.clearPlotDict()
|
||||
wfstart, wfend = full_range(wfdata)
|
||||
nmax = 0
|
||||
@ -479,6 +480,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
nsc.append((trace.stats.network, trace.stats.station, trace.stats.channel))
|
||||
nsc.sort()
|
||||
nsc.reverse()
|
||||
plots = []
|
||||
|
||||
for n, (network, station, channel) in enumerate(nsc):
|
||||
st = wfdata.select(network=network, station=station, channel=channel)
|
||||
@ -499,23 +501,13 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
||||
data = [datum + n for index, datum in enumerate(trace.data) if not index%nth_sample]
|
||||
self.plotWidget.plot(times, data, pen=(0, 0, 0))
|
||||
if noiselevel is not None:
|
||||
for level in noiselevel:
|
||||
self.plotWidget.plot([time_ax[0], time_ax[-1]],
|
||||
[level, level], pen=(0, 0, 0))
|
||||
# if iniPick:
|
||||
# ax = self.getAxes()
|
||||
# ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1],
|
||||
# colors='m', linestyles='dashed',
|
||||
# linewidth=2)
|
||||
plots.append((times, data))
|
||||
self.setPlotDict(n, (station, channel, network))
|
||||
self.reinitMoveProxy()
|
||||
self.xlabel = 'seconds since {0}'.format(wfstart)
|
||||
self.ylabel = ''
|
||||
self.setXLims([0, wfend - wfstart])
|
||||
self.setYLims([-0.5, nmax + 0.5])
|
||||
self.draw()
|
||||
return plots
|
||||
|
||||
# def getAxes(self):
|
||||
# return self.axes
|
||||
|
Loading…
Reference in New Issue
Block a user