code clean-up following several conventions

This commit is contained in:
Sebastian Wehling-Benatelli 2015-06-11 10:07:21 +02:00
parent 3d8bea8f7e
commit 546e919dc9
10 changed files with 140 additions and 136 deletions

View File

@ -43,13 +43,13 @@ import icons_rc
# Version information # Version information
__version__ = _getVersionString() __version__ = _getVersionString()
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
closing = Signal() closing = Signal()
def __init__(self, parent=None): def __init__(self, parent=None):
super(MainWindow, self).__init__(parent) super(MainWindow, self).__init__(parent)
self.createAction = createAction self.createAction = createAction
self.dirty = False self.dirty = False
settings = QSettings() settings = QSettings()
@ -58,7 +58,9 @@ class MainWindow(QMainWindow):
settings.setValue("user/FullName", fulluser) settings.setValue("user/FullName", fulluser)
settings.setValue("user/Login", getLogin()) settings.setValue("user/Login", getLogin())
if settings.value("agency_id", None) is None: if settings.value("agency_id", None) is None:
agency = QInputDialog.getText(self, "Enter authority name (e.g. BUG):", "Authority") agency = QInputDialog.getText(self,
"Enter authority name (e.g. BUG):",
"Authority")
settings.setValue("agency_id", agency) settings.setValue("agency_id", agency)
self.recentEvents = settings.value("data/recentEvents", []) self.recentEvents = settings.value("data/recentEvents", [])
self.fnames = None self.fnames = None
@ -91,7 +93,6 @@ class MainWindow(QMainWindow):
self.loadData() self.loadData()
self.updateFilterOptions() self.updateFilterOptions()
def setupUi(self): def setupUi(self):
try: try:
@ -159,7 +160,8 @@ class MainWindow(QMainWindow):
QCoreApplication.instance().quit, QCoreApplication.instance().quit,
QKeySequence.Close, quitIcon, QKeySequence.Close, quitIcon,
"Close event and quit PyLoT") "Close event and quit PyLoT")
self.filterAction = self.createAction(self, "&Filter ...", self.filterWaveformData, self.filterAction = self.createAction(self, "&Filter ...",
self.filterWaveformData,
"Ctrl+F", QIcon(":/filter.png"), "Ctrl+F", QIcon(":/filter.png"),
"""Toggle un-/filtered waveforms """Toggle un-/filtered waveforms
to be displayed, according to the to be displayed, according to the
@ -168,10 +170,12 @@ class MainWindow(QMainWindow):
self.adjustFilterOptions, self.adjustFilterOptions,
"Alt+F", QIcon(None), "Alt+F", QIcon(None),
"""Adjust filter parameters.""") """Adjust filter parameters.""")
self.selectPAction = self.createAction(self, "&P", self.alterPhase, "Alt+P", self.selectPAction = self.createAction(self, "&P", self.alterPhase,
"Alt+P",
p_icon, p_icon,
"Toggle P phase.", True) "Toggle P phase.", True)
self.selectSAction = self.createAction(self, "&S", self.alterPhase, "Alt+S", self.selectSAction = self.createAction(self, "&S", self.alterPhase,
"Alt+S",
s_icon, s_icon,
"Toggle S phase", True) "Toggle S phase", True)
printAction = self.createAction(self, "&Print event ...", printAction = self.createAction(self, "&Print event ...",
@ -197,7 +201,7 @@ class MainWindow(QMainWindow):
self.addActions(self.editMenu, editActions) self.addActions(self.editMenu, editActions)
self.helpMenu = self.menuBar().addMenu('&Help') self.helpMenu = self.menuBar().addMenu('&Help')
helpActions = (helpAction, ) helpActions = (helpAction,)
self.addActions(self.helpMenu, helpActions) self.addActions(self.helpMenu, helpActions)
fileToolBar = self.addToolBar("FileTools") fileToolBar = self.addToolBar("FileTools")
@ -342,7 +346,8 @@ class MainWindow(QMainWindow):
def getPlotWidget(self): def getPlotWidget(self):
return self.DataPlot return self.DataPlot
def getWFID(self, gui_event): @staticmethod
def getWFID(gui_event):
ycoord = gui_event.ydata ycoord = gui_event.ydata
@ -383,11 +388,12 @@ class MainWindow(QMainWindow):
def filterWaveformData(self): def filterWaveformData(self):
if self.getData(): if self.getData():
def hasfreq(kwargs): def hasfreq(kwdict):
for key in kwargs.keys(): for key in kwdict.keys():
if not key.startswith('freq'): if not key.startswith('freq'):
return True return True
return False return False
if self.filterAction.isChecked(): if self.filterAction.isChecked():
kwargs = {} kwargs = {}
freq = self.getFilterOptions().getFreq() freq = self.getFilterOptions().getFreq()
@ -430,11 +436,11 @@ class MainWindow(QMainWindow):
else: else:
self.getFilters()[seismicPhase] = filterOptions self.getFilters()[seismicPhase] = filterOptions
def updateFilterOptions(self): def updateFilterOptions(self):
try: try:
settings = QSettings() settings = QSettings()
if settings.value("filterdefaults", None) is None and not self.getFilters(): if settings.value("filterdefaults",
None) is None and not self.getFilters():
for key, value in FILTERDEFAULTS.iteritems(): for key, value in FILTERDEFAULTS.iteritems():
self.setFilterOptions(FilterOptions(**value), key) self.setFilterOptions(FilterOptions(**value), key)
elif settings.value("filterdefaults", None) is not None: elif settings.value("filterdefaults", None) is not None:
@ -446,7 +452,9 @@ class MainWindow(QMainWindow):
emsg.showMessage('Error: {0}'.format(e)) emsg.showMessage('Error: {0}'.format(e))
else: else:
self.updateStatus('Filter loaded ... ' self.updateStatus('Filter loaded ... '
'[{0}: {1} Hz]'.format(self.getFilterOptions().getFilterType(), self.getFilterOptions().getFreq())) '[{0}: {1} Hz]'.format(
self.getFilterOptions().getFilterType(),
self.getFilterOptions().getFreq()))
if self.filterAction.isChecked(): if self.filterAction.isChecked():
self.filterWaveformData() self.filterWaveformData()
@ -479,7 +487,6 @@ class MainWindow(QMainWindow):
else: else:
print 'picks not saved and closed dialog' print 'picks not saved and closed dialog'
def updateStatus(self, message): def updateStatus(self, message):
self.statusBar().showMessage(message, 5000) self.statusBar().showMessage(message, 5000)
if self.getData() is not None: if self.getData() is not None:
@ -493,7 +500,6 @@ class MainWindow(QMainWindow):
"PyLoT - seismic processing the python way[*]") "PyLoT - seismic processing the python way[*]")
self.setWindowModified(self.dirty) self.setWindowModified(self.dirty)
def printEvent(self): def printEvent(self):
pass pass

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: utf-8 # encoding: utf-8
''' """
makePyLoT -- build and install PyLoT makePyLoT -- build and install PyLoT
makePyLoT is a python make file in order to establish the folder structure and makePyLoT is a python make file in order to establish the folder structure and
@ -20,7 +20,7 @@ It defines
:contact: sebastian.wehling@rub.de :contact: sebastian.wehling@rub.de
updated: Updated updated: Updated
''' """
import glob import glob
import os import os
@ -38,16 +38,21 @@ DEBUG = 0
TESTRUN = 0 TESTRUN = 0
PROFILE = 0 PROFILE = 0
class CLIError(Exception): class CLIError(Exception):
'''Generic exception to raise and log different fatal errors.''' """Generic exception to raise and log different fatal errors."""
def __init__(self, msg): def __init__(self, msg):
super(CLIError).__init__(type(self)) super(CLIError).__init__(type(self))
self.msg = "E: %s" % msg self.msg = "E: %s" % msg
def __str__(self): def __str__(self):
return self.msg return self.msg
def __unicode__(self): def __unicode__(self):
return self.msg return self.msg
def main(argv=None): # IGNORE:C0111 def main(argv=None): # IGNORE:C0111
'''Command line options.''' '''Command line options.'''
@ -59,7 +64,8 @@ def main(argv=None): # IGNORE:C0111
program_name = os.path.basename(sys.argv[0]) program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__ program_version = "v%s" % __version__
program_build_date = str(__updated__) program_build_date = str(__updated__)
program_version_message = '%makePyLoT %s (%s)' % (program_version, program_build_date) program_version_message = 'makePyLoT %s (%s)' % (
program_version, program_build_date)
program_shortdesc = __import__('__main__').__doc__.split("\n")[1] program_shortdesc = __import__('__main__').__doc__.split("\n")[1]
program_license = '''%s program_license = '''%s
@ -77,12 +83,19 @@ USAGE
try: try:
# Setup argument parser # Setup argument parser
parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter) parser = ArgumentParser(description=program_license,
parser.add_argument("-b", "--build", dest="build", action="store_true", help="build PyLoT") formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level") parser.add_argument("-b", "--build", dest="build", action="store_true",
parser.add_argument("-i", "--install", dest="install", action="store_true", help="install PyLoT on the system") help="build PyLoT")
parser.add_argument("-d", "--directory", dest="directory", help="installation directory", metavar="RE" ) parser.add_argument("-v", "--verbose", dest="verbose", action="count",
parser.add_argument('-V', '--version', action='version', version=program_version_message) help="set verbosity level")
parser.add_argument("-i", "--install", dest="install",
action="store_true",
help="install PyLoT on the system")
parser.add_argument("-d", "--directory", dest="directory",
help="installation directory", metavar="RE")
parser.add_argument('-V', '--version', action='version',
version=program_version_message)
# Process arguments # Process arguments
args = parser.parse_args() args = parser.parse_args()
@ -112,12 +125,13 @@ USAGE
return 0 return 0
except Exception, e: except Exception, e:
if DEBUG or TESTRUN: if DEBUG or TESTRUN:
raise(e) raise e
indent = len(program_name) * " " indent = len(program_name) * " "
sys.stderr.write(program_name + ": " + repr(e) + "\n") sys.stderr.write(program_name + ": " + repr(e) + "\n")
sys.stderr.write(indent + " for help use --help") sys.stderr.write(indent + " for help use --help")
return 2 return 2
def buildPyLoT(verbosity=None): def buildPyLoT(verbosity=None):
system = sys.platform system = sys.platform
if verbosity > 1: if verbosity > 1:
@ -127,7 +141,8 @@ def buildPyLoT(verbosity=None):
).format(system, os.getcwd()) ).format(system, os.getcwd())
print msg print msg
if system.startswith(('win', 'microsoft')): if system.startswith(('win', 'microsoft')):
raise CLIError("building on Windows system not tested yet; implementation pending") raise CLIError(
"building on Windows system not tested yet; implementation pending")
elif system == 'darwin': elif system == 'darwin':
# create a symbolic link to the desired python interpreter in order to # create a symbolic link to the desired python interpreter in order to
# display the right application name # display the right application name
@ -141,19 +156,23 @@ def buildPyLoT(verbosity=None):
def installPyLoT(verbosity=None): def installPyLoT(verbosity=None):
pass pass
def cleanUp(verbosity=None): def cleanUp(verbosity=None):
pass pass
if __name__ == "__main__": if __name__ == "__main__":
if DEBUG: if DEBUG:
sys.argv.append("-h") sys.argv.append("-h")
sys.argv.append("-v") sys.argv.append("-v")
if TESTRUN: if TESTRUN:
import doctest import doctest
doctest.testmod() doctest.testmod()
if PROFILE: if PROFILE:
import cProfile import cProfile
import pstats import pstats
profile_filename = 'makePyLoT_profile.txt' profile_filename = 'makePyLoT_profile.txt'
cProfile.run('main()', profile_filename) cProfile.run('main()', profile_filename)
statsfile = open("profile_stats.txt", "wb") statsfile = open("profile_stats.txt", "wb")

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#-------------------------------------------------------- # --------------------------------------------------------
# Purpose: Convience imports for PyLoT # Purpose: Convience imports for PyLoT
# #
''' '''

View File

@ -161,7 +161,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
index1 = [] index1 = []
i = 0 i = 0
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]): for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
i = i + 1 i += 1
if xraw[j - 1] <= 0 and xraw[j] >= 0: if xraw[j - 1] <= 0 and xraw[j] >= 0:
zc1.append(t[ipick][i]) zc1.append(t[ipick][i])
index1.append(i) index1.append(i)
@ -196,7 +196,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
index2 = [] index2 = []
i = 0 i = 0
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]): for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
i = i + 1 i += 1
if xfilt[j - 1] <= 0 and xfilt[j] >= 0: if xfilt[j - 1] <= 0 and xfilt[j] >= 0:
zc2.append(t[ipick][i]) zc2.append(t[ipick][i])
index2.append(i) index2.append(i)

View File

@ -2,5 +2,3 @@ from pylot.core.read.inputs import AutoPickParameter, FilterOptions
from pylot.core.read.io import readPILOTEvent from pylot.core.read.io import readPILOTEvent
from pylot.core.read.data import GenericDataStructure, SeiscompDataStructure, \ from pylot.core.read.data import GenericDataStructure, SeiscompDataStructure, \
PilotDataStructure, Data PilotDataStructure, Data

View File

@ -124,21 +124,11 @@ class AutoPickParameter(object):
for key, value in self.__parameter.iteritems(): for key, value in self.__parameter.iteritems():
yield key, value yield key, value
def hasParam(self, *args): def hasParam(self, parameter):
if self.__parameter.has_key(parameter):
def test(param):
try:
self.__parameter[param]
return True return True
except KeyError:
return False return False
try:
for param in args:
return test(param)
except TypeError:
return test(args)
def getParam(self, *args): def getParam(self, *args):
try: try:
for param in args: for param in args:
@ -157,7 +147,8 @@ class AutoPickParameter(object):
self.__setitem__(param, value) self.__setitem__(param, value)
print self print self
def _printParameterError(self, errmsg): @staticmethod
def _printParameterError(errmsg):
print 'ParameterError:\n non-existent parameter %s' % errmsg print 'ParameterError:\n non-existent parameter %s' % errmsg
def export2File(self, fnout): def export2File(self, fnout):

View File

@ -9,8 +9,10 @@ Created on Thu Mar 20 09:47:04 2014
class OptionsError(Exception): class OptionsError(Exception):
pass pass
class FormatError(Exception): class FormatError(Exception):
pass pass
class DatastructureError(Exception): class DatastructureError(Exception):
pass pass

View File

@ -8,5 +8,5 @@ Created on Wed Jan 26 17:47:25 2015
from pylot.core.read import SeiscompDataStructure, PilotDataStructure from pylot.core.read import SeiscompDataStructure, PilotDataStructure
DATASTRUCTURE = {'PILOT':PilotDataStructure, 'SeisComP':SeiscompDataStructure, DATASTRUCTURE = {'PILOT': PilotDataStructure, 'SeisComP': SeiscompDataStructure,
None:None} None: None}

View File

@ -31,7 +31,7 @@
# #
# include RELEASE-VERSION # include RELEASE-VERSION
__all__ = ("get_git_version") __all__ = "get_git_version"
# NO IMPORTS FROM PYLOT IN THIS FILE! (file gets used at installation time) # NO IMPORTS FROM PYLOT IN THIS FILE! (file gets used at installation time)
import os import os

View File

@ -16,9 +16,9 @@ from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvas from matplotlib.backends.backend_qt4agg import FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
from matplotlib.widgets import MultiCursor from matplotlib.widgets import MultiCursor
from PySide.QtGui import QAction, QApplication,QComboBox, QDateTimeEdit,\ from PySide.QtGui import QAction, QApplication, QComboBox, QDateTimeEdit, \
QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, QGridLayout,\ QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, QGridLayout, \
QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, QPixmap, QSpinBox,\ QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, QPixmap, QSpinBox, \
QTabWidget, QToolBar, QVBoxLayout, QWidget QTabWidget, QToolBar, QVBoxLayout, QWidget
from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
from PySide.QtWebKit import QWebView from PySide.QtWebKit import QWebView
@ -48,8 +48,8 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
action.setCheckable(True) action.setCheckable(True)
return action return action
class MPLWidget(FigureCanvas):
class MPLWidget(FigureCanvas):
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'): def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
self._parent = None self._parent = None
@ -65,7 +65,8 @@ class MPLWidget(FigureCanvas):
# initialize super class # initialize super class
FigureCanvas.__init__(self, self.figure) FigureCanvas.__init__(self, self.figure)
# add an cursor for station selection # add an cursor for station selection
self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,), horizOn=True, self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,),
horizOn=True,
color='m', lw=1) color='m', lw=1)
# update labels of the entire widget # update labels of the entire widget
self.updateWidget(xlabel, ylabel, title) self.updateWidget(xlabel, ylabel, title)
@ -126,7 +127,6 @@ class MPLWidget(FigureCanvas):
self.axes.set_xlabel(text) self.axes.set_xlabel(text)
self.draw() self.draw()
def updateYLabel(self, text): def updateYLabel(self, text):
self.axes.set_ylabel(text) self.axes.set_ylabel(text)
self.draw() self.draw()
@ -142,12 +142,12 @@ class MPLWidget(FigureCanvas):
def insertLabel(self, pos, text): def insertLabel(self, pos, text):
pos = pos / max(self.axes.ylim) pos = pos / max(self.axes.ylim)
axann = self.axes.annotate(text, xy=(.03, pos), xycoords='axes fraction') axann = self.axes.annotate(text, xy=(.03, pos),
xycoords='axes fraction')
axann.set_bbox(dict(facecolor='lightgrey', alpha=.6)) axann.set_bbox(dict(facecolor='lightgrey', alpha=.6))
class multiComponentPlot(FigureCanvas): class multiComponentPlot(FigureCanvas):
def __init__(self, data, parent=None, components='ZNE'): def __init__(self, data, parent=None, components='ZNE'):
self.data = data self.data = data
@ -211,7 +211,7 @@ class multiComponentPlot(FigureCanvas):
# plot individual component traces in separate subplots # plot individual component traces in separate subplots
for n, comp in enumerate(components): for n, comp in enumerate(components):
nsub = '{0}1{1}'.format(self.noc, n+1) nsub = '{0}1{1}'.format(self.noc, n + 1)
if n >= 1: if n >= 1:
subax = self.figure.add_subplot(nsub, sharex=self.axesdict[0]) subax = self.figure.add_subplot(nsub, sharex=self.axesdict[0])
else: else:
@ -239,7 +239,6 @@ class multiComponentPlot(FigureCanvas):
class PickDlg(QDialog): class PickDlg(QDialog):
def __init__(self, parent=None, data=None, station=None, rotate=False): def __init__(self, parent=None, data=None, station=None, rotate=False):
super(PickDlg, self).__init__(parent) super(PickDlg, self).__init__(parent)
@ -275,8 +274,8 @@ class PickDlg(QDialog):
# plot data # plot data
self.getPlotWidget().plotWFData(wfdata=self.getWFData(), self.getPlotWidget().plotWFData(wfdata=self.getWFData(),
title=self.getStation()) title=self.getStation())
self.limits = {'xlims' : self.getPlotWidget().axes.get_xlim(), self.limits = {'xlims': self.getPlotWidget().axes.get_xlim(),
'ylims' : self.getPlotWidget().axes.get_ylim()} 'ylims': self.getPlotWidget().axes.get_ylim()}
self.apd = self.getWFData() self.apd = self.getWFData()
# set plot labels # set plot labels
@ -420,9 +419,10 @@ class PickDlg(QDialog):
def selectWFData(self, channel): def selectWFData(self, channel):
component = channel[-1].upper() component = channel[-1].upper()
wfdata = Stream() wfdata = Stream()
def selectTrace(trace, components):
if trace.stats.channel[-1].upper() in components: def selectTrace(tr, components):
return trace if tr.stats.channel[-1].upper() in components:
return tr
if component == 'E' or component == 'N': if component == 'E' or component == 'N':
for trace in self.getWFData(): for trace in self.getWFData():
@ -462,10 +462,10 @@ class PickDlg(QDialog):
# see also Diehl et al. 2009 # see also Diehl et al. 2009
res_wins = { res_wins = {
'HRW' : 2., 'HRW': 2.,
'MRW' : 5., 'MRW': 5.,
'LRW' : 10., 'LRW': 10.,
'VLRW' : 15. 'VLRW': 15.
} }
result = getSNR(wfdata, (5., .5, 2.), ini_pick) result = getSNR(wfdata, (5., .5, 2.), ini_pick)
@ -512,12 +512,7 @@ class PickDlg(QDialog):
phase = self.selectPhase.currentText() phase = self.selectPhase.currentText()
# save pick times for actual phase # save pick times for actual phase
phasepicks = {} phasepicks = {'epp': epp, 'lpp': lpp, 'mpp': pick, 'spe': spe}
phasepicks['epp'] = epp
phasepicks['lpp'] = lpp
phasepicks['mpp'] = pick
phasepicks['spe'] = spe
try: try:
oldphasepick = self.picks[phase] oldphasepick = self.picks[phase]
@ -570,10 +565,10 @@ class PickDlg(QDialog):
lpp = picks['lpp'] lpp = picks['lpp']
spe = picks['spe'] spe = picks['spe']
ax.fill_between([epp, lpp],ylims[0], ylims[1], alpha=.5, color='c') ax.fill_between([epp, lpp], ylims[0], ylims[1], alpha=.5, color='c')
ax.plot([mpp-spe, mpp-spe], ylims, 'c--', ax.plot([mpp - spe, mpp - spe], ylims, 'c--',
[mpp, mpp], ylims, 'b-', [mpp, mpp], ylims, 'b-',
[mpp+spe, mpp+spe], ylims, 'c--') [mpp + spe, mpp + spe], ylims, 'c--')
self.getPlotWidget().draw() self.getPlotWidget().draw()
@ -648,7 +643,7 @@ class PickDlg(QDialog):
curr_ylim = widget.axes.get_ylim() curr_ylim = widget.axes.get_ylim()
if gui_event.button == 'up': if gui_event.button == 'up':
scale_factor = 1/factor scale_factor = 1 / factor
elif gui_event.button == 'down': elif gui_event.button == 'down':
# deal with zoom out # deal with zoom out
scale_factor = factor scale_factor = factor
@ -682,8 +677,8 @@ class PickDlg(QDialog):
self.apply() self.apply()
QDialog.accept(self) QDialog.accept(self)
class PropertiesDlg(QDialog):
class PropertiesDlg(QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
super(PropertiesDlg, self).__init__(parent) super(PropertiesDlg, self).__init__(parent)
@ -707,7 +702,8 @@ class PropertiesDlg(QDialog):
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
self.buttonBox.button(QDialogButtonBox.Apply).clicked.connect(self.apply) self.buttonBox.button(QDialogButtonBox.Apply).clicked.connect(
self.apply)
def accept(self, *args, **kwargs): def accept(self, *args, **kwargs):
self.apply() self.apply()
@ -728,7 +724,6 @@ class PropertiesDlg(QDialog):
class PropTab(QWidget): class PropTab(QWidget):
def __init__(self, parent=None): def __init__(self, parent=None):
super(PropTab, self).__init__(parent) super(PropTab, self).__init__(parent)
@ -737,7 +732,6 @@ class PropTab(QWidget):
class InputsTab(PropTab): class InputsTab(PropTab):
def __init__(self, parent): def __init__(self, parent):
super(InputsTab, self).__init__(parent) super(InputsTab, self).__init__(parent)
@ -775,15 +769,13 @@ class InputsTab(PropTab):
self.setLayout(layout) self.setLayout(layout)
def getValues(self): def getValues(self):
values = {} values = {"data/dataRoot": self.dataDirEdit.text(),
values["data/dataRoot"] = self.dataDirEdit.text() "user/FullName": self.fullNameEdit.text(),
values["user/FullName"] = self.fullNameEdit.text() "data/Structure": self.structureSelect.currentText()}
values["data/Structure"] = self.structureSelect.currentText()
return values return values
class OutputsTab(PropTab): class OutputsTab(PropTab):
def __init__(self, parent=None): def __init__(self, parent=None):
super(OutputsTab, self).__init__(parent) super(OutputsTab, self).__init__(parent)
@ -808,12 +800,11 @@ class OutputsTab(PropTab):
self.setLayout(layout) self.setLayout(layout)
def getValues(self): def getValues(self):
values = {} values = {"output/Format": self.eventOutputComboBox.currentText()}
values["output/Format"] = self.eventOutputComboBox.currentText()
return values return values
class PhasesTab(PropTab):
class PhasesTab(PropTab):
def __init__(self, parent=None): def __init__(self, parent=None):
super(PhasesTab, self).__init__(parent) super(PhasesTab, self).__init__(parent)
@ -821,7 +812,6 @@ class PhasesTab(PropTab):
class GraphicsTab(PropTab): class GraphicsTab(PropTab):
def __init__(self, parent=None): def __init__(self, parent=None):
super(GraphicsTab, self).__init__(parent) super(GraphicsTab, self).__init__(parent)
@ -850,13 +840,12 @@ class NewEventDlg(QDialog):
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
def getValues(self): def getValues(self):
return {'origintime' : self.eventTimeEdit.dateTime().toPython(), return {'origintime': self.eventTimeEdit.dateTime().toPython(),
'latitude' : self.latEdit.text(), 'latitude': self.latEdit.text(),
'longitude' : self.lonEdit.text(), 'longitude': self.lonEdit.text(),
'depth' : self.depEdit.text()} 'depth': self.depEdit.text()}
def setupUI(self): def setupUI(self):
# create widget objects # create widget objects
timeLabel = QLabel() timeLabel = QLabel()
timeLabel.setText("Select time: ") timeLabel.setText("Select time: ")
@ -887,8 +876,8 @@ class NewEventDlg(QDialog):
self.setLayout(grid) self.setLayout(grid)
class FilterOptionsDialog(QDialog):
class FilterOptionsDialog(QDialog):
def __init__(self, parent=None, titleString="Filter options", def __init__(self, parent=None, titleString="Filter options",
filterOptions=None): filterOptions=None):
""" """
@ -925,8 +914,10 @@ class FilterOptionsDialog(QDialog):
if _enable: if _enable:
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0]) self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
if self.getFilterOptions().getFilterType() in ['bandpass', 'bandstop']: if self.getFilterOptions().getFilterType() in ['bandpass',
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1]) 'bandstop']:
self.freqmaxSpinBox.setValue(
self.getFilterOptions().getFreq()[1])
else: else:
try: try:
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()) self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq())
@ -963,7 +954,7 @@ class FilterOptionsDialog(QDialog):
self.freqmaxSpinBox.setEnabled(_enable) self.freqmaxSpinBox.setEnabled(_enable)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel) QDialogButtonBox.Cancel)
grid = QGridLayout() grid = QGridLayout()
@ -980,7 +971,6 @@ class FilterOptionsDialog(QDialog):
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
def updateUi(self): def updateUi(self):
_enable = False _enable = False
if self.selectTypeCombo.currentText() not in ['bandpass', 'bandstop']: if self.selectTypeCombo.currentText() not in ['bandpass', 'bandstop']:
@ -993,10 +983,9 @@ class FilterOptionsDialog(QDialog):
self.freqmaxLabel.setEnabled(_enable) self.freqmaxLabel.setEnabled(_enable)
self.freqmaxSpinBox.setEnabled(_enable) self.freqmaxSpinBox.setEnabled(_enable)
self.getFilterOptions().setFilterType(
self.getFilterOptions().setFilterType(self.selectTypeCombo.currentText()) self.selectTypeCombo.currentText())
freq = [] freq = [self.freqminSpinBox.value()]
freq.append(self.freqminSpinBox.value())
if _enable: if _enable:
if self.freqminSpinBox.value() > self.freqmaxSpinBox.value(): if self.freqminSpinBox.value() > self.freqmaxSpinBox.value():
QMessageBox.warning(self, "Value error", QMessageBox.warning(self, "Value error",
@ -1019,7 +1008,6 @@ class FilterOptionsDialog(QDialog):
class LoadDataDlg(QDialog): class LoadDataDlg(QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
super(LoadDataDlg, self).__init__(parent) super(LoadDataDlg, self).__init__(parent)
@ -1027,8 +1015,8 @@ class LoadDataDlg(QDialog):
class HelpForm(QDialog): class HelpForm(QDialog):
def __init__(self, page=QUrl('https://ariadne.geophysik.rub.de/trac/PyLoT'),
def __init__(self, page=QUrl('https://ariadne.geophysik.rub.de/trac/PyLoT'), parent=None): parent=None):
super(HelpForm, self).__init__(parent) super(HelpForm, self).__init__(parent)
self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_DeleteOnClose)
self.setAttribute(Qt.WA_GroupLeader) self.setAttribute(Qt.WA_GroupLeader)