Merge branch 'develop'
This commit is contained in:
commit
0d5c0e5bd2
113
QtPyLoT.py
113
QtPyLoT.py
@ -63,7 +63,7 @@ from pylot.core.pick.compare import Comparison
|
|||||||
from pylot.core.pick.utils import symmetrize_error
|
from pylot.core.pick.utils import symmetrize_error
|
||||||
from pylot.core.io.phases import picksdict_from_picks
|
from pylot.core.io.phases import picksdict_from_picks
|
||||||
import pylot.core.loc.nll as nll
|
import pylot.core.loc.nll as nll
|
||||||
from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents
|
from pylot.core.util.defaults import FILTERDEFAULTS, OUTPUTFORMATS, SetChannelComponents
|
||||||
from pylot.core.util.errors import FormatError, DatastructureError, \
|
from pylot.core.util.errors import FormatError, DatastructureError, \
|
||||||
OverwriteError, ProcessingError
|
OverwriteError, ProcessingError
|
||||||
from pylot.core.util.connection import checkurl
|
from pylot.core.util.connection import checkurl
|
||||||
@ -650,6 +650,8 @@ class MainWindow(QMainWindow):
|
|||||||
data[type] += Data(self, evtdata=fname)
|
data[type] += Data(self, evtdata=fname)
|
||||||
if not loc:
|
if not loc:
|
||||||
self.updatePicks(type=type)
|
self.updatePicks(type=type)
|
||||||
|
if self.get_current_event.picks:
|
||||||
|
self.plotWaveformDataThread()
|
||||||
self.drawPicks(picktype=type)
|
self.drawPicks(picktype=type)
|
||||||
self.draw()
|
self.draw()
|
||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
@ -732,9 +734,13 @@ class MainWindow(QMainWindow):
|
|||||||
'''
|
'''
|
||||||
Return event path of event (type QtPylot.Event) currently selected in eventbox.
|
Return event path of event (type QtPylot.Event) currently selected in eventbox.
|
||||||
'''
|
'''
|
||||||
if not eventbox:
|
return self.get_current_event(eventbox).path
|
||||||
eventbox = self.eventBox
|
|
||||||
return str(eventbox.currentText().split('|')[0]).strip()
|
def get_current_event_name(self, eventbox=None):
|
||||||
|
'''
|
||||||
|
Return event path of event (type QtPylot.Event) currently selected in eventbox.
|
||||||
|
'''
|
||||||
|
return self.get_current_event_path(eventbox).split('/')[-1]
|
||||||
|
|
||||||
def getLastEvent(self):
|
def getLastEvent(self):
|
||||||
return self.recentfiles[0]
|
return self.recentfiles[0]
|
||||||
@ -908,41 +914,46 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def getSavePath(e):
|
def getSavePath(e):
|
||||||
print('warning: {0}'.format(e))
|
print('warning: {0}'.format(e))
|
||||||
directory = os.path.realpath(self.getRoot())
|
directory = self.get_current_event_path()
|
||||||
|
eventname = self.get_current_event_name()
|
||||||
|
filename = 'picks_'+eventname
|
||||||
|
outpath = os.path.join(directory, filename)
|
||||||
file_filter = "QuakeML file (*.xml);;VELEST observation file " \
|
file_filter = "QuakeML file (*.xml);;VELEST observation file " \
|
||||||
"format (*.cnv);;NonLinLoc observation file (*.obs)"
|
"format (*.cnv);;NonLinLoc observation file (*.obs)"
|
||||||
title = 'Save pick data ...'
|
title = 'Save pick data ...'
|
||||||
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
||||||
title,
|
title,
|
||||||
directory,
|
outpath,
|
||||||
file_filter)
|
file_filter)
|
||||||
|
|
||||||
fbasename, exform = os.path.splitext(fname)
|
fbasename, exform = os.path.splitext(fname)
|
||||||
|
|
||||||
if not exform and selected_filter:
|
if not exform and selected_filter or not exform in OUTPUTFORMATS:
|
||||||
exform = selected_filter.split('*')[1][:-1]
|
exform = selected_filter.split('*')[1][:-1]
|
||||||
|
if not exform in OUTPUTFORMATS:
|
||||||
|
return fname, exform
|
||||||
return fbasename, exform
|
return fbasename, exform
|
||||||
|
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
fbasename = self.getEventFileName()
|
fbasename = self.getEventFileName()
|
||||||
exform = settings.value('data/exportFormat', 'QUAKEML')
|
exform = settings.value('data/exportFormat', 'QUAKEML')
|
||||||
try:
|
# try:
|
||||||
self.get_data().applyEVTData(self.getPicks())
|
# self.get_data().applyEVTData(self.getPicks())
|
||||||
except OverwriteError:
|
# except OverwriteError:
|
||||||
msgBox = QMessageBox()
|
# msgBox = QMessageBox()
|
||||||
msgBox.setText("Picks have been modified!")
|
# msgBox.setText("Picks have been modified!")
|
||||||
msgBox.setInformativeText(
|
# msgBox.setInformativeText(
|
||||||
"Do you want to save the changes and overwrite the picks?")
|
# "Do you want to save the changes and overwrite the picks?")
|
||||||
msgBox.setDetailedText(self.get_data().getPicksStr())
|
# msgBox.setDetailedText(self.get_data().getPicksStr())
|
||||||
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
# msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
||||||
msgBox.setDefaultButton(QMessageBox.Save)
|
# msgBox.setDefaultButton(QMessageBox.Save)
|
||||||
ret = msgBox.exec_()
|
# ret = msgBox.exec_()
|
||||||
if ret == QMessageBox.Save:
|
# if ret == QMessageBox.Save:
|
||||||
self.get_data().resetPicks()
|
# self.get_data().resetPicks()
|
||||||
return self.saveData()
|
# return self.saveData()
|
||||||
elif ret == QMessageBox.Cancel:
|
# elif ret == QMessageBox.Cancel:
|
||||||
return False
|
# return False
|
||||||
|
# MP MP changed due to new event structure not uniquely refering to data object
|
||||||
try:
|
try:
|
||||||
self.get_data().exportEvent(fbasename, exform)
|
self.get_data().exportEvent(fbasename, exform)
|
||||||
except FormatError as e:
|
except FormatError as e:
|
||||||
@ -1523,7 +1534,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.get_current_event().setPick(station, pickDlg.getPicks())
|
self.get_current_event().setPick(station, pickDlg.getPicks())
|
||||||
self.enableSaveManualPicksAction()
|
self.enableSaveManualPicksAction()
|
||||||
if replot:
|
if replot:
|
||||||
self.plotWaveformData()
|
self.plotWaveformDataThread()
|
||||||
self.drawPicks()
|
self.drawPicks()
|
||||||
self.draw()
|
self.draw()
|
||||||
else:
|
else:
|
||||||
@ -1627,31 +1638,36 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def addPicks(self, station, picks, type='manual'):
|
def addPicks(self, station, picks, type='manual'):
|
||||||
stat_picks = self.getPicksOnStation(station, type)
|
stat_picks = self.getPicksOnStation(station, type)
|
||||||
rval = False
|
|
||||||
if not stat_picks:
|
if not stat_picks:
|
||||||
stat_picks = picks
|
rval = False
|
||||||
else:
|
else:
|
||||||
msgBox = QMessageBox(self)
|
#set picks (ugly syntax?)
|
||||||
msgBox.setText("The picks for station {0} have been "
|
self.getPicks(type=type)[station] = picks
|
||||||
"changed.".format(station))
|
rval = True
|
||||||
msgBox.setDetailedText("Old picks:\n"
|
|
||||||
"{old_picks}\n\n"
|
|
||||||
"New picks:\n"
|
|
||||||
"{new_picks}".format(old_picks=stat_picks,
|
|
||||||
new_picks=picks))
|
|
||||||
msgBox.setInformativeText("Do you want to save your changes?")
|
|
||||||
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
|
||||||
msgBox.setDefaultButton(QMessageBox.Save)
|
|
||||||
ret = msgBox.exec_()
|
|
||||||
if ret == QMessageBox.Save:
|
|
||||||
stat_picks = picks
|
|
||||||
rval = True
|
|
||||||
elif ret == QMessageBox.Cancel:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
raise Exception('FATAL: Should never occur!')
|
|
||||||
self.getPicks(type=type)[station] = stat_picks
|
|
||||||
return rval
|
return rval
|
||||||
|
# if not stat_picks:
|
||||||
|
# stat_picks = picks
|
||||||
|
# else:
|
||||||
|
# msgBox = QMessageBox(self)
|
||||||
|
# msgBox.setText("The picks for station {0} have been "
|
||||||
|
# "changed.".format(station))
|
||||||
|
# msgBox.setDetailedText("Old picks:\n"
|
||||||
|
# "{old_picks}\n\n"
|
||||||
|
# "New picks:\n"
|
||||||
|
# "{new_picks}".format(old_picks=stat_picks,
|
||||||
|
# new_picks=picks))
|
||||||
|
# msgBox.setInformativeText("Do you want to save your changes?")
|
||||||
|
# msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
||||||
|
# msgBox.setDefaultButton(QMessageBox.Save)
|
||||||
|
# ret = msgBox.exec_()
|
||||||
|
# if ret == QMessageBox.Save:
|
||||||
|
# stat_picks = picks
|
||||||
|
# rval = True
|
||||||
|
# elif ret == QMessageBox.Cancel:
|
||||||
|
# pass
|
||||||
|
# else:
|
||||||
|
# raise Exception('FATAL: Should never occur!')
|
||||||
|
# MP MP prompt redundant because new picks have to be accepted in the first place closing PickDlg
|
||||||
|
|
||||||
def updatePicks(self, type='manual'):
|
def updatePicks(self, type='manual'):
|
||||||
picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data())
|
picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data())
|
||||||
@ -2461,6 +2477,9 @@ def create_window():
|
|||||||
if app is None:
|
if app is None:
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app_created = True
|
app_created = True
|
||||||
|
app.setOrganizationName("QtPyLoT");
|
||||||
|
app.setOrganizationDomain("rub.de");
|
||||||
|
app.setApplicationName("RUB");
|
||||||
app.references = set()
|
app.references = set()
|
||||||
#app.references.add(window)
|
#app.references.add(window)
|
||||||
#window.show()
|
#window.show()
|
||||||
|
@ -1 +1 @@
|
|||||||
5412-dirty
|
053c-dirty
|
||||||
|
Loading…
Reference in New Issue
Block a user