[minor] tweaks and finalization of obspyDMT options

This commit is contained in:
Marcel Paffrath 2018-06-08 15:01:05 +02:00
parent 083e5c8fe9
commit f50e38241e
2 changed files with 39 additions and 18 deletions

View File

@ -1677,6 +1677,7 @@ class MainWindow(QMainWindow):
call modal plot thread method when finished. call modal plot thread method when finished.
''' '''
if load: if load:
self.prepareLoadWaveformData()
self.wfd_thread = Thread(self, self.loadWaveformData, self.wfd_thread = Thread(self, self.loadWaveformData,
progressText='Reading data input...', progressText='Reading data input...',
pb_widget=self.mainProgressBarWidget) pb_widget=self.mainProgressBarWidget)
@ -1689,6 +1690,16 @@ class MainWindow(QMainWindow):
if plot and not load: if plot and not load:
self.plotWaveformDataThread() self.plotWaveformDataThread()
def prepareLoadWaveformData(self):
self.fnames = self.getWFFnames_from_eventbox()
self.fnames_syn = []
eventpath = self.get_current_event_path()
basepath = eventpath.split(os.path.basename(eventpath))[0]
obspy_dmt = check_obspydmt_structure(basepath)
self.dataPlot.activateObspyDMToptions(obspy_dmt)
if obspy_dmt:
self.prepareObspyDMT_data(eventpath)
def loadWaveformData(self): def loadWaveformData(self):
''' '''
Load waveform data corresponding to current selected event. Load waveform data corresponding to current selected event.
@ -1700,13 +1711,6 @@ class MainWindow(QMainWindow):
# ans = self.data.setWFData(self.getWFFnames()) # ans = self.data.setWFData(self.getWFFnames())
# else: # else:
# ans = False # ans = False
self.fnames = self.getWFFnames_from_eventbox()
self.fnames_syn = []
eventpath = self.get_current_event_path()
basepath = eventpath.split(os.path.basename(eventpath))[0]
obspy_dmt = check_obspydmt_structure(basepath)
if obspy_dmt:
self.prepareObspyDMT_data(eventpath)
self.data.setWFData(self.fnames, self.data.setWFData(self.fnames,
self.fnames_syn, self.fnames_syn,
@ -1714,7 +1718,7 @@ class MainWindow(QMainWindow):
metadata=self.metadata) metadata=self.metadata)
def prepareObspyDMT_data(self, eventpath): def prepareObspyDMT_data(self, eventpath):
qcbox_processed = self.dataPlot.perm_qcbox_right qcbox_processed = self.dataPlot.qcombo_processed
qcheckb_syn = self.dataPlot.syn_checkbox qcheckb_syn = self.dataPlot.syn_checkbox
qcbox_processed.setEnabled(False) qcbox_processed.setEnabled(False)
qcheckb_syn.setEnabled(False) qcheckb_syn.setEnabled(False)
@ -1727,7 +1731,11 @@ class MainWindow(QMainWindow):
self.fnames_syn = [os.path.join(eventpath_syn, filename) for filename in os.listdir(eventpath_syn)] self.fnames_syn = [os.path.join(eventpath_syn, filename) for filename in os.listdir(eventpath_syn)]
if 'processed' in fpath: if 'processed' in fpath:
qcbox_processed.setEnabled(True) qcbox_processed.setEnabled(True)
wftype = qcbox_processed.currentText() if qcbox_processed.isEnabled() else 'raw' if qcbox_processed.isEnabled():
wftype = qcbox_processed.currentText()
else:
wftype = 'raw'
qcbox_processed.setCurrentIndex(qcbox_processed.findText(wftype))
eventpath_dmt = os.path.join(eventpath, wftype) eventpath_dmt = os.path.join(eventpath, wftype)
self.fnames = [os.path.join(eventpath_dmt, filename) for filename in os.listdir(eventpath_dmt)] self.fnames = [os.path.join(eventpath_dmt, filename) for filename in os.listdir(eventpath_dmt)]

View File

