Merge branch 'develop' of ariadne:/data/git/pylot into develop

This commit is contained in:
Marcel Paffrath 2017-04-10 15:07:48 +02:00
commit d370ef67c0

View File

@ -73,9 +73,6 @@ class MainWindow(QMainWindow):
def __init__(self, parent=None): def __init__(self, parent=None):
super(MainWindow, self).__init__(parent) super(MainWindow, self).__init__(parent)
self.createAction = createAction
# read settings
settings = QSettings()
# check for default pylot.in-file # check for default pylot.in-file
infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in') infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
if os.path.isfile(infile)== False: if os.path.isfile(infile)== False:
@ -88,7 +85,14 @@ class MainWindow(QMainWindow):
else: else:
self.infile = infile self.infile = infile
self._inputs = AutoPickParameter(self.infile) # UI has to be set up before(!) children widgets are about to show up
self.createAction = createAction
# read settings
settings = QSettings()
self.recentfiles = settings.value("data/recentEvents", [])
self.dispComponent = str(settings.value("plotting/dispComponent", "Z"))
self.setupUi()
if settings.value("user/FullName", None) is None: if settings.value("user/FullName", None) is None:
fulluser = QInputDialog.getText(self, "Enter Name:", "Full name") fulluser = QInputDialog.getText(self, "Enter Name:", "Full name")
settings.setValue("user/FullName", fulluser) settings.setValue("user/FullName", fulluser)
@ -98,14 +102,12 @@ class MainWindow(QMainWindow):
"Enter authority/institution name:", "Enter authority/institution name:",
"Authority") "Authority")
settings.setValue("agency_id", agency) settings.setValue("agency_id", agency)
self.recentfiles = settings.value("data/recentEvents", [])
self.fname = dict(manual=None, auto=None, loc=None) self.fname = dict(manual=None, auto=None, loc=None)
self.fnames = None self.fnames = None
self._stime = None self._stime = None
structure_setting = settings.value("data/Structure", "PILOT") structure_setting = settings.value("data/Structure", "PILOT")
self.dataStructure = DATASTRUCTURE[structure_setting]() self.dataStructure = DATASTRUCTURE[structure_setting]()
self.seismicPhase = str(settings.value("phase", "P")) self.seismicPhase = str(settings.value("phase", "P"))
self.dispComponent = str(settings.value("plotting/dispComponent", "Z"))
if settings.value("data/dataRoot", None) is None: if settings.value("data/dataRoot", None) is None:
dirname = QFileDialog().getExistingDirectory( dirname = QFileDialog().getExistingDirectory(
caption='Choose data root ...') caption='Choose data root ...')
@ -118,9 +120,6 @@ class MainWindow(QMainWindow):
self.autopicks = {} self.autopicks = {}
self.loc = False self.loc = False
# UI has to be set up before(!) children widgets are about to show up
self.setupUi()
# initialize event data # initialize event data
if self.recentfiles: if self.recentfiles:
lastEvent = self.getLastEvent() lastEvent = self.getLastEvent()
@ -129,18 +128,7 @@ class MainWindow(QMainWindow):
self.data = Data(self) self.data = Data(self)
self.autodata = Data(self) self.autodata = Data(self)
# load and display waveform data
self.dirty = False self.dirty = False
self.load_data()
finv = settings.value("inventoryFile", None)
if finv is not None:
self._metadata = read_metadata(finv)
else:
self._metadata = None
if self.loadWaveformData():
self.updateFilterOptions()
else:
sys.exit(0)
def setupUi(self): def setupUi(self):
@ -201,7 +189,7 @@ class MainWindow(QMainWindow):
n_icon.addPixmap(QPixmap(':/icons/key_N.png')) n_icon.addPixmap(QPixmap(':/icons/key_N.png'))
e_icon = QIcon() e_icon = QIcon()
e_icon.addPixmap(QPixmap(':/icons/key_E.png')) e_icon.addPixmap(QPixmap(':/icons/key_E.png'))
auto_icon = QIcon() auto_icon = QIcon(':/icons/autopick_button.png')
auto_icon.addPixmap(QPixmap(':/icons/autopick_button.png')) auto_icon.addPixmap(QPixmap(':/icons/autopick_button.png'))
locate_icon = QIcon() locate_icon = QIcon()
locate_icon.addPixmap(QPixmap(':/icons/locate_button.png')) locate_icon.addPixmap(QPixmap(':/icons/locate_button.png'))
@ -211,36 +199,43 @@ class MainWindow(QMainWindow):
self.createNewEvent, self.createNewEvent,
QKeySequence.New, newIcon, QKeySequence.New, newIcon,
"Create a new event.") "Create a new event.")
openmanualpicksaction = self.createAction(self, "Load &picks ...", self.openmanualpicksaction = self.createAction(self, "Load &picks ...",
self.load_data, self.load_data,
QKeySequence.Open, QKeySequence.Open,
manupicksicon, manupicksicon,
"Load manual picks for " "Load manual picks for "
"the displayed event.") "the displayed event.")
openmanualpicksaction.setData(None) self.openmanualpicksaction.setEnabled(False)
openautopicksaction = self.createAction(self, "Load &automatic picks " self.openmanualpicksaction.setData(None)
self.openautopicksaction = self.createAction(self, "Load &automatic picks "
"...", "...",
self.load_autopicks, self.load_autopicks,
"Ctrl+A", "Ctrl+A",
autopicksicon, autopicksicon,
"Load automatic picks " "Load automatic picks "
"for the displayed event.") "for the displayed event.")
openautopicksaction.setData(None) self.openautopicksaction.setEnabled(False)
self.openautopicksaction.setData(None)
loadlocationaction = self.createAction(self, "Load &location ...", loadlocationaction = self.createAction(self, "Load &location ...",
self.load_loc, "Ctrl+L", self.load_loc, "Ctrl+L",
locactionicon, locactionicon,
"Load location information on " "Load location information on "
"the displayed event.") "the displayed event.")
loadpilotevent = self.createAction(self, "Load PILOT &event ...", self.loadpilotevent = self.createAction(self, "Load PILOT &event ...",
self.load_pilotevent, "Ctrl+E", self.load_pilotevent, "Ctrl+E",
loadpiloticon, loadpiloticon,
"Load PILOT event from information " "Load PILOT event from information "
"MatLab binary collections (created" "MatLab binary collections (created"
" in former MatLab based version).") " in former MatLab based version).")
saveEventAction = self.createAction(self, "&Save event ...", self.loadpilotevent.setEnabled(False)
self.saveEventAction = self.createAction(self, "&Save event ...",
self.saveData, QKeySequence.Save, self.saveData, QKeySequence.Save,
saveIcon, "Save actual event data.") saveIcon, "Save actual event data.")
self.saveEventAction.setEnabled(False)
openWFDataAction = self.createAction(self, "Open &waveforms ...", openWFDataAction = self.createAction(self, "Open &waveforms ...",
self.loadWaveformData, self.loadWaveformData,
"Ctrl+W", QIcon(":/wfIcon.png"), "Ctrl+W", QIcon(":/wfIcon.png"),
@ -279,6 +274,8 @@ class MainWindow(QMainWindow):
"manual and " "manual and "
"automatic pick " "automatic pick "
"data.", False) "data.", False)
self.compare_action.setEnabled(False)
printAction = self.createAction(self, "&Print event ...", printAction = self.createAction(self, "&Print event ...",
self.show_event_information, QKeySequence.Print, self.show_event_information, QKeySequence.Print,
print_icon, print_icon,
@ -289,8 +286,8 @@ class MainWindow(QMainWindow):
homepage (internet connection available), homepage (internet connection available),
or shipped documentation files.""") or shipped documentation files.""")
self.fileMenu = self.menuBar().addMenu('&File') self.fileMenu = self.menuBar().addMenu('&File')
self.fileMenuActions = (newEventAction, openmanualpicksaction, self.fileMenuActions = (newEventAction, self.openmanualpicksaction,
saveEventAction, openWFDataAction, None, self.saveEventAction, openWFDataAction, None,
prefsEventAction, quitAction) prefsEventAction, quitAction)
self.fileMenu.aboutToShow.connect(self.updateFileMenu) self.fileMenu.aboutToShow.connect(self.updateFileMenu)
self.updateFileMenu() self.updateFileMenu()
@ -306,9 +303,9 @@ class MainWindow(QMainWindow):
self.addActions(self.helpMenu, helpActions) self.addActions(self.helpMenu, helpActions)
fileToolBar = self.addToolBar("FileTools") fileToolBar = self.addToolBar("FileTools")
fileToolActions = (newEventAction, openmanualpicksaction, fileToolActions = (newEventAction, self.openmanualpicksaction,
openautopicksaction, loadlocationaction, self.openautopicksaction, loadlocationaction,
loadpilotevent, saveEventAction) self.loadpilotevent, self.saveEventAction)
fileToolBar.setObjectName("FileTools") fileToolBar.setObjectName("FileTools")
self.addActions(fileToolBar, fileToolActions) self.addActions(fileToolBar, fileToolActions)
@ -322,53 +319,57 @@ class MainWindow(QMainWindow):
componentGroup = QActionGroup(self) componentGroup = QActionGroup(self)
componentGroup.setExclusive(True) componentGroup.setExclusive(True)
z_action = self.createAction(parent=componentGroup, text='Z', self.z_action = self.createAction(parent=componentGroup, text='Z',
slot=self.plotZ, shortcut='Alt+Z', slot=self.plotZ, shortcut='Alt+Z',
icon=z_icon, tip='Display the vertical (Z)' icon=z_icon, tip='Display the vertical (Z)'
' component.', ' component.',
checkable=True) checkable=True)
z_action.setChecked(True) self.z_action.setChecked(True)
self.z_action.setEnabled(False)
n_action = self.createAction(parent=componentGroup, text='N', self.n_action = self.createAction(parent=componentGroup, text='N',
slot=self.plotN, shortcut='Alt+N', slot=self.plotN, shortcut='Alt+N',
icon=n_icon, icon=n_icon,
tip='Display the north-south (N) ' tip='Display the north-south (N) '
'component.', checkable=True) 'component.', checkable=True)
self.n_action.setEnabled(False)
e_action = self.createAction(parent=componentGroup, text='E', self.e_action = self.createAction(parent=componentGroup, text='E',
slot=self.plotE, shortcut='Alt+E', slot=self.plotE, shortcut='Alt+E',
icon=e_icon, icon=e_icon,
tip='Display the east-west (E) component.', tip='Display the east-west (E) component.',
checkable=True) checkable=True)
self.e_action.setEnabled(False)
componentToolBar = self.addToolBar("ComponentSelection") componentToolBar = self.addToolBar("ComponentSelection")
componentActions = (z_action, n_action, e_action) componentActions = (self.z_action, self.n_action, self.e_action)
componentToolBar.setObjectName("PhaseTools") componentToolBar.setObjectName("PhaseTools")
self.addActions(componentToolBar, componentActions) self.addActions(componentToolBar, componentActions)
auto_pick = self.createAction(parent=self, text='autoPick', self.auto_pick = self.createAction(parent=self, text='autoPick',
slot=self.autoPick, shortcut='Alt+Ctrl+A', slot=self.autoPick, shortcut='Alt+Ctrl+A',
icon=auto_icon, tip='Automatically pick' icon=auto_icon, tip='Automatically pick'
' the entire dataset' ' the displayed waveforms.')
' displayed!') self.auto_pick.setEnabled(False)
autoPickToolBar = self.addToolBar("autoPyLoT") autoPickToolBar = self.addToolBar("autoPyLoT")
autoPickActions = (auto_pick, self.compare_action) autoPickActions = (self.auto_pick, self.compare_action)
self.addActions(autoPickToolBar, autoPickActions) self.addActions(autoPickToolBar, autoPickActions)
# pickToolBar = self.addToolBar("PickTools") # pickToolBar = self.addToolBar("PickTools")
# pickToolActions = (selectStation, ) # pickToolActions = (selectStation, )
# pickToolBar.setObjectName("PickTools") # pickToolBar.setObjectName("PickTools")
# self.addActions(pickToolBar, pickToolActions) # self.addActions(pickToolBar, pickToolActions)
locateEvent = self.createAction(parent=self, text='locate the event', self.locateEvent = self.createAction(parent=self, text='locate the event',
slot=self.locate_event, slot=self.locate_event,
shortcut='Alt+Ctrl+L', shortcut='Alt+Ctrl+L',
icon=locate_icon, icon=locate_icon,
tip='Locate the event using ' tip='Locate the event using '
'the displayed manual arrivals.') 'the displayed manual arrivals.')
self.locateEvent.setEnabled(False)
locationToolBar = self.addToolBar("LocationTools") locationToolBar = self.addToolBar("LocationTools")
locationToolActions = (locateEvent,) locationToolActions = (self.locateEvent,)
locationToolBar.setObjectName("LocationTools") locationToolBar.setObjectName("LocationTools")
self.addActions(locationToolBar, locationToolActions) self.addActions(locationToolBar, locationToolActions)
@ -691,6 +692,14 @@ class MainWindow(QMainWindow):
else: else:
ans = False ans = False
self._stime = full_range(self.get_data().getWFData())[0] self._stime = full_range(self.get_data().getWFData())[0]
self.auto_pick.setEnabled(True)
self.z_action.setEnabled(True)
self.e_action.setEnabled(True)
self.n_action.setEnabled(True)
self.openmanualpicksaction.setEnabled(True)
self.openautopicksaction.setEnabled(True)
self.loadpilotevent.setEnabled(True)
self.saveEventAction.setEnabled(True)
if ans: if ans:
self.plotWaveformData() self.plotWaveformData()
return ans return ans
@ -837,6 +846,7 @@ class MainWindow(QMainWindow):
else: else:
self.update_status('picks discarded ({0})'.format(station)) self.update_status('picks discarded ({0})'.format(station))
if not self.get_loc_flag() and self.check4Loc(): if not self.get_loc_flag() and self.check4Loc():
self.locateEvent.setEnabled(True)
self.set_loc_flag(True) self.set_loc_flag(True)
elif self.get_loc_flag() and not self.check4Loc(): elif self.get_loc_flag() and not self.check4Loc():
self.set_loc_flag(False) self.set_loc_flag(False)
@ -1075,7 +1085,7 @@ class MainWindow(QMainWindow):
return None return None
def check4Loc(self): def check4Loc(self):
return self.picksNum() > 4 return self.picksNum() >= 4
def check4Comparison(self): def check4Comparison(self):
mpicks = self.getPicks() mpicks = self.getPicks()