some bugfixes
This commit is contained in:
parent
b23228253a
commit
6b7dbe3f9a
29
QtPyLoT.py
29
QtPyLoT.py
@ -91,7 +91,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.project = Project()
|
self.project = Project()
|
||||||
self.array_map = None
|
self.array_map = None
|
||||||
self._metadata = None
|
self._metadata = None
|
||||||
self._eventChanged = False
|
self._eventChanged = [False, False]
|
||||||
|
|
||||||
self.poS_id = None
|
self.poS_id = None
|
||||||
self.ae_id = None
|
self.ae_id = None
|
||||||
@ -839,23 +839,34 @@ class MainWindow(QMainWindow):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def refreshEvents(self):
|
def refreshEvents(self):
|
||||||
self._eventChanged = True
|
self._eventChanged = [True, True]
|
||||||
self.refreshTabs()
|
self.refreshTabs()
|
||||||
|
|
||||||
def refreshTabs(self):
|
def refreshTabs(self):
|
||||||
|
if self._eventChanged[0] or self._eventChanged[1]:
|
||||||
|
event = self.getCurrentEvent()
|
||||||
|
if not event.picks:
|
||||||
|
self.picks = {}
|
||||||
|
else:
|
||||||
|
self.picks = event.picks
|
||||||
|
if not event.autopicks:
|
||||||
|
self.autopicks = {}
|
||||||
|
else:
|
||||||
|
self.autopicks = event.autopicks
|
||||||
if self.tabs.currentIndex() == 0:
|
if self.tabs.currentIndex() == 0:
|
||||||
if hasattr(self.project, 'eventlist'):
|
if hasattr(self.project, 'eventlist'):
|
||||||
if len(self.project.eventlist) > 0:
|
if len(self.project.eventlist) > 0:
|
||||||
if self._eventChanged:
|
if self._eventChanged[0]:
|
||||||
self.newWFplot()
|
self.newWFplot()
|
||||||
if self.tabs.currentIndex() == 1:
|
if self.tabs.currentIndex() == 1:
|
||||||
|
if self._eventChanged[1]:
|
||||||
self.refresh_array_map()
|
self.refresh_array_map()
|
||||||
if self.tabs.currentIndex() == 2:
|
if self.tabs.currentIndex() == 2:
|
||||||
self.init_event_table()
|
self.init_event_table()
|
||||||
|
|
||||||
def newWFplot(self):
|
def newWFplot(self):
|
||||||
self.loadWaveformDataThread()
|
self.loadWaveformDataThread()
|
||||||
self._eventChanged = False
|
self._eventChanged[0] = False
|
||||||
|
|
||||||
def loadWaveformDataThread(self):
|
def loadWaveformDataThread(self):
|
||||||
wfd_thread = Thread(self, self.loadWaveformData, progressText='Reading data input...')
|
wfd_thread = Thread(self, self.loadWaveformData, progressText='Reading data input...')
|
||||||
@ -1282,12 +1293,14 @@ class MainWindow(QMainWindow):
|
|||||||
self.array_layout.removeWidget(self.metadata_widget)
|
self.array_layout.removeWidget(self.metadata_widget)
|
||||||
self.array_layout.addWidget(self.array_map)
|
self.array_layout.addWidget(self.array_map)
|
||||||
self.tabs.setCurrentIndex(index)
|
self.tabs.setCurrentIndex(index)
|
||||||
|
self.refresh_array_map()
|
||||||
|
|
||||||
def refresh_array_map(self):
|
def refresh_array_map(self):
|
||||||
if not self.array_map:
|
if not self.array_map:
|
||||||
return
|
return
|
||||||
# refresh with new picks here!!!
|
# refresh with new picks here!!!
|
||||||
self.array_map.show()
|
self.array_map.refresh_drawings(self.picks)
|
||||||
|
self._eventChanged[1] = False
|
||||||
|
|
||||||
def init_event_table(self, index=2):
|
def init_event_table(self, index=2):
|
||||||
def set_enabled(item, enabled=True, checkable=False):
|
def set_enabled(item, enabled=True, checkable=False):
|
||||||
@ -1513,12 +1526,15 @@ class MainWindow(QMainWindow):
|
|||||||
dlg = QFileDialog()
|
dlg = QFileDialog()
|
||||||
fnm = dlg.getSaveFileName(self, 'Create a new project file...', filter='Pylot project (*.plp)')
|
fnm = dlg.getSaveFileName(self, 'Create a new project file...', filter='Pylot project (*.plp)')
|
||||||
filename = fnm[0]
|
filename = fnm[0]
|
||||||
|
if not len(fnm[0]):
|
||||||
|
return
|
||||||
if not filename.split('.')[-1] == 'plp':
|
if not filename.split('.')[-1] == 'plp':
|
||||||
filename = fnm[0] + '.plp'
|
filename = fnm[0] + '.plp'
|
||||||
if not exists:
|
if not exists:
|
||||||
self.project = Project()
|
self.project = Project()
|
||||||
self.init_events(new=True)
|
self.init_events(new=True)
|
||||||
self.project.save(filename)
|
self.project.save(filename)
|
||||||
|
return True
|
||||||
|
|
||||||
def loadProject(self):
|
def loadProject(self):
|
||||||
if self.project:
|
if self.project:
|
||||||
@ -1543,7 +1559,8 @@ class MainWindow(QMainWindow):
|
|||||||
def saveProject(self):
|
def saveProject(self):
|
||||||
if self.project:
|
if self.project:
|
||||||
if not self.project.location:
|
if not self.project.location:
|
||||||
self.createNewProject(exists=True)
|
if not self.createNewProject(exists=True):
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
self.project.save()
|
self.project.save()
|
||||||
if not self.project.dirty:
|
if not self.project.dirty:
|
||||||
|
@ -1 +1 @@
|
|||||||
29701-dirty
|
b232-dirty
|
||||||
|
@ -12,7 +12,7 @@ from pylot.core.util.widgets import PickDlg
|
|||||||
plt.interactive(False)
|
plt.interactive(False)
|
||||||
|
|
||||||
class map_projection(QtGui.QWidget):
|
class map_projection(QtGui.QWidget):
|
||||||
def __init__(self, mainwindow, figure=None, picked=False):
|
def __init__(self, mainwindow, figure=None):
|
||||||
'''
|
'''
|
||||||
:param: picked, can be False, auto, manual
|
:param: picked, can be False, auto, manual
|
||||||
:value: str
|
:value: str
|
||||||
@ -20,7 +20,8 @@ class map_projection(QtGui.QWidget):
|
|||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
self.pyl_mainwindow = mainwindow
|
self.pyl_mainwindow = mainwindow
|
||||||
self.parser = mainwindow.metadata[1]
|
self.parser = mainwindow.metadata[1]
|
||||||
self.picked = picked
|
self.picks = None
|
||||||
|
self.picks_dict = None
|
||||||
self.figure = figure
|
self.figure = figure
|
||||||
self.init_graphics()
|
self.init_graphics()
|
||||||
self.init_stations()
|
self.init_stations()
|
||||||
@ -63,7 +64,7 @@ class map_projection(QtGui.QWidget):
|
|||||||
print('Could not generate Plot for station {st}.\n{er}'.format(st=station, er=e))
|
print('Could not generate Plot for station {st}.\n{er}'.format(st=station, er=e))
|
||||||
|
|
||||||
def connectSignals(self):
|
def connectSignals(self):
|
||||||
self.comboBox_phase.currentIndexChanged.connect(self.refresh_drawings)
|
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
||||||
|
|
||||||
def init_graphics(self):
|
def init_graphics(self):
|
||||||
self.main_box = QtGui.QVBoxLayout()
|
self.main_box = QtGui.QVBoxLayout()
|
||||||
@ -75,6 +76,11 @@ class map_projection(QtGui.QWidget):
|
|||||||
self.comboBox_phase = QtGui.QComboBox()
|
self.comboBox_phase = QtGui.QComboBox()
|
||||||
self.comboBox_phase.insertItem(0, 'P')
|
self.comboBox_phase.insertItem(0, 'P')
|
||||||
self.comboBox_phase.insertItem(1, 'S')
|
self.comboBox_phase.insertItem(1, 'S')
|
||||||
|
|
||||||
|
# self.comboBox_am = QtGui.QComboBox()
|
||||||
|
# self.comboBox_am.insertItem(0, 'auto')
|
||||||
|
# self.comboBox_am.insertItem(1, 'manual')
|
||||||
|
|
||||||
self.top_row.addWidget(QtGui.QLabel('Select a phase: '))
|
self.top_row.addWidget(QtGui.QLabel('Select a phase: '))
|
||||||
self.top_row.addWidget(self.comboBox_phase)
|
self.top_row.addWidget(self.comboBox_phase)
|
||||||
self.top_row.setStretch(1,1) #set stretch of item 1 to 1
|
self.top_row.setStretch(1,1) #set stretch of item 1 to 1
|
||||||
@ -114,7 +120,7 @@ class map_projection(QtGui.QWidget):
|
|||||||
picks=[]
|
picks=[]
|
||||||
for station in station_names:
|
for station in station_names:
|
||||||
try:
|
try:
|
||||||
picks.append(self.pyl_mainwindow.autopicks[station][phase]['mpp'])
|
picks.append(self.picks_dict[station][phase]['mpp'])
|
||||||
except:
|
except:
|
||||||
picks.append(np.nan)
|
picks.append(np.nan)
|
||||||
return picks
|
return picks
|
||||||
@ -226,19 +232,24 @@ class map_projection(QtGui.QWidget):
|
|||||||
cbar.set_label(label)
|
cbar.set_label(label)
|
||||||
return cbar
|
return cbar
|
||||||
|
|
||||||
def refresh_drawings(self):
|
def refresh_drawings(self, picks=None):
|
||||||
|
self.picks_dict = picks
|
||||||
|
self.remove_drawings()
|
||||||
|
self.draw_everything()
|
||||||
|
|
||||||
|
def _refresh_drawings(self):
|
||||||
self.remove_drawings()
|
self.remove_drawings()
|
||||||
self.draw_everything()
|
self.draw_everything()
|
||||||
|
|
||||||
def draw_everything(self):
|
def draw_everything(self):
|
||||||
if self.picked:
|
if self.picks_dict:
|
||||||
self.init_picks()
|
self.init_picks()
|
||||||
self.init_picks_active()
|
self.init_picks_active()
|
||||||
self.init_stations_active()
|
self.init_stations_active()
|
||||||
self.init_picksgrid()
|
self.init_picksgrid()
|
||||||
self.draw_contour_filled()
|
self.draw_contour_filled()
|
||||||
self.scatter_all_stations()
|
self.scatter_all_stations()
|
||||||
if self.picked:
|
if self.picks_dict:
|
||||||
self.scatter_picked_stations()
|
self.scatter_picked_stations()
|
||||||
self.cbar = self.add_cbar(label='Time relative to first onset [s]')
|
self.cbar = self.add_cbar(label='Time relative to first onset [s]')
|
||||||
self.comboBox_phase.setEnabled(True)
|
self.comboBox_phase.setEnabled(True)
|
||||||
@ -248,13 +259,20 @@ class map_projection(QtGui.QWidget):
|
|||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def remove_drawings(self):
|
def remove_drawings(self):
|
||||||
|
if hasattr(self, 'sc_picked'):
|
||||||
self.sc_picked.remove()
|
self.sc_picked.remove()
|
||||||
self.sc.remove()
|
del(self.sc_picked)
|
||||||
|
if hasattr(self, 'cbar'):
|
||||||
self.cbar.remove()
|
self.cbar.remove()
|
||||||
self.remove_annotations()
|
del(self.cbar)
|
||||||
self.legend.remove()
|
if hasattr(self, 'contourf'):
|
||||||
self.remove_contourf()
|
self.remove_contourf()
|
||||||
|
del(self.contourf)
|
||||||
|
if hasattr(self, 'cid'):
|
||||||
self.canvas.mpl_disconnect(self.cid)
|
self.canvas.mpl_disconnect(self.cid)
|
||||||
|
del(self.cid)
|
||||||
|
self.sc.remove()
|
||||||
|
self.legend.remove()
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def remove_contourf(self):
|
def remove_contourf(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user