changed some things in properties dialog to keep settings when opened again. added settings 'nth_sample' to speed up plotting a little bit

This commit is contained in:
Marcel Paffrath 2017-05-29 18:03:31 +02:00
parent 0f1292e9f2
commit 395295a295
3 changed files with 34 additions and 9 deletions

View File

@ -96,6 +96,7 @@ class MainWindow(QMainWindow):
else:
self.infile = infile
self._inputs = AutoPickParameter(infile)
self._props = PropertiesDlg(self, infile=infile)
self.project = Project()
self.tap = None
@ -650,8 +651,7 @@ class MainWindow(QMainWindow):
return self.fnames
except DatastructureError as e:
print(e)
props = PropertiesDlg(self)
if props.exec_() == QDialog.Accepted:
if self._props.exec_() == QDialog.Accepted:
return self.getWFFnames()
else:
return
@ -1208,6 +1208,10 @@ class MainWindow(QMainWindow):
'''
Plot waveform data to current plotWidget.
'''
settings = QSettings()
nth_sample = settings.value('nth_sample')
if not nth_sample:
nth_sample = 1
compclass = SetChannelComponents()
zne_text = {'Z': 'vertical', 'N': 'north-south', 'E': 'east-west'}
comp = self.getComponent()
@ -1218,7 +1222,7 @@ 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)
plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False, nth_sample=int(nth_sample))
plotDict = plotWidget.getPlotDict()
pos = plotDict.keys()
labels = [plotDict[n][2]+'.'+plotDict[n][0] for n in pos]
@ -2037,8 +2041,7 @@ class MainWindow(QMainWindow):
QMainWindow.closeEvent(self, event)
def PyLoTprefs(self):
props = PropertiesDlg(self, infile=self.getinfile())
if props.exec_():
if self._props.exec_():
return
def helpHelp(self):

View File

@ -1 +1 @@
5115-dirty
0f12-dirty

View File

@ -430,7 +430,8 @@ class WaveformWidget(FigureCanvas):
self._parent = parent
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
noiselevel=None, scaleddata=False, mapping=True):
noiselevel=None, scaleddata=False, mapping=True,
nth_sample=1):
self.getAxes().cla()
self.clearPlotDict()
wfstart, wfend = full_range(wfdata)
@ -461,7 +462,9 @@ class WaveformWidget(FigureCanvas):
if not scaleddata:
trace.detrend('constant')
trace.normalize(np.max(np.abs(trace.data)) * 2)
self.getAxes().plot(time_ax, trace.data + n, 'k')
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.getAxes().plot(times, data, 'k')
if noiselevel is not None:
for level in noiselevel:
self.getAxes().plot([time_ax[0], time_ax[-1]],
@ -2146,8 +2149,27 @@ class PhasesTab(PropTab):
class GraphicsTab(PropTab):
def __init__(self, parent=None):
super(GraphicsTab, self).__init__(parent)
self.init_layout()
self.add_nth_sample()
self.setLayout(self.main_layout)
def init_layout(self):
self.main_layout = QGridLayout()
pass
def add_nth_sample(self):
self.nth_sample = QtGui.QSpinBox()
label = QLabel('nth sample')
self.nth_sample.setMinimum(1)
self.nth_sample.setMaximum(100)
self.nth_sample.setValue(1)
label.setToolTip('Plot every nth sample (to speed up plotting)')
self.main_layout.addWidget(label, 0, 0)
self.main_layout.addWidget(self.nth_sample, 0, 1)
def getValues(self):
values = {'nth_sample': self.nth_sample.value()}
return values
class ChannelOrderTab(PropTab):
def __init__(self, parent=None, infile=None):