working on connection between picks/autopicks of different tools [WIP], to do: fix array map number of picks/points mismatch in map
This commit is contained in:
parent
ba58cb548b
commit
55bc0de036
37
QtPyLoT.py
37
QtPyLoT.py
@ -661,11 +661,13 @@ class MainWindow(QMainWindow):
|
|||||||
self.refreshEvents()
|
self.refreshEvents()
|
||||||
tabindex = self.tabs.currentIndex()
|
tabindex = self.tabs.currentIndex()
|
||||||
|
|
||||||
def fill_eventbox(self, eventBox, select_events='all'):
|
def fill_eventbox(self, eventBox=None, select_events='all'):
|
||||||
'''
|
'''
|
||||||
:param: select_events, can be 'all', 'ref'
|
:param: select_events, can be 'all', 'ref'
|
||||||
:type: str
|
:type: str
|
||||||
'''
|
'''
|
||||||
|
if not eventBox:
|
||||||
|
eventBox = self.eventBox
|
||||||
index=eventBox.currentIndex()
|
index=eventBox.currentIndex()
|
||||||
tv=QtGui.QTableView()
|
tv=QtGui.QTableView()
|
||||||
header = tv.horizontalHeader()
|
header = tv.horizontalHeader()
|
||||||
@ -1149,6 +1151,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
self.update_status('picks accepted ({0})'.format(station))
|
self.update_status('picks accepted ({0})'.format(station))
|
||||||
replot = self.addPicks(station, pickDlg.getPicks())
|
replot = self.addPicks(station, pickDlg.getPicks())
|
||||||
|
self.getCurrentEvent().setPick(station, pickDlg.getPicks())
|
||||||
if replot:
|
if replot:
|
||||||
self.plotWaveformData()
|
self.plotWaveformData()
|
||||||
self.drawPicks()
|
self.drawPicks()
|
||||||
@ -1439,7 +1442,7 @@ class MainWindow(QMainWindow):
|
|||||||
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.refresh_drawings(self.picks)
|
self.array_map.refresh_drawings(self.getCurrentEvent().getPicks())
|
||||||
self._eventChanged[1] = False
|
self._eventChanged[1] = False
|
||||||
|
|
||||||
def init_event_table(self, tabindex=2):
|
def init_event_table(self, tabindex=2):
|
||||||
@ -1836,9 +1839,9 @@ class Event(object):
|
|||||||
'''
|
'''
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.autopicks = None
|
self.autopicks = {}
|
||||||
self.picks = None
|
self.picks = {}
|
||||||
self.notes = None
|
self.notes = ''
|
||||||
self._testEvent = False
|
self._testEvent = False
|
||||||
self._refEvent = False
|
self._refEvent = False
|
||||||
|
|
||||||
@ -1867,7 +1870,31 @@ class Event(object):
|
|||||||
def setTestEvent(self, bool):
|
def setTestEvent(self, bool):
|
||||||
self._testEvent = bool
|
self._testEvent = bool
|
||||||
if bool: self._refEvent = False
|
if bool: self._refEvent = False
|
||||||
|
|
||||||
|
def setPick(self, station, pick):
|
||||||
|
self.picks[station] = pick
|
||||||
|
|
||||||
|
def setPicks(self, picks):
|
||||||
|
self.picks = picks
|
||||||
|
|
||||||
|
def getPick(self, station):
|
||||||
|
return self.picks[station]
|
||||||
|
|
||||||
|
def getPicks(self):
|
||||||
|
return self.picks
|
||||||
|
|
||||||
|
def setAutopick(self, station, autopick):
|
||||||
|
self.autopicks[station] = autopick
|
||||||
|
|
||||||
|
def setAutopicks(self, autopicks):
|
||||||
|
self.autopicks = autopicks
|
||||||
|
|
||||||
|
def getAutopick(self, station):
|
||||||
|
return self.autopicks[station]
|
||||||
|
|
||||||
|
def getAutopicks(self):
|
||||||
|
return self.autopicks
|
||||||
|
|
||||||
|
|
||||||
class getExistingDirectories(QFileDialog):
|
class getExistingDirectories(QFileDialog):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
@ -1 +1 @@
|
|||||||
f436-dirty
|
ba58-dirty
|
||||||
|
@ -48,13 +48,13 @@ class map_projection(QtGui.QWidget):
|
|||||||
pickDlg = PickDlg(self, parameter=self._parent._inputs,
|
pickDlg = PickDlg(self, parameter=self._parent._inputs,
|
||||||
data=data.select(station=station),
|
data=data.select(station=station),
|
||||||
station=station,
|
station=station,
|
||||||
picks=self._parent.getPicksOnStation(station, 'manual'),
|
picks=self._parent.getCurrentEvent().getPick(station),
|
||||||
autopicks=self._parent.getPicksOnStation(station, 'auto'))
|
autopicks=self._parent.getCurrentEvent().getAutopick(station))
|
||||||
pyl_mw = self._parent
|
pyl_mw = self._parent
|
||||||
if pickDlg.exec_():
|
if pickDlg.exec_():
|
||||||
pyl_mw.setDirty(True)
|
pyl_mw.setDirty(True)
|
||||||
pyl_mw.update_status('picks accepted ({0})'.format(station))
|
pyl_mw.update_status('picks accepted ({0})'.format(station))
|
||||||
replot = pyl_mw.addPicks(station, pickDlg.getPicks())
|
replot = pyl_mw.getCurrentEvent().setPick(station, pickDlg.getPicks())
|
||||||
if replot:
|
if replot:
|
||||||
pyl_mw.plotWaveformData()
|
pyl_mw.plotWaveformData()
|
||||||
pyl_mw.drawPicks()
|
pyl_mw.drawPicks()
|
||||||
@ -148,8 +148,9 @@ 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 not np.isnan(pick):
|
if pick:
|
||||||
picks_no_nan.append(pick)
|
if not np.isnan(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)
|
||||||
|
@ -515,13 +515,14 @@ class WaveformWidget(FigureCanvas):
|
|||||||
|
|
||||||
|
|
||||||
class PickDlg(QDialog):
|
class PickDlg(QDialog):
|
||||||
|
update_picks = QtCore.Signal(dict)
|
||||||
def __init__(self, parent=None, data=None, station=None, picks=None,
|
def __init__(self, parent=None, data=None, station=None, picks=None,
|
||||||
autopicks=None, rotate=False, parameter=None, buttons=True):
|
autopicks=None, rotate=False, parameter=None, embedded=False):
|
||||||
super(PickDlg, self).__init__(parent)
|
super(PickDlg, self).__init__(parent)
|
||||||
|
|
||||||
# initialize attributes
|
# initialize attributes
|
||||||
self.parameter = parameter
|
self.parameter = parameter
|
||||||
self._buttons = buttons
|
self._embedded = embedded
|
||||||
self.station = station
|
self.station = station
|
||||||
self.rotate = rotate
|
self.rotate = rotate
|
||||||
self.components = 'ZNE'
|
self.components = 'ZNE'
|
||||||
@ -531,12 +532,16 @@ class PickDlg(QDialog):
|
|||||||
self._user = settings.value('user/Login', pylot_user)
|
self._user = settings.value('user/Login', pylot_user)
|
||||||
if picks:
|
if picks:
|
||||||
self.picks = picks
|
self.picks = picks
|
||||||
|
self._init_picks = copy.deepcopy(picks)
|
||||||
else:
|
else:
|
||||||
self.picks = {}
|
self.picks = {}
|
||||||
|
self._init_picks = {}
|
||||||
if autopicks:
|
if autopicks:
|
||||||
self.autopicks = autopicks
|
self.autopicks = autopicks
|
||||||
|
self._init_autopicks = copy.deepcopy(autopicks)
|
||||||
else:
|
else:
|
||||||
self.autopicks = {}
|
self.autopicks = {}
|
||||||
|
self._init_autopicks = {}
|
||||||
self.filteroptions = FILTERDEFAULTS
|
self.filteroptions = FILTERDEFAULTS
|
||||||
self.pick_block = False
|
self.pick_block = False
|
||||||
|
|
||||||
@ -638,6 +643,11 @@ class PickDlg(QDialog):
|
|||||||
# set button tooltips
|
# set button tooltips
|
||||||
self.p_button.setToolTip('Hotkey: "1"')
|
self.p_button.setToolTip('Hotkey: "1"')
|
||||||
self.s_button.setToolTip('Hotkey: "2"')
|
self.s_button.setToolTip('Hotkey: "2"')
|
||||||
|
|
||||||
|
# create accept/reject button
|
||||||
|
self.accept_button = QPushButton('&Accept Picks')
|
||||||
|
self.reject_button = QPushButton('&Reject Picks')
|
||||||
|
self.disable_ar_buttons()
|
||||||
|
|
||||||
# layout the outermost appearance of the Pick Dialog
|
# layout the outermost appearance of the Pick Dialog
|
||||||
_outerlayout = QVBoxLayout()
|
_outerlayout = QVBoxLayout()
|
||||||
@ -652,6 +662,9 @@ class PickDlg(QDialog):
|
|||||||
_dialtoolbar.addAction(self.resetZoomAction)
|
_dialtoolbar.addAction(self.resetZoomAction)
|
||||||
_dialtoolbar.addSeparator()
|
_dialtoolbar.addSeparator()
|
||||||
_dialtoolbar.addAction(self.resetPicksAction)
|
_dialtoolbar.addAction(self.resetPicksAction)
|
||||||
|
if self._embedded:
|
||||||
|
_dialtoolbar.addWidget(self.accept_button)
|
||||||
|
_dialtoolbar.addWidget(self.reject_button)
|
||||||
|
|
||||||
# layout the innermost widget
|
# layout the innermost widget
|
||||||
_innerlayout = QVBoxLayout()
|
_innerlayout = QVBoxLayout()
|
||||||
@ -662,7 +675,7 @@ class PickDlg(QDialog):
|
|||||||
QDialogButtonBox.Cancel)
|
QDialogButtonBox.Cancel)
|
||||||
|
|
||||||
# merge widgets and layouts to establish the dialog
|
# merge widgets and layouts to establish the dialog
|
||||||
if self._buttons:
|
if not self._embedded:
|
||||||
_innerlayout.addWidget(_buttonbox)
|
_innerlayout.addWidget(_buttonbox)
|
||||||
_outerlayout.addWidget(_dialtoolbar)
|
_outerlayout.addWidget(_dialtoolbar)
|
||||||
_outerlayout.addLayout(_innerlayout)
|
_outerlayout.addLayout(_innerlayout)
|
||||||
@ -671,6 +684,10 @@ class PickDlg(QDialog):
|
|||||||
# object
|
# object
|
||||||
self.p_button.clicked.connect(self.p_clicked)
|
self.p_button.clicked.connect(self.p_clicked)
|
||||||
self.s_button.clicked.connect(self.s_clicked)
|
self.s_button.clicked.connect(self.s_clicked)
|
||||||
|
self.accept_button.clicked.connect(self.accept)
|
||||||
|
self.reject_button.clicked.connect(self.reject)
|
||||||
|
self.accept_button.clicked.connect(self.disable_ar_buttons)
|
||||||
|
self.reject_button.clicked.connect(self.disable_ar_buttons)
|
||||||
_buttonbox.accepted.connect(self.accept)
|
_buttonbox.accepted.connect(self.accept)
|
||||||
_buttonbox.rejected.connect(self.reject)
|
_buttonbox.rejected.connect(self.reject)
|
||||||
|
|
||||||
@ -713,6 +730,13 @@ class PickDlg(QDialog):
|
|||||||
widget = self.getPlotWidget()
|
widget = self.getPlotWidget()
|
||||||
return widget.mpl_connect('button_release_event', slot)
|
return widget.mpl_connect('button_release_event', slot)
|
||||||
|
|
||||||
|
def disable_ar_buttons(self):
|
||||||
|
self.enable_ar_buttons(False)
|
||||||
|
|
||||||
|
def enable_ar_buttons(self, bool=True):
|
||||||
|
self.accept_button.setEnabled(bool)
|
||||||
|
self.reject_button.setEnabled(bool)
|
||||||
|
|
||||||
def p_clicked(self):
|
def p_clicked(self):
|
||||||
if self.p_button.isChecked():
|
if self.p_button.isChecked():
|
||||||
self.s_button.setEnabled(False)
|
self.s_button.setEnabled(False)
|
||||||
@ -1073,6 +1097,7 @@ class PickDlg(QDialog):
|
|||||||
olpp=olpp)
|
olpp=olpp)
|
||||||
|
|
||||||
self.disconnectPressEvent()
|
self.disconnectPressEvent()
|
||||||
|
self.enable_ar_buttons()
|
||||||
self.zoomAction.setEnabled(True)
|
self.zoomAction.setEnabled(True)
|
||||||
self.pick_block = self.togglePickBlocker()
|
self.pick_block = self.togglePickBlocker()
|
||||||
self.leave_picking_mode()
|
self.leave_picking_mode()
|
||||||
@ -1110,9 +1135,10 @@ class PickDlg(QDialog):
|
|||||||
if picktype == 'manual':
|
if picktype == 'manual':
|
||||||
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
||||||
alpha=.25, color=colors[0])
|
alpha=.25, color=colors[0])
|
||||||
ax.plot([mpp - spe, mpp - spe], ylims, colors[1],
|
if spe:
|
||||||
[mpp, mpp], ylims, colors[2],
|
ax.plot([mpp - spe, mpp - spe], ylims, colors[1],
|
||||||
[mpp + spe, mpp + spe], ylims, colors[1])
|
[mpp, mpp], ylims, colors[2],
|
||||||
|
[mpp + spe, mpp + spe], ylims, colors[1])
|
||||||
elif picktype == 'auto':
|
elif picktype == 'auto':
|
||||||
ax.plot(mpp, ylims[1], colors[3],
|
ax.plot(mpp, ylims[1], colors[3],
|
||||||
mpp, ylims[0], colors[4])
|
mpp, ylims[0], colors[4])
|
||||||
@ -1265,12 +1291,35 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
picks = self.getPicks()
|
picks = self.getPicks()
|
||||||
|
self.update_picks.emit(picks)
|
||||||
for pick in picks:
|
for pick in picks:
|
||||||
print(pick, picks[pick])
|
print(pick, picks[pick])
|
||||||
|
|
||||||
|
def discard(self):
|
||||||
|
picks = self._init_picks
|
||||||
|
self.picks = picks
|
||||||
|
self.update_picks.emit(picks)
|
||||||
|
for pick in picks:
|
||||||
|
print(pick, picks[pick])
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
self.discard()
|
||||||
|
if not self._embedded:
|
||||||
|
QDialog.reject(self)
|
||||||
|
else:
|
||||||
|
self.resetPlot()
|
||||||
|
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
|
||||||
|
'Denied', 'New picks rejected!')
|
||||||
|
self.qmb.show()
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.apply()
|
self.apply()
|
||||||
QDialog.accept(self)
|
if not self._embedded:
|
||||||
|
QDialog.accept(self)
|
||||||
|
else:
|
||||||
|
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
|
||||||
|
'Accepted', 'New picks applied!')
|
||||||
|
self.qmb.show()
|
||||||
|
|
||||||
|
|
||||||
class TuneAutopicker(QWidget):
|
class TuneAutopicker(QWidget):
|
||||||
@ -1285,6 +1334,7 @@ class TuneAutopicker(QWidget):
|
|||||||
QtGui.QWidget.__init__(self, parent, 1)
|
QtGui.QWidget.__init__(self, parent, 1)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.setParent(parent)
|
self.setParent(parent)
|
||||||
|
self.setWindowTitle('PyLoT - Tune Autopicker')
|
||||||
self.parameter = parent._inputs
|
self.parameter = parent._inputs
|
||||||
self.fig_dict = parent.fig_dict
|
self.fig_dict = parent.fig_dict
|
||||||
self.data = Data()
|
self.data = Data()
|
||||||
@ -1385,6 +1435,16 @@ class TuneAutopicker(QWidget):
|
|||||||
|
|
||||||
def get_current_event_fp(self):
|
def get_current_event_fp(self):
|
||||||
return self.eventBox.currentText()
|
return self.eventBox.currentText()
|
||||||
|
|
||||||
|
def get_current_event_picks(self, station):
|
||||||
|
event = self.get_current_event()
|
||||||
|
if station in event.picks.keys():
|
||||||
|
return event.picks[station]
|
||||||
|
|
||||||
|
def get_current_event_autopicks(self, station):
|
||||||
|
event = self.get_current_event()
|
||||||
|
if event.autopicks:
|
||||||
|
return event.autopicks[station]
|
||||||
|
|
||||||
def get_current_station(self):
|
def get_current_station(self):
|
||||||
return str(self.stationBox.currentText())
|
return str(self.stationBox.currentText())
|
||||||
@ -1402,13 +1462,20 @@ class TuneAutopicker(QWidget):
|
|||||||
data = self.data.getWFData()
|
data = self.data.getWFData()
|
||||||
pickDlg = PickDlg(self, data=data.select(station=station),
|
pickDlg = PickDlg(self, data=data.select(station=station),
|
||||||
station=station, parameter=self.parameter,
|
station=station, parameter=self.parameter,
|
||||||
picks=self.get_current_event().picks,
|
picks=self.get_current_event_picks(station),
|
||||||
autopicks=self.get_current_event().autopicks,
|
autopicks=self.get_current_event_autopicks(station),
|
||||||
buttons=False)
|
embedded=True)
|
||||||
|
pickDlg.update_picks.connect(self.picks_from_pickdlg)
|
||||||
|
pickDlg.update_picks.connect(self.parent.fill_eventbox)
|
||||||
|
pickDlg.update_picks.connect(self.fill_eventbox)
|
||||||
self.pickDlg = QtGui.QWidget()
|
self.pickDlg = QtGui.QWidget()
|
||||||
hl = QtGui.QHBoxLayout()
|
hl = QtGui.QHBoxLayout()
|
||||||
self.pickDlg.setLayout(hl)
|
self.pickDlg.setLayout(hl)
|
||||||
hl.addWidget(pickDlg)
|
hl.addWidget(pickDlg)
|
||||||
|
|
||||||
|
def picks_from_pickdlg(self, picks=None):
|
||||||
|
station = self.get_current_station()
|
||||||
|
self.get_current_event().setPick(station, picks)
|
||||||
|
|
||||||
def fill_tabs(self, event=None, picked=False):
|
def fill_tabs(self, event=None, picked=False):
|
||||||
self.clear_all()
|
self.clear_all()
|
||||||
|
Loading…
Reference in New Issue
Block a user