[add] delete all autopicks button in GUI

[bugfix] small bugfix in case of problems with Stream String representation
This commit is contained in:
Marcel Paffrath 2019-12-17 13:50:54 +01:00
parent a9135ec483
commit 3a1c907043
2 changed files with 30 additions and 3 deletions

View File

@ -67,7 +67,7 @@ from pylot.core.io.inputs import FilterOptions, PylotParameter
from autoPyLoT import autoPyLoT
from pylot.core.pick.compare import Comparison
from pylot.core.pick.utils import symmetrize_error, getQualityFromUncertainty, getPickQuality, get_quality_class
from pylot.core.io.phases import picksdict_from_picks
from pylot.core.io.phases import picksdict_from_picks, picks_from_picksdict
import pylot.core.loc.nll as nll
from pylot.core.util.errors import DatastructureError, \
OverwriteError
@ -290,6 +290,8 @@ class MainWindow(QMainWindow):
prefIcon.addPixmap(QPixmap(':/icons/preferences.png'))
paraIcon = QIcon()
paraIcon.addPixmap(QPixmap(':/icons/parameter.png'))
deleteIcon = QIcon()
deleteIcon.addPixmap(QPixmap(':/icons/delete.png'))
self.inventoryIcon = QIcon()
self.inventoryIcon.addPixmap(QPixmap(':/icons/inventory.png'))
self.mapIcon = QIcon()
@ -412,6 +414,10 @@ class MainWindow(QMainWindow):
self.setParameter,
None, paraIcon,
"Modify Parameter")
self.deleteAutopicksAction = self.createAction(self, "Delete Autopicks",
self.deleteAllAutopicks,
None, deleteIcon,
"Delete all automatic picks from Project.")
self.filterActionP = createAction(parent=self, text='Apply P Filter',
slot=self.filterP,
icon=self.filter_icon_p,
@ -567,7 +573,7 @@ class MainWindow(QMainWindow):
prefsEventAction)
# printAction) #TODO: print event?
pickMenuActions = (self.parameterAction,)
pickMenuActions = (self.parameterAction, self.deleteAutopicksAction)
self.pickMenu = self.menuBar().addMenu('&Picking')
self.autoPickMenu = self.pickMenu.addMenu(self.autopicksicon_small, 'Automatic picking')
self.autoPickMenu.setEnabled(False)
@ -3629,6 +3635,22 @@ class MainWindow(QMainWindow):
self.paraBox.params_to_gui()
self.paraBox.show()
def deleteAllAutopicks(self):
qmb = QMessageBox(self, icon=QMessageBox.Question,
text='Are you sure you want to delete all automatic picks?')
qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
qmb.setDefaultButton(QMessageBox.Yes)
ret = qmb.exec_()
if not ret == qmb.Yes:
return
for event in self.project.eventlist:
event.pylot_autopicks = {}
for index, pick in reversed(list(enumerate(event.picks))):
if pick.method_id.id.endswith('auto'):
event.picks.pop(index)
self.refreshEvents()
def PyLoTprefs(self):
if not self._props:
self._props = PropertiesDlg(self, infile=self.infile,

View File

@ -770,9 +770,14 @@ class AutopickStation(object):
:raises:
MissingTraceException: If vertical trace is missing.
"""
try:
stream_string_repr = str(self.zstream)
except Exception as e:
stream_string_repr = None
print('Could not get string representation of Stream: {}'.format(e))
msg = '##################################################\nautopickstation:' \
' Working on P onset of station {station}\nFiltering vertical ' \
'trace ...\n{data}'.format(station=self.station_name, data=str(self.zstream))
'trace ...\n{data}'.format(station=self.station_name, data=stream_string_repr)
self.vprint(msg)
tr_filt, z_copy = self.prepare_wfstream(self.zstream, self.pickparams["bpz1"][0], self.pickparams["bpz1"][1])