[update] warn/do not save picks with unknown phase ID
This commit is contained in:
parent
4589f92a1a
commit
b191bd8cf4
@ -1 +1 @@
|
|||||||
44f63-dirty
|
4589-dirty
|
||||||
|
@ -1169,6 +1169,8 @@ def identifyPhase(phase):
|
|||||||
# common phase suffix for P and S
|
# common phase suffix for P and S
|
||||||
common_P = ['P', 'p', 'R']
|
common_P = ['P', 'p', 'R']
|
||||||
common_S = ['S', 's']
|
common_S = ['S', 's']
|
||||||
|
if phase is None:
|
||||||
|
return False
|
||||||
if phase[-1] in common_P:
|
if phase[-1] in common_P:
|
||||||
return 'P'
|
return 'P'
|
||||||
if phase[-1] in common_S:
|
if phase[-1] in common_S:
|
||||||
|
@ -1144,6 +1144,7 @@ class PickDlg(QDialog):
|
|||||||
self.arrivals = []
|
self.arrivals = []
|
||||||
self.arrivalsText = []
|
self.arrivalsText = []
|
||||||
self.cidpick = []
|
self.cidpick = []
|
||||||
|
self.cidpress = None
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
pylot_user = getpass.getuser()
|
pylot_user = getpass.getuser()
|
||||||
self._user = settings.value('user/Login', pylot_user)
|
self._user = settings.value('user/Login', pylot_user)
|
||||||
@ -1678,7 +1679,12 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
def activatePicking(self):
|
def activatePicking(self):
|
||||||
phase = self.currentPhase
|
phase = self.currentPhase
|
||||||
color = pick_color_plt('manual', self.getPhaseID(phase))
|
phaseID = self.getPhaseID(phase)
|
||||||
|
if not phaseID:
|
||||||
|
self.warn_unknown_phase(phase)
|
||||||
|
self.leave_picking_mode()
|
||||||
|
return
|
||||||
|
color = pick_color_plt('manual', phaseID)
|
||||||
self.multicompfig.set_frame_color(color)
|
self.multicompfig.set_frame_color(color)
|
||||||
self.multicompfig.set_frame_linewidth(1.5)
|
self.multicompfig.set_frame_linewidth(1.5)
|
||||||
if self.zoomAction.isChecked():
|
if self.zoomAction.isChecked():
|
||||||
@ -2020,39 +2026,27 @@ class PickDlg(QDialog):
|
|||||||
network=wfdata[0].stats.network,
|
network=wfdata[0].stats.network,
|
||||||
filteroptions=transformFilteroptions2String(filteroptions))
|
filteroptions=transformFilteroptions2String(filteroptions))
|
||||||
|
|
||||||
try:
|
saved = self.savePick(phase, phasepicks, pick, epp, lpp)
|
||||||
oldphasepick = self.picks[phase]
|
if saved:
|
||||||
except KeyError:
|
self.setDirty(True)
|
||||||
self.picks[phase] = phasepicks
|
|
||||||
else:
|
|
||||||
self.picks[phase] = phasepicks
|
|
||||||
oepp = oldphasepick['epp']
|
|
||||||
ompp = oldphasepick['mpp']
|
|
||||||
olpp = oldphasepick['lpp']
|
|
||||||
msg = """Warning old phase information for phase {phase} has been
|
|
||||||
altered.\n
|
|
||||||
New phase times:\n
|
|
||||||
earliest possible pick: {epp}\n
|
|
||||||
most probable pick: {mpp}\n
|
|
||||||
latest possible pick: {lpp}\n
|
|
||||||
\n
|
|
||||||
Old phase times (overwritten):\n
|
|
||||||
earliest possible pick: {oepp}\n
|
|
||||||
most probable pick: {ompp}\n
|
|
||||||
latest possible pick: {olpp}\n""".format(phase=phase,
|
|
||||||
epp=epp,
|
|
||||||
mpp=pick,
|
|
||||||
lpp=lpp,
|
|
||||||
oepp=oepp,
|
|
||||||
ompp=ompp,
|
|
||||||
olpp=olpp)
|
|
||||||
|
|
||||||
self.disconnectPressEvent()
|
self.disconnectPressEvent()
|
||||||
self.enable_ar_buttons()
|
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()
|
||||||
self.setDirty(True)
|
|
||||||
|
def savePick(self, phase, phasepicks):
|
||||||
|
if not self.getPhaseID(phase):
|
||||||
|
self.warn_unknown_phase(phase)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.picks[phase] = phasepicks
|
||||||
|
return True
|
||||||
|
|
||||||
|
def warn_unknown_phase(self, phase=None):
|
||||||
|
QtGui.QMessageBox.warning(self, 'Unknown phase ID',
|
||||||
|
'Could not identify phase ID: {}.'.format(phase))
|
||||||
|
|
||||||
def disconnectPressEvent(self):
|
def disconnectPressEvent(self):
|
||||||
self.multicompfig.mpl_disconnect(self.cidpress)
|
self.multicompfig.mpl_disconnect(self.cidpress)
|
||||||
@ -2232,7 +2226,9 @@ class PickDlg(QDialog):
|
|||||||
def renamePhaseInDict(self, picks, phase_old, phase_new):
|
def renamePhaseInDict(self, picks, phase_old, phase_new):
|
||||||
if phase_new in picks:
|
if phase_new in picks:
|
||||||
raise KeyError('New phase ID already assigned.')
|
raise KeyError('New phase ID already assigned.')
|
||||||
picks[phase_new] = picks[phase_old].copy()
|
picks_new = picks[phase_old].copy()
|
||||||
|
saved = self.savePick(phase_new, picks_new)
|
||||||
|
if saved:
|
||||||
picks.pop(phase_old)
|
picks.pop(phase_old)
|
||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user