@ -459,10 +459,8 @@ class WaveformWidgetPG(QtGui.QWidget):
self.plotWidget = self.pg.PlotWidget(self.parent(), title=title) self.plotWidget = self.pg.PlotWidget(self.parent(), title=title)
self.main_layout.addWidget(self.plotWidget) self.main_layout.addWidget(self.plotWidget)
self.main_layout.addLayout(self.label_layout) self.main_layout.addLayout(self.label_layout)
self.label_layout.addWidget(self.status_label) self.init_labels()
self.label_layout.addWidget(self.perm_label_mid) self.activateObspyDMToptions(False)
self.label_layout.addWidget(self.syn_checkbox)
self.label_layout.addWidget(self.perm_qcbox_right)
self.plotWidget.showGrid(x=False, y=True, alpha=0.3) self.plotWidget.showGrid(x=False, y=True, alpha=0.3)
self.wfstart, self.wfend = 0, 0 self.wfstart, self.wfend = 0, 0
self.pen_multicursor = self.pg.mkPen(self.parent()._style['multicursor']['rgba']) self.pen_multicursor = self.pg.mkPen(self.parent()._style['multicursor']['rgba'])
@ -494,14 +492,25 @@ class WaveformWidgetPG(QtGui.QWidget):
self.hLine.setPos(mousePoint.y()) self.hLine.setPos(mousePoint.y())
def connect_signals(self): def connect_signals(self):
self.perm_qcbox_right.currentIndexChanged.connect(self.parent().newWF) self.qcombo_processed.activated.connect(self.parent().newWF)
self.syn_checkbox.clicked.connect(self.parent().newWF) self.syn_checkbox.clicked.connect(self.parent().newWF)
def init_labels(self):
self.label_layout.addWidget(self.status_label)
self.label_layout.addWidget(self.perm_label_mid)
self.label_layout.addWidget(self.syn_checkbox)
self.label_layout.addWidget(self.qcombo_processed)
self.syn_checkbox.setLayoutDirection(Qt.RightToLeft)
self.label_layout.setStretch(0, 4)
self.label_layout.setStretch(1, 2)
self.label_layout.setStretch(2, 3)
self.label_layout.setStretch(3, 1)
def add_labels(self): def add_labels(self):
self.status_label = QtGui.QLabel() self.status_label = QtGui.QLabel()
self.perm_label_mid = QtGui.QLabel() self.perm_label_mid = QtGui.QLabel()
self.perm_label_mid.setAlignment(4) self.perm_label_mid.setAlignment(4)
self.perm_qcbox_right = QtGui.QComboBox() self.qcombo_processed = QtGui.QComboBox()
self.syn_checkbox = QtGui.QCheckBox('synthetics') self.syn_checkbox = QtGui.QCheckBox('synthetics')
self.addQCboxItem('raw', 'black') self.addQCboxItem('raw', 'black')
self.addQCboxItem('processed', 'green') self.addQCboxItem('processed', 'green')
@ -511,19 +520,23 @@ class WaveformWidgetPG(QtGui.QWidget):
def getPlotDict(self): def getPlotDict(self):
return self.plotdict return self.plotdict
def activateObspyDMToptions(self, activate):
self.syn_checkbox.setVisible(activate)
self.qcombo_processed.setVisible(activate)
def setPermTextMid(self, text=None, color='black'): def setPermTextMid(self, text=None, color='black'):
self.perm_label_mid.setText(text) self.perm_label_mid.setText(text)
self.perm_label_mid.setStyleSheet('color: {}'.format(color)) self.perm_label_mid.setStyleSheet('color: {}'.format(color))
def addQCboxItem(self, text=None, color='black'): def addQCboxItem(self, text=None, color='black'):
item = QtGui.QStandardItem(text) item = QtGui.QStandardItem(text)
model = self.perm_qcbox_right.model() model = self.qcombo_processed.model()
model.appendRow(item) model.appendRow(item)
item.setForeground(QtGui.QColor('{}'.format(color))) item.setForeground(QtGui.QColor('{}'.format(color)))
def setQCboxItem(self, text): def setQCboxItem(self, text):
index = self.perm_qcbox_right.findText(text) index = self.qcombo_processed.findText(text)
self.perm_qcbox_right.setCurrentIndex(index) self.qcombo_processed.setCurrentIndex(index)
def setPlotDict(self, key, value): def setPlotDict(self, key, value):
self.plotdict[key] = value self.plotdict[key] = value