[new] add qcombobox for raw/processed selection

This commit is contained in:
Marcel Paffrath 2018-06-08 14:18:28 +02:00
parent 5e161d308a
commit 8155389b3d
3 changed files with 76 additions and 49 deletions

View File

@ -1001,6 +1001,7 @@ class MainWindow(QMainWindow):
# TODO: add dataStructure class for obspyDMT here, this is just a workaround! # TODO: add dataStructure class for obspyDMT here, this is just a workaround!
eventpath = self.get_current_event_path(eventbox) eventpath = self.get_current_event_path(eventbox)
basepath = eventpath.split(os.path.basename(eventpath))[0] basepath = eventpath.split(os.path.basename(eventpath))[0]
obspy_dmt = check_obspydmt_structure(basepath)
if self.dataStructure: if self.dataStructure:
if not eventpath: if not eventpath:
return return
@ -1659,10 +1660,10 @@ class MainWindow(QMainWindow):
if self._eventChanged[1]: if self._eventChanged[1]:
self.refresh_array_map() self.refresh_array_map()
if not plotted and self._eventChanged[0]: if not plotted and self._eventChanged[0]:
# newWF(False) = load data without plotting # newWF(plot=False) = load data without plotting
self.newWF(plot=False) self.newWF(plot=False)
def newWF(self, plot=True): def newWF(self, event=None, plot=True):
''' '''
Load new data and plot if necessary. Load new data and plot if necessary.
''' '''
@ -1703,25 +1704,42 @@ class MainWindow(QMainWindow):
eventpath = self.get_current_event_path() eventpath = self.get_current_event_path()
basepath = eventpath.split(os.path.basename(eventpath))[0] basepath = eventpath.split(os.path.basename(eventpath))[0]
obspy_dmt = check_obspydmt_structure(basepath) obspy_dmt = check_obspydmt_structure(basepath)
self.data.setWFData(self.fnames, if obspy_dmt:
checkRotated=True, self.prepareObspyDMT_data(eventpath)
metadata=self.metadata,
obspy_dmt=obspy_dmt)
def setWFstatus(self): self.data.setWFData(self.fnames,
''' self.fnames_syn,
show status of current data, can be either 'raw' or 'processed' checkRotated=True,
:param status: metadata=self.metadata)
:return:
''' def prepareObspyDMT_data(self, eventpath):
status = self.data.processed qcbox_processed = self.dataPlot.perm_qcbox_right
wf_stat_color = {True: 'green', qcbox_processed.setEnabled(False)
False: 'black', for fpath in os.listdir(eventpath):
None: None} fpath = fpath.split('/')[-1]
wf_stat = {True: 'processed', if 'syngine' in fpath:
False: 'raw', eventpath_syn = os.path.join(eventpath, fpath)
None: None} self.fnames_syn = [os.path.join(eventpath_syn, filename) for filename in os.listdir(eventpath_syn)]
self.dataPlot.setPermTextRight(wf_stat[status], wf_stat_color[status]) if 'processed' in fpath:
qcbox_processed.setEnabled(True)
wftype = qcbox_processed.currentText() if qcbox_processed.isEnabled() else 'raw'
eventpath_dmt = os.path.join(eventpath, wftype)
self.fnames = [os.path.join(eventpath_dmt, filename) for filename in os.listdir(eventpath_dmt)]
# def setWFstatus(self):
# '''
# show status of current data, can be either 'raw' or 'processed'
# :param status:
# :return:
# '''
# status = self.data.processed
# wf_stat_color = {True: 'green',
# False: 'black',
# None: None}
# wf_stat = {True: 'processed',
# False: 'raw',
# None: None}
# self.dataPlot.setQCboxItem(wf_stat[status])
def check_plot_quantity(self): def check_plot_quantity(self):
""" """
@ -1867,7 +1885,6 @@ class MainWindow(QMainWindow):
if True in self.comparable.values(): if True in self.comparable.values():
self.compare_action.setEnabled(True) self.compare_action.setEnabled(True)
self.draw() self.draw()
self.setWFstatus()
def checkEvent4comparison(self, event): def checkEvent4comparison(self, event):
if event.pylot_picks and event.pylot_autopicks: if event.pylot_picks and event.pylot_autopicks:

View File

@ -371,7 +371,7 @@ class Data(object):
data.filter(**kwargs) data.filter(**kwargs)
self.dirty = True self.dirty = True
def setWFData(self, fnames, checkRotated=False, metadata=None, obspy_dmt=False): def setWFData(self, fnames, fnames_syn=None, checkRotated=False, metadata=None):
""" """
Clear current waveform data and set given waveform data Clear current waveform data and set given waveform data
:param fnames: waveform data names to append :param fnames: waveform data names to append
@ -380,27 +380,25 @@ class Data(object):
self.wfdata = Stream() self.wfdata = Stream()
self.wforiginal = None self.wforiginal = None
self.wfsyn = Stream() self.wfsyn = Stream()
wffnames = None # if obspy_dmt:
wffnames_syn = None # wfdir = 'raw'
if obspy_dmt: # self.processed = False
wfdir = 'raw' # for fname in fnames:
self.processed = False # if fname.endswith('processed'):
for fname in fnames: # wfdir = 'processed'
if fname.endswith('processed'): # self.processed = True
wfdir = 'processed' # break
self.processed = True # for fpath in fnames:
break # if fpath.endswith(wfdir):
for fpath in fnames: # wffnames = [os.path.join(fpath, fname) for fname in os.listdir(fpath)]
if fpath.endswith(wfdir): # if 'syngine' in fpath.split('/')[-1]:
wffnames = [os.path.join(fpath, fname) for fname in os.listdir(fpath)] # wffnames_syn = [os.path.join(fpath, fname) for fname in os.listdir(fpath)]
if 'syngine' in fpath.split('/')[-1]: # else:
wffnames_syn = [os.path.join(fpath, fname) for fname in os.listdir(fpath)] # wffnames = fnames
else: if fnames is not None:
wffnames = fnames self.appendWFData(fnames)
if wffnames is not None: if fnames_syn is not None:
self.appendWFData(wffnames) self.appendWFData(fnames_syn, synthetic=True)
if wffnames_syn is not None:
self.appendWFData(wffnames_syn, synthetic=True)
else: else:
return False return False

View File

@ -455,12 +455,13 @@ class WaveformWidgetPG(QtGui.QWidget):
self.main_layout = QtGui.QVBoxLayout() self.main_layout = QtGui.QVBoxLayout()
self.label_layout = QtGui.QHBoxLayout() self.label_layout = QtGui.QHBoxLayout()
self.add_labels() self.add_labels()
self.connect_signals()
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.label_layout.addWidget(self.status_label)
self.label_layout.addWidget(self.perm_label_mid) self.label_layout.addWidget(self.perm_label_mid)
self.label_layout.addWidget(self.perm_label_right) 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'])
@ -491,12 +492,17 @@ class WaveformWidgetPG(QtGui.QWidget):
self.vLine.setPos(mousePoint.x()) self.vLine.setPos(mousePoint.x())
self.hLine.setPos(mousePoint.y()) self.hLine.setPos(mousePoint.y())
def connect_signals(self):
self.perm_qcbox_right.currentIndexChanged.connect(self.parent().newWF)
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_label_right = QtGui.QLabel() self.perm_qcbox_right = QtGui.QComboBox()
self.perm_label_right.setAlignment(2) self.addQCboxItem('raw', 'black')
self.addQCboxItem('processed', 'green')
#self.perm_qcbox_right.setAlignment(2)
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
def getPlotDict(self): def getPlotDict(self):
@ -506,9 +512,15 @@ class WaveformWidgetPG(QtGui.QWidget):
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 setPermTextRight(self, text=None, color='black'): def addQCboxItem(self, text=None, color='black'):
self.perm_label_right.setText(text) item = QtGui.QStandardItem(text)
self.perm_label_right.setStyleSheet('color: {}'.format(color)) model = self.perm_qcbox_right.model()
model.appendRow(item)
item.setForeground(QtGui.QColor('{}'.format(color)))
def setQCboxItem(self, text):
index = self.perm_qcbox_right.findText(text)
self.perm_qcbox_right.setCurrentIndex(index)
def setPlotDict(self, key, value): def setPlotDict(self, key, value):
self.plotdict[key] = value self.plotdict[key] = value