some bugfixes
This commit is contained in:
parent
b23228253a
commit
6b7dbe3f9a
41
QtPyLoT.py
41
QtPyLoT.py
@ -91,7 +91,7 @@ class MainWindow(QMainWindow):
|
||||
self.project = Project()
|
||||
self.array_map = None
|
||||
self._metadata = None
|
||||
self._eventChanged = False
|
||||
self._eventChanged = [False, False]
|
||||
|
||||
self.poS_id = None
|
||||
self.ae_id = None
|
||||
@ -839,23 +839,34 @@ class MainWindow(QMainWindow):
|
||||
return True
|
||||
|
||||
def refreshEvents(self):
|
||||
self._eventChanged = True
|
||||
self._eventChanged = [True, True]
|
||||
self.refreshTabs()
|
||||
|
||||
def refreshTabs(self):
|
||||
if self.tabs.currentIndex() == 0:
|
||||
if hasattr(self.project, 'eventlist'):
|
||||
if len(self.project.eventlist) > 0:
|
||||
if self._eventChanged:
|
||||
self.newWFplot()
|
||||
if self.tabs.currentIndex() == 1:
|
||||
self.refresh_array_map()
|
||||
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 hasattr(self.project, 'eventlist'):
|
||||
if len(self.project.eventlist) > 0:
|
||||
if self._eventChanged[0]:
|
||||
self.newWFplot()
|
||||
if self.tabs.currentIndex() == 1:
|
||||
if self._eventChanged[1]:
|
||||
self.refresh_array_map()
|
||||
if self.tabs.currentIndex() == 2:
|
||||
self.init_event_table()
|
||||
|
||||
def newWFplot(self):
|
||||
self.loadWaveformDataThread()
|
||||
self._eventChanged = False
|
||||
self._eventChanged[0] = False
|
||||
|
||||
def loadWaveformDataThread(self):
|
||||
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.addWidget(self.array_map)
|
||||
self.tabs.setCurrentIndex(index)
|
||||
self.refresh_array_map()
|
||||
|
||||
def refresh_array_map(self):
|
||||
if not self.array_map:
|
||||
return
|
||||
# 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 set_enabled(item, enabled=True, checkable=False):
|
||||
@ -1513,12 +1526,15 @@ class MainWindow(QMainWindow):
|
||||
dlg = QFileDialog()
|
||||
fnm = dlg.getSaveFileName(self, 'Create a new project file...', filter='Pylot project (*.plp)')
|
||||
filename = fnm[0]
|
||||
if not len(fnm[0]):
|
||||
return
|
||||
if not filename.split('.')[-1] == 'plp':
|
||||
filename = fnm[0] + '.plp'
|
||||
if not exists:
|
||||
self.project = Project()
|
||||
self.init_events(new=True)
|
||||
self.project.save(filename)
|
||||
return True
|
||||
|
||||
def loadProject(self):
|
||||
if self.project:
|
||||
@ -1543,7 +1559,8 @@ class MainWindow(QMainWindow):
|
||||
def saveProject(self):
|
||||
if self.project:
|
||||
if not self.project.location:
|
||||
self.createNewProject(exists=True)
|
||||
if not self.createNewProject(exists=True):
|
||||
return
|
||||
else:
|
||||
self.project.save()
|
||||
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)
|
||||
|
||||
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
|
||||
:value: str
|
||||
@ -20,7 +20,8 @@ class map_projection(QtGui.QWidget):
|
||||
QtGui.QWidget.__init__(self)
|
||||
self.pyl_mainwindow = mainwindow
|
||||
self.parser = mainwindow.metadata[1]
|
||||
self.picked = picked
|
||||
self.picks = None
|
||||
self.picks_dict = None
|
||||
self.figure = figure
|
||||
self.init_graphics()
|
||||
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))
|
||||
|
||||
def connectSignals(self):
|
||||
self.comboBox_phase.currentIndexChanged.connect(self.refresh_drawings)
|
||||
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
||||
|
||||
def init_graphics(self):
|
||||
self.main_box = QtGui.QVBoxLayout()
|
||||
@ -75,6 +76,11 @@ class map_projection(QtGui.QWidget):
|
||||
self.comboBox_phase = QtGui.QComboBox()
|
||||
self.comboBox_phase.insertItem(0, 'P')
|
||||
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(self.comboBox_phase)
|
||||
self.top_row.setStretch(1,1) #set stretch of item 1 to 1
|
||||
@ -89,7 +95,7 @@ class map_projection(QtGui.QWidget):
|
||||
|
||||
self.toolbar = NavigationToolbar(self.canvas, self)
|
||||
self.main_box.addWidget(self.toolbar)
|
||||
|
||||
|
||||
def init_stations(self):
|
||||
def get_station_names_lat_lon(parser):
|
||||
station_names=[]
|
||||
@ -114,7 +120,7 @@ class map_projection(QtGui.QWidget):
|
||||
picks=[]
|
||||
for station in station_names:
|
||||
try:
|
||||
picks.append(self.pyl_mainwindow.autopicks[station][phase]['mpp'])
|
||||
picks.append(self.picks_dict[station][phase]['mpp'])
|
||||
except:
|
||||
picks.append(np.nan)
|
||||
return picks
|
||||
@ -226,19 +232,24 @@ class map_projection(QtGui.QWidget):
|
||||
cbar.set_label(label)
|
||||
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.draw_everything()
|
||||
|
||||
def draw_everything(self):
|
||||
if self.picked:
|
||||
if self.picks_dict:
|
||||
self.init_picks()
|
||||
self.init_picks_active()
|
||||
self.init_stations_active()
|
||||
self.init_picksgrid()
|
||||
self.draw_contour_filled()
|
||||
self.scatter_all_stations()
|
||||
if self.picked:
|
||||
if self.picks_dict:
|
||||
self.scatter_picked_stations()
|
||||
self.cbar = self.add_cbar(label='Time relative to first onset [s]')
|
||||
self.comboBox_phase.setEnabled(True)
|
||||
@ -248,13 +259,20 @@ class map_projection(QtGui.QWidget):
|
||||
self.canvas.draw()
|
||||
|
||||
def remove_drawings(self):
|
||||
self.sc_picked.remove()
|
||||
self.sc.remove()
|
||||
self.cbar.remove()
|
||||
self.remove_annotations()
|
||||
if hasattr(self, 'sc_picked'):
|
||||
self.sc_picked.remove()
|
||||
del(self.sc_picked)
|
||||
if hasattr(self, 'cbar'):
|
||||
self.cbar.remove()
|
||||
del(self.cbar)
|
||||
if hasattr(self, 'contourf'):
|
||||
self.remove_contourf()
|
||||
del(self.contourf)
|
||||
if hasattr(self, 'cid'):
|
||||
self.canvas.mpl_disconnect(self.cid)
|
||||
del(self.cid)
|
||||
self.sc.remove()
|
||||
self.legend.remove()
|
||||
self.remove_contourf()
|
||||
self.canvas.mpl_disconnect(self.cid)
|
||||
self.canvas.draw()
|
||||
|
||||
def remove_contourf(self):
|
||||
|
Loading…
Reference in New Issue
Block a user