several bugfixes, mainly on map_projection with updated pick structure as part of event class
This commit is contained in:
parent
55bc0de036
commit
d81fb3e2e9
42
QtPyLoT.py
42
QtPyLoT.py
@ -912,6 +912,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.refreshTabs()
|
self.refreshTabs()
|
||||||
|
|
||||||
def refreshTabs(self):
|
def refreshTabs(self):
|
||||||
|
plotted=False
|
||||||
if self._eventChanged[0] or self._eventChanged[1]:
|
if self._eventChanged[0] or self._eventChanged[1]:
|
||||||
event = self.getCurrentEvent()
|
event = self.getCurrentEvent()
|
||||||
if not event.picks:
|
if not event.picks:
|
||||||
@ -927,20 +928,25 @@ class MainWindow(QMainWindow):
|
|||||||
if len(self.project.eventlist) > 0:
|
if len(self.project.eventlist) > 0:
|
||||||
if self._eventChanged[0]:
|
if self._eventChanged[0]:
|
||||||
self.newWFplot()
|
self.newWFplot()
|
||||||
|
plotted=True
|
||||||
if self.tabs.currentIndex() == 1:
|
if self.tabs.currentIndex() == 1:
|
||||||
if self._eventChanged[1]:
|
if self._eventChanged[1]:
|
||||||
self.refresh_array_map()
|
self.refresh_array_map()
|
||||||
|
if not plotted and self._eventChanged[0]:
|
||||||
|
self.newWFplot(False)
|
||||||
if self.tabs.currentIndex() == 2:
|
if self.tabs.currentIndex() == 2:
|
||||||
self.init_event_table()
|
self.init_event_table()
|
||||||
|
|
||||||
def newWFplot(self):
|
def newWFplot(self, plot=True):
|
||||||
self.loadWaveformDataThread()
|
self.loadWaveformDataThread(plot)
|
||||||
self._eventChanged[0] = False
|
if plot:
|
||||||
|
self._eventChanged[0] = False
|
||||||
|
|
||||||
def loadWaveformDataThread(self):
|
def loadWaveformDataThread(self, plot=True):
|
||||||
wfd_thread = Thread(self, self.loadWaveformData,
|
wfd_thread = Thread(self, self.loadWaveformData,
|
||||||
progressText='Reading data input...')
|
progressText='Reading data input...')
|
||||||
wfd_thread.finished.connect(self.plotWaveformDataThread)
|
if plot:
|
||||||
|
wfd_thread.finished.connect(self.plotWaveformDataThread)
|
||||||
wfd_thread.start()
|
wfd_thread.start()
|
||||||
|
|
||||||
def loadWaveformData(self):
|
def loadWaveformData(self):
|
||||||
@ -1845,12 +1851,6 @@ class Event(object):
|
|||||||
self._testEvent = False
|
self._testEvent = False
|
||||||
self._refEvent = False
|
self._refEvent = False
|
||||||
|
|
||||||
def addPicks(self, picks):
|
|
||||||
self.picks = picks
|
|
||||||
|
|
||||||
def addAutopicks(self, autopicks):
|
|
||||||
self.autopicks = autopicks
|
|
||||||
|
|
||||||
def addNotes(self, notes):
|
def addNotes(self, notes):
|
||||||
self.notes = notes
|
self.notes = notes
|
||||||
|
|
||||||
@ -1871,26 +1871,38 @@ class Event(object):
|
|||||||
self._testEvent = bool
|
self._testEvent = bool
|
||||||
if bool: self._refEvent = False
|
if bool: self._refEvent = False
|
||||||
|
|
||||||
|
def addPicks(self, picks):
|
||||||
|
for station in picks:
|
||||||
|
self.picks[station] = picks[station]
|
||||||
|
|
||||||
|
def addAutopicks(self, autopicks):
|
||||||
|
for station in autopicks:
|
||||||
|
self.autopicks[station] = autopicks[station]
|
||||||
|
|
||||||
def setPick(self, station, pick):
|
def setPick(self, station, pick):
|
||||||
self.picks[station] = pick
|
if pick:
|
||||||
|
self.picks[station] = pick
|
||||||
|
|
||||||
def setPicks(self, picks):
|
def setPicks(self, picks):
|
||||||
self.picks = picks
|
self.picks = picks
|
||||||
|
|
||||||
def getPick(self, station):
|
def getPick(self, station):
|
||||||
return self.picks[station]
|
if station in self.picks.keys():
|
||||||
|
return self.picks[station]
|
||||||
|
|
||||||
def getPicks(self):
|
def getPicks(self):
|
||||||
return self.picks
|
return self.picks
|
||||||
|
|
||||||
def setAutopick(self, station, autopick):
|
def setAutopick(self, station, autopick):
|
||||||
self.autopicks[station] = autopick
|
if autopick:
|
||||||
|
self.autopicks[station] = autopick
|
||||||
|
|
||||||
def setAutopicks(self, autopicks):
|
def setAutopicks(self, autopicks):
|
||||||
self.autopicks = autopicks
|
self.autopicks = autopicks
|
||||||
|
|
||||||
def getAutopick(self, station):
|
def getAutopick(self, station):
|
||||||
return self.autopicks[station]
|
if station in self.autopicks.keys():
|
||||||
|
return self.autopicks[station]
|
||||||
|
|
||||||
def getAutopicks(self):
|
def getAutopicks(self):
|
||||||
return self.autopicks
|
return self.autopicks
|
||||||
|
@ -1 +1 @@
|
|||||||
ba58-dirty
|
55bc-dirty
|
||||||
|
@ -50,22 +50,29 @@ class map_projection(QtGui.QWidget):
|
|||||||
station=station,
|
station=station,
|
||||||
picks=self._parent.getCurrentEvent().getPick(station),
|
picks=self._parent.getCurrentEvent().getPick(station),
|
||||||
autopicks=self._parent.getCurrentEvent().getAutopick(station))
|
autopicks=self._parent.getCurrentEvent().getAutopick(station))
|
||||||
pyl_mw = self._parent
|
|
||||||
if pickDlg.exec_():
|
|
||||||
pyl_mw.setDirty(True)
|
|
||||||
pyl_mw.update_status('picks accepted ({0})'.format(station))
|
|
||||||
replot = pyl_mw.getCurrentEvent().setPick(station, pickDlg.getPicks())
|
|
||||||
if replot:
|
|
||||||
pyl_mw.plotWaveformData()
|
|
||||||
pyl_mw.drawPicks()
|
|
||||||
pyl_mw.draw()
|
|
||||||
else:
|
|
||||||
pyl_mw.drawPicks(station)
|
|
||||||
pyl_mw.draw()
|
|
||||||
else:
|
|
||||||
pyl_mw.update_status('picks discarded ({0})'.format(station))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Could not generate Plot for station {st}.\n{er}'.format(st=station, er=e))
|
message = 'Could not generate Plot for station {st}.\n{er}'.format(st=station, er=e)
|
||||||
|
self._warn(message)
|
||||||
|
print(message, e)
|
||||||
|
pyl_mw = self._parent
|
||||||
|
#try:
|
||||||
|
if pickDlg.exec_():
|
||||||
|
pyl_mw.setDirty(True)
|
||||||
|
pyl_mw.update_status('picks accepted ({0})'.format(station))
|
||||||
|
replot = pyl_mw.getCurrentEvent().setPick(station, pickDlg.getPicks())
|
||||||
|
if replot:
|
||||||
|
pyl_mw.plotWaveformData()
|
||||||
|
pyl_mw.drawPicks()
|
||||||
|
pyl_mw.draw()
|
||||||
|
else:
|
||||||
|
pyl_mw.drawPicks(station)
|
||||||
|
pyl_mw.draw()
|
||||||
|
else:
|
||||||
|
pyl_mw.update_status('picks discarded ({0})'.format(station))
|
||||||
|
# except Exception as e:
|
||||||
|
# message = 'Could not save picks for station {st}.\n{er}'.format(st=station, er=e)
|
||||||
|
# self._warn(message)
|
||||||
|
# print(message, e)
|
||||||
|
|
||||||
def connectSignals(self):
|
def connectSignals(self):
|
||||||
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
||||||
@ -92,9 +99,9 @@ class map_projection(QtGui.QWidget):
|
|||||||
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 = QtGui.QComboBox()
|
||||||
# self.comboBox_am.insertItem(0, 'auto')
|
self.comboBox_am.insertItem(0, 'auto')
|
||||||
# self.comboBox_am.insertItem(1, 'manual')
|
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)
|
||||||
@ -134,9 +141,13 @@ class map_projection(QtGui.QWidget):
|
|||||||
|
|
||||||
def get_picks_rel(picks):
|
def get_picks_rel(picks):
|
||||||
picks_rel=[]
|
picks_rel=[]
|
||||||
minp = min(picks)
|
picks_utc = []
|
||||||
for pick in picks:
|
for pick in picks:
|
||||||
if type(pick) is obspy.core.utcdatetime.UTCDateTime:
|
if type(pick) is obspy.core.utcdatetime.UTCDateTime:
|
||||||
|
picks_utc.append(pick)
|
||||||
|
minp = min(picks_utc)
|
||||||
|
for pick in picks:
|
||||||
|
if type(pick) is obspy.core.utcdatetime.UTCDateTime:
|
||||||
pick -= minp
|
pick -= minp
|
||||||
picks_rel.append(pick)
|
picks_rel.append(pick)
|
||||||
return picks_rel
|
return picks_rel
|
||||||
@ -148,9 +159,8 @@ class map_projection(QtGui.QWidget):
|
|||||||
def remove_nan_picks(picks):
|
def remove_nan_picks(picks):
|
||||||
picks_no_nan=[]
|
picks_no_nan=[]
|
||||||
for pick in picks:
|
for pick in picks:
|
||||||
if pick:
|
if not np.isnan(pick):
|
||||||
if not np.isnan(pick):
|
picks_no_nan.append(pick)
|
||||||
picks_no_nan.append(pick)
|
|
||||||
return picks_no_nan
|
return picks_no_nan
|
||||||
|
|
||||||
self.picks_no_nan = remove_nan_picks(self.picks_rel)
|
self.picks_no_nan = remove_nan_picks(self.picks_rel)
|
||||||
@ -225,8 +235,19 @@ class map_projection(QtGui.QWidget):
|
|||||||
self.cid = self.canvas.mpl_connect('pick_event', self.onpick)
|
self.cid = self.canvas.mpl_connect('pick_event', self.onpick)
|
||||||
|
|
||||||
def scatter_picked_stations(self):
|
def scatter_picked_stations(self):
|
||||||
self.sc_picked = self.basemap.scatter(self.lon_no_nan, self.lat_no_nan, s=50, facecolor='white',
|
lon = self.lon_no_nan
|
||||||
c=self.picks_no_nan, latlon=True, zorder=11, label='Picked')
|
lat = self.lat_no_nan
|
||||||
|
|
||||||
|
#workaround because of an issue with latlon transformation of arrays with len <3
|
||||||
|
if len(lon) <= 2 and len(lat) <= 2:
|
||||||
|
self.sc_picked = self.basemap.scatter(lon[0], lat[0], s=50, facecolor='white',
|
||||||
|
c=self.picks_no_nan[0], latlon=True, zorder=11, label='Picked')
|
||||||
|
if len(lon) == 2 and len(lat) == 2:
|
||||||
|
self.sc_picked = self.basemap.scatter(lon[1], lat[1], s=50, facecolor='white',
|
||||||
|
c=self.picks_no_nan[1], latlon=True, zorder=11)
|
||||||
|
else:
|
||||||
|
self.sc_picked = self.basemap.scatter(lon, lat, s=50, facecolor='white',
|
||||||
|
c=self.picks_no_nan, latlon=True, zorder=11, label='Picked')
|
||||||
|
|
||||||
def annotate_ax(self):
|
def annotate_ax(self):
|
||||||
self.annotations=[]
|
self.annotations=[]
|
||||||
@ -254,8 +275,9 @@ class map_projection(QtGui.QWidget):
|
|||||||
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()
|
if len(self.picks_no_nan) >= 3:
|
||||||
self.draw_contour_filled()
|
self.init_picksgrid()
|
||||||
|
self.draw_contour_filled()
|
||||||
self.scatter_all_stations()
|
self.scatter_all_stations()
|
||||||
if self.picks_dict:
|
if self.picks_dict:
|
||||||
self.scatter_picked_stations()
|
self.scatter_picked_stations()
|
||||||
@ -297,4 +319,9 @@ class map_projection(QtGui.QWidget):
|
|||||||
for annotation in self.annotations:
|
for annotation in self.annotations:
|
||||||
annotation.remove()
|
annotation.remove()
|
||||||
|
|
||||||
|
def _warn(self, message):
|
||||||
|
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
|
||||||
|
'Warning', message)
|
||||||
|
self.qmb.show()
|
||||||
|
|
||||||
|
|
||||||
|
@ -693,6 +693,7 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
# finally layout the entire dialog
|
# finally layout the entire dialog
|
||||||
self.setLayout(_outerlayout)
|
self.setLayout(_outerlayout)
|
||||||
|
self.resize(1280, 720)
|
||||||
|
|
||||||
def disconnectPressEvent(self):
|
def disconnectPressEvent(self):
|
||||||
widget = self.getPlotWidget()
|
widget = self.getPlotWidget()
|
||||||
@ -1390,8 +1391,12 @@ class TuneAutopicker(QWidget):
|
|||||||
if not station in stations:
|
if not station in stations:
|
||||||
stations.append(str(station))
|
stations.append(str(station))
|
||||||
stations.sort()
|
stations.sort()
|
||||||
|
model = self.stationBox.model()
|
||||||
for station in stations:
|
for station in stations:
|
||||||
self.stationBox.addItem(str(station))
|
item = QtGui.QStandardItem(str(station))
|
||||||
|
if station in self.get_current_event().picks:
|
||||||
|
item.setBackground(QtGui.QColor(200, 210, 230, 255))
|
||||||
|
model.appendRow(item)
|
||||||
|
|
||||||
def init_figure_tabs(self):
|
def init_figure_tabs(self):
|
||||||
self.figure_tabs = QtGui.QTabWidget()
|
self.figure_tabs = QtGui.QTabWidget()
|
||||||
@ -1415,8 +1420,11 @@ class TuneAutopicker(QWidget):
|
|||||||
def add_buttons(self):
|
def add_buttons(self):
|
||||||
self.pick_button = QtGui.QPushButton('Pick Trace')
|
self.pick_button = QtGui.QPushButton('Pick Trace')
|
||||||
self.pick_button.clicked.connect(self.call_picker)
|
self.pick_button.clicked.connect(self.call_picker)
|
||||||
|
self.close_button = QtGui.QPushButton('Close')
|
||||||
|
self.close_button.clicked.connect(self.hide)
|
||||||
self.trace_layout.addWidget(self.pick_button)
|
self.trace_layout.addWidget(self.pick_button)
|
||||||
self.trace_layout.setStretch(0, 1)
|
self.trace_layout.setStretch(0, 1)
|
||||||
|
self.parameter_layout.addWidget(self.close_button)
|
||||||
|
|
||||||
def add_log(self):
|
def add_log(self):
|
||||||
self.listWidget = QtGui.QListWidget()
|
self.listWidget = QtGui.QListWidget()
|
||||||
@ -1467,7 +1475,8 @@ class TuneAutopicker(QWidget):
|
|||||||
embedded=True)
|
embedded=True)
|
||||||
pickDlg.update_picks.connect(self.picks_from_pickdlg)
|
pickDlg.update_picks.connect(self.picks_from_pickdlg)
|
||||||
pickDlg.update_picks.connect(self.parent.fill_eventbox)
|
pickDlg.update_picks.connect(self.parent.fill_eventbox)
|
||||||
pickDlg.update_picks.connect(self.fill_eventbox)
|
pickDlg.update_picks.connect(self.fill_eventbox)
|
||||||
|
pickDlg.update_picks.connect(self.fill_stationbox)
|
||||||
self.pickDlg = QtGui.QWidget()
|
self.pickDlg = QtGui.QWidget()
|
||||||
hl = QtGui.QHBoxLayout()
|
hl = QtGui.QHBoxLayout()
|
||||||
self.pickDlg.setLayout(hl)
|
self.pickDlg.setLayout(hl)
|
||||||
|
Loading…
Reference in New Issue
Block a user