code clean-up following several conventions
This commit is contained in:
parent
3d8bea8f7e
commit
546e919dc9
58
QtPyLoT.py
58
QtPyLoT.py
@ -43,13 +43,13 @@ import icons_rc
|
||||
# Version information
|
||||
__version__ = _getVersionString()
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
closing = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(MainWindow, self).__init__(parent)
|
||||
|
||||
|
||||
self.createAction = createAction
|
||||
self.dirty = False
|
||||
settings = QSettings()
|
||||
@ -58,7 +58,9 @@ class MainWindow(QMainWindow):
|
||||
settings.setValue("user/FullName", fulluser)
|
||||
settings.setValue("user/Login", getLogin())
|
||||
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)
|
||||
self.recentEvents = settings.value("data/recentEvents", [])
|
||||
self.fnames = None
|
||||
@ -91,7 +93,6 @@ class MainWindow(QMainWindow):
|
||||
self.loadData()
|
||||
self.updateFilterOptions()
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
|
||||
try:
|
||||
@ -159,21 +160,24 @@ class MainWindow(QMainWindow):
|
||||
QCoreApplication.instance().quit,
|
||||
QKeySequence.Close, quitIcon,
|
||||
"Close event and quit PyLoT")
|
||||
self.filterAction = self.createAction(self, "&Filter ...", self.filterWaveformData,
|
||||
"Ctrl+F", QIcon(":/filter.png"),
|
||||
"""Toggle un-/filtered waveforms
|
||||
self.filterAction = self.createAction(self, "&Filter ...",
|
||||
self.filterWaveformData,
|
||||
"Ctrl+F", QIcon(":/filter.png"),
|
||||
"""Toggle un-/filtered waveforms
|
||||
to be displayed, according to the
|
||||
desired seismic phase.""", True)
|
||||
filterEditAction = self.createAction(self, "&Filter parameter ...",
|
||||
self.adjustFilterOptions,
|
||||
"Alt+F", QIcon(None),
|
||||
"""Adjust filter parameters.""")
|
||||
self.selectPAction = self.createAction(self, "&P", self.alterPhase, "Alt+P",
|
||||
p_icon,
|
||||
"Toggle P phase.", True)
|
||||
self.selectSAction = self.createAction(self, "&S", self.alterPhase, "Alt+S",
|
||||
s_icon,
|
||||
"Toggle S phase", True)
|
||||
self.selectPAction = self.createAction(self, "&P", self.alterPhase,
|
||||
"Alt+P",
|
||||
p_icon,
|
||||
"Toggle P phase.", True)
|
||||
self.selectSAction = self.createAction(self, "&S", self.alterPhase,
|
||||
"Alt+S",
|
||||
s_icon,
|
||||
"Toggle S phase", True)
|
||||
printAction = self.createAction(self, "&Print event ...",
|
||||
self.printEvent, QKeySequence.Print,
|
||||
print_icon,
|
||||
@ -197,7 +201,7 @@ class MainWindow(QMainWindow):
|
||||
self.addActions(self.editMenu, editActions)
|
||||
|
||||
self.helpMenu = self.menuBar().addMenu('&Help')
|
||||
helpActions = (helpAction, )
|
||||
helpActions = (helpAction,)
|
||||
self.addActions(self.helpMenu, helpActions)
|
||||
|
||||
fileToolBar = self.addToolBar("FileTools")
|
||||
@ -273,8 +277,8 @@ class MainWindow(QMainWindow):
|
||||
filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)"
|
||||
caption = "Open an event file"
|
||||
fname = QFileDialog().getOpenFileName(self,
|
||||
caption=caption,
|
||||
filter=filt)
|
||||
caption=caption,
|
||||
filter=filt)
|
||||
self.fname = fname[0]
|
||||
else:
|
||||
self.fname = unicode(action.data().toString())
|
||||
@ -303,9 +307,9 @@ class MainWindow(QMainWindow):
|
||||
if self.dataStructure:
|
||||
searchPath = self.dataStructure.expandDataPath()
|
||||
fnames = QFileDialog.getOpenFileNames(self,
|
||||
"Select waveform "
|
||||
"files:",
|
||||
dir=searchPath)
|
||||
"Select waveform "
|
||||
"files:",
|
||||
dir=searchPath)
|
||||
self.fnames = fnames[0]
|
||||
|
||||
else:
|
||||
@ -342,7 +346,8 @@ class MainWindow(QMainWindow):
|
||||
def getPlotWidget(self):
|
||||
return self.DataPlot
|
||||
|
||||
def getWFID(self, gui_event):
|
||||
@staticmethod
|
||||
def getWFID(gui_event):
|
||||
|
||||
ycoord = gui_event.ydata
|
||||
|
||||
@ -383,11 +388,12 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def filterWaveformData(self):
|
||||
if self.getData():
|
||||
def hasfreq(kwargs):
|
||||
for key in kwargs.keys():
|
||||
def hasfreq(kwdict):
|
||||
for key in kwdict.keys():
|
||||
if not key.startswith('freq'):
|
||||
return True
|
||||
return False
|
||||
|
||||
if self.filterAction.isChecked():
|
||||
kwargs = {}
|
||||
freq = self.getFilterOptions().getFreq()
|
||||
@ -430,11 +436,11 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
self.getFilters()[seismicPhase] = filterOptions
|
||||
|
||||
|
||||
def updateFilterOptions(self):
|
||||
try:
|
||||
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():
|
||||
self.setFilterOptions(FilterOptions(**value), key)
|
||||
elif settings.value("filterdefaults", None) is not None:
|
||||
@ -446,7 +452,9 @@ class MainWindow(QMainWindow):
|
||||
emsg.showMessage('Error: {0}'.format(e))
|
||||
else:
|
||||
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():
|
||||
self.filterWaveformData()
|
||||
|
||||
@ -479,7 +487,6 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
print 'picks not saved and closed dialog'
|
||||
|
||||
|
||||
def updateStatus(self, message):
|
||||
self.statusBar().showMessage(message, 5000)
|
||||
if self.getData() is not None:
|
||||
@ -493,7 +500,6 @@ class MainWindow(QMainWindow):
|
||||
"PyLoT - seismic processing the python way[*]")
|
||||
self.setWindowModified(self.dirty)
|
||||
|
||||
|
||||
def printEvent(self):
|
||||
pass
|
||||
|
||||
|
69
makePyLoT.py
69
makePyLoT.py
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
'''
|
||||
"""
|
||||
makePyLoT -- build and install PyLoT
|
||||
|
||||
makePyLoT is a python make file in order to establish the folder structure and
|
||||
@ -11,16 +11,16 @@ It defines
|
||||
:method main:
|
||||
|
||||
:author: Sebastian Wehling-Benatelli
|
||||
|
||||
|
||||
:copyright: 2014 MAGS2 EP3 Working Group. All rights reserved.
|
||||
|
||||
|
||||
:license: GNU Lesser General Public License, Version 3
|
||||
(http://www.gnu.org/copyleft/lesser.html)
|
||||
|
||||
:contact: sebastian.wehling@rub.de
|
||||
|
||||
updated: Updated
|
||||
'''
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
@ -38,19 +38,24 @@ DEBUG = 0
|
||||
TESTRUN = 0
|
||||
PROFILE = 0
|
||||
|
||||
|
||||
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):
|
||||
super(CLIError).__init__(type(self))
|
||||
self.msg = "E: %s" % msg
|
||||
|
||||
def __str__(self):
|
||||
return self.msg
|
||||
|
||||
def __unicode__(self):
|
||||
return self.msg
|
||||
|
||||
def main(argv=None): # IGNORE:C0111
|
||||
|
||||
def main(argv=None): # IGNORE:C0111
|
||||
'''Command line options.'''
|
||||
|
||||
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
else:
|
||||
@ -59,16 +64,17 @@ def main(argv=None): # IGNORE:C0111
|
||||
program_name = os.path.basename(sys.argv[0])
|
||||
program_version = "v%s" % __version__
|
||||
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_license = '''%s
|
||||
|
||||
Created by Sebastian Wehling-Benatelli on %s.
|
||||
Copyright 2014 MAGS2 EP3 Working Group. All rights reserved.
|
||||
|
||||
|
||||
GNU Lesser General Public License, Version 3
|
||||
(http://www.gnu.org/copyleft/lesser.html)
|
||||
|
||||
|
||||
Distributed on an "AS IS" basis without warranties
|
||||
or conditions of any kind, either express or implied.
|
||||
|
||||
@ -77,21 +83,28 @@ USAGE
|
||||
|
||||
try:
|
||||
# Setup argument parser
|
||||
parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter)
|
||||
parser.add_argument("-b", "--build", dest="build", action="store_true", help="build PyLoT")
|
||||
parser.add_argument("-v", "--verbose", dest="verbose", action="count", 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)
|
||||
|
||||
parser = ArgumentParser(description=program_license,
|
||||
formatter_class=RawDescriptionHelpFormatter)
|
||||
parser.add_argument("-b", "--build", dest="build", action="store_true",
|
||||
help="build PyLoT")
|
||||
parser.add_argument("-v", "--verbose", dest="verbose", action="count",
|
||||
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
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
verbose = args.verbose
|
||||
build = args.build
|
||||
install = args.install
|
||||
directory = args.directory
|
||||
|
||||
|
||||
if verbose > 0:
|
||||
print("Verbose mode on")
|
||||
if install and not directory:
|
||||
@ -112,22 +125,24 @@ USAGE
|
||||
return 0
|
||||
except Exception, e:
|
||||
if DEBUG or TESTRUN:
|
||||
raise(e)
|
||||
raise e
|
||||
indent = len(program_name) * " "
|
||||
sys.stderr.write(program_name + ": " + repr(e) + "\n")
|
||||
sys.stderr.write(indent + " for help use --help")
|
||||
return 2
|
||||
|
||||
|
||||
def buildPyLoT(verbosity=None):
|
||||
system = sys.platform
|
||||
if verbosity > 1:
|
||||
msg = ("... on system: {0}\n"
|
||||
"\n"
|
||||
" Current working directory: {1}\n"
|
||||
).format(system, os.getcwd())
|
||||
print msg
|
||||
).format(system, os.getcwd())
|
||||
print msg
|
||||
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':
|
||||
# create a symbolic link to the desired python interpreter in order to
|
||||
# display the right application name
|
||||
@ -136,24 +151,28 @@ def buildPyLoT(verbosity=None):
|
||||
if found:
|
||||
os.symlink(found, './PyLoT')
|
||||
break
|
||||
|
||||
|
||||
|
||||
def installPyLoT(verbosity=None):
|
||||
pass
|
||||
|
||||
|
||||
def cleanUp(verbosity=None):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if DEBUG:
|
||||
sys.argv.append("-h")
|
||||
sys.argv.append("-v")
|
||||
if TESTRUN:
|
||||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
if PROFILE:
|
||||
import cProfile
|
||||
import pstats
|
||||
|
||||
profile_filename = 'makePyLoT_profile.txt'
|
||||
cProfile.run('main()', profile_filename)
|
||||
statsfile = open("profile_stats.txt", "wb")
|
||||
@ -162,4 +181,4 @@ if __name__ == "__main__":
|
||||
stats.print_stats()
|
||||
statsfile.close()
|
||||
sys.exit(0)
|
||||
sys.exit(main())
|
||||
sys.exit(main())
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#--------------------------------------------------------
|
||||
# --------------------------------------------------------
|
||||
# Purpose: Convience imports for PyLoT
|
||||
#
|
||||
'''
|
||||
@ -24,4 +24,4 @@ The development of PyLoT is part of the joint research project MAGS2.
|
||||
:license:
|
||||
GNU Lesser General Public License, Version 3
|
||||
(http://www.gnu.org/copyleft/lesser.html)
|
||||
'''
|
||||
'''
|
||||
|
@ -161,7 +161,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
|
||||
index1 = []
|
||||
i = 0
|
||||
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:
|
||||
zc1.append(t[ipick][i])
|
||||
index1.append(i)
|
||||
@ -196,7 +196,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
|
||||
index2 = []
|
||||
i = 0
|
||||
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:
|
||||
zc2.append(t[ipick][i])
|
||||
index2.append(i)
|
||||
|
@ -2,5 +2,3 @@ from pylot.core.read.inputs import AutoPickParameter, FilterOptions
|
||||
from pylot.core.read.io import readPILOTEvent
|
||||
from pylot.core.read.data import GenericDataStructure, SeiscompDataStructure, \
|
||||
PilotDataStructure, Data
|
||||
|
||||
|
||||
|
@ -124,20 +124,10 @@ class AutoPickParameter(object):
|
||||
for key, value in self.__parameter.iteritems():
|
||||
yield key, value
|
||||
|
||||
def hasParam(self, *args):
|
||||
|
||||
def test(param):
|
||||
try:
|
||||
self.__parameter[param]
|
||||
return True
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
try:
|
||||
for param in args:
|
||||
return test(param)
|
||||
except TypeError:
|
||||
return test(args)
|
||||
def hasParam(self, parameter):
|
||||
if self.__parameter.has_key(parameter):
|
||||
return True
|
||||
return False
|
||||
|
||||
def getParam(self, *args):
|
||||
try:
|
||||
@ -157,7 +147,8 @@ class AutoPickParameter(object):
|
||||
self.__setitem__(param, value)
|
||||
print self
|
||||
|
||||
def _printParameterError(self, errmsg):
|
||||
@staticmethod
|
||||
def _printParameterError(errmsg):
|
||||
print 'ParameterError:\n non-existent parameter %s' % errmsg
|
||||
|
||||
def export2File(self, fnout):
|
||||
|
@ -9,8 +9,10 @@ Created on Thu Mar 20 09:47:04 2014
|
||||
class OptionsError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class FormatError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class DatastructureError(Exception):
|
||||
pass
|
||||
|
@ -8,5 +8,5 @@ Created on Wed Jan 26 17:47:25 2015
|
||||
|
||||
from pylot.core.read import SeiscompDataStructure, PilotDataStructure
|
||||
|
||||
DATASTRUCTURE = {'PILOT':PilotDataStructure, 'SeisComP':SeiscompDataStructure,
|
||||
None:None}
|
||||
DATASTRUCTURE = {'PILOT': PilotDataStructure, 'SeisComP': SeiscompDataStructure,
|
||||
None: None}
|
||||
|
@ -31,7 +31,7 @@
|
||||
#
|
||||
# include RELEASE-VERSION
|
||||
|
||||
__all__ = ("get_git_version")
|
||||
__all__ = "get_git_version"
|
||||
|
||||
# NO IMPORTS FROM PYLOT IN THIS FILE! (file gets used at installation time)
|
||||
import os
|
||||
@ -108,4 +108,4 @@ def get_git_version(abbrev=4):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print get_git_version()
|
||||
print get_git_version()
|
||||
|
@ -16,9 +16,9 @@ from matplotlib.figure import Figure
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvas
|
||||
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
|
||||
from matplotlib.widgets import MultiCursor
|
||||
from PySide.QtGui import QAction, QApplication,QComboBox, QDateTimeEdit,\
|
||||
QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, QGridLayout,\
|
||||
QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, QPixmap, QSpinBox,\
|
||||
from PySide.QtGui import QAction, QApplication, QComboBox, QDateTimeEdit, \
|
||||
QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, QGridLayout, \
|
||||
QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, QPixmap, QSpinBox, \
|
||||
QTabWidget, QToolBar, QVBoxLayout, QWidget
|
||||
from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
|
||||
from PySide.QtWebKit import QWebView
|
||||
@ -48,8 +48,8 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
class MPLWidget(FigureCanvas):
|
||||
|
||||
class MPLWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
|
||||
self._parent = None
|
||||
@ -65,7 +65,8 @@ class MPLWidget(FigureCanvas):
|
||||
# initialize super class
|
||||
FigureCanvas.__init__(self, self.figure)
|
||||
# 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)
|
||||
# update labels of the entire widget
|
||||
self.updateWidget(xlabel, ylabel, title)
|
||||
@ -126,7 +127,6 @@ class MPLWidget(FigureCanvas):
|
||||
self.axes.set_xlabel(text)
|
||||
self.draw()
|
||||
|
||||
|
||||
def updateYLabel(self, text):
|
||||
self.axes.set_ylabel(text)
|
||||
self.draw()
|
||||
@ -142,12 +142,12 @@ class MPLWidget(FigureCanvas):
|
||||
|
||||
def insertLabel(self, pos, text):
|
||||
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))
|
||||
|
||||
|
||||
class multiComponentPlot(FigureCanvas):
|
||||
|
||||
def __init__(self, data, parent=None, components='ZNE'):
|
||||
|
||||
self.data = data
|
||||
@ -211,7 +211,7 @@ class multiComponentPlot(FigureCanvas):
|
||||
|
||||
# plot individual component traces in separate subplots
|
||||
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:
|
||||
subax = self.figure.add_subplot(nsub, sharex=self.axesdict[0])
|
||||
else:
|
||||
@ -239,7 +239,6 @@ class multiComponentPlot(FigureCanvas):
|
||||
|
||||
|
||||
class PickDlg(QDialog):
|
||||
|
||||
def __init__(self, parent=None, data=None, station=None, rotate=False):
|
||||
super(PickDlg, self).__init__(parent)
|
||||
|
||||
@ -275,8 +274,8 @@ class PickDlg(QDialog):
|
||||
# plot data
|
||||
self.getPlotWidget().plotWFData(wfdata=self.getWFData(),
|
||||
title=self.getStation())
|
||||
self.limits = {'xlims' : self.getPlotWidget().axes.get_xlim(),
|
||||
'ylims' : self.getPlotWidget().axes.get_ylim()}
|
||||
self.limits = {'xlims': self.getPlotWidget().axes.get_xlim(),
|
||||
'ylims': self.getPlotWidget().axes.get_ylim()}
|
||||
self.apd = self.getWFData()
|
||||
|
||||
# set plot labels
|
||||
@ -420,9 +419,10 @@ class PickDlg(QDialog):
|
||||
def selectWFData(self, channel):
|
||||
component = channel[-1].upper()
|
||||
wfdata = Stream()
|
||||
def selectTrace(trace, components):
|
||||
if trace.stats.channel[-1].upper() in components:
|
||||
return trace
|
||||
|
||||
def selectTrace(tr, components):
|
||||
if tr.stats.channel[-1].upper() in components:
|
||||
return tr
|
||||
|
||||
if component == 'E' or component == 'N':
|
||||
for trace in self.getWFData():
|
||||
@ -462,10 +462,10 @@ class PickDlg(QDialog):
|
||||
# see also Diehl et al. 2009
|
||||
|
||||
res_wins = {
|
||||
'HRW' : 2.,
|
||||
'MRW' : 5.,
|
||||
'LRW' : 10.,
|
||||
'VLRW' : 15.
|
||||
'HRW': 2.,
|
||||
'MRW': 5.,
|
||||
'LRW': 10.,
|
||||
'VLRW': 15.
|
||||
}
|
||||
|
||||
result = getSNR(wfdata, (5., .5, 2.), ini_pick)
|
||||
@ -501,7 +501,7 @@ class PickDlg(QDialog):
|
||||
|
||||
def setPick(self, gui_event):
|
||||
# setting pick
|
||||
pick = gui_event.xdata # get pick time relative to the traces timeaxis not to the global
|
||||
pick = gui_event.xdata # get pick time relative to the traces timeaxis not to the global
|
||||
channel = self.getChannelID(round(gui_event.ydata))
|
||||
|
||||
wfdata = self.getAPD().copy().select(channel=channel)
|
||||
@ -512,12 +512,7 @@ class PickDlg(QDialog):
|
||||
phase = self.selectPhase.currentText()
|
||||
|
||||
# save pick times for actual phase
|
||||
phasepicks = {}
|
||||
|
||||
phasepicks['epp'] = epp
|
||||
phasepicks['lpp'] = lpp
|
||||
phasepicks['mpp'] = pick
|
||||
phasepicks['spe'] = spe
|
||||
phasepicks = {'epp': epp, 'lpp': lpp, 'mpp': pick, 'spe': spe}
|
||||
|
||||
try:
|
||||
oldphasepick = self.picks[phase]
|
||||
@ -570,10 +565,10 @@ class PickDlg(QDialog):
|
||||
lpp = picks['lpp']
|
||||
spe = picks['spe']
|
||||
|
||||
ax.fill_between([epp, lpp],ylims[0], ylims[1], alpha=.5, color='c')
|
||||
ax.plot([mpp-spe, mpp-spe], ylims, 'c--',
|
||||
ax.fill_between([epp, lpp], ylims[0], ylims[1], alpha=.5, color='c')
|
||||
ax.plot([mpp - spe, mpp - spe], ylims, 'c--',
|
||||
[mpp, mpp], ylims, 'b-',
|
||||
[mpp+spe, mpp+spe], ylims, 'c--')
|
||||
[mpp + spe, mpp + spe], ylims, 'c--')
|
||||
|
||||
self.getPlotWidget().draw()
|
||||
|
||||
@ -648,7 +643,7 @@ class PickDlg(QDialog):
|
||||
curr_ylim = widget.axes.get_ylim()
|
||||
|
||||
if gui_event.button == 'up':
|
||||
scale_factor = 1/factor
|
||||
scale_factor = 1 / factor
|
||||
elif gui_event.button == 'down':
|
||||
# deal with zoom out
|
||||
scale_factor = factor
|
||||
@ -682,8 +677,8 @@ class PickDlg(QDialog):
|
||||
self.apply()
|
||||
QDialog.accept(self)
|
||||
|
||||
class PropertiesDlg(QDialog):
|
||||
|
||||
class PropertiesDlg(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
super(PropertiesDlg, self).__init__(parent)
|
||||
|
||||
@ -707,7 +702,8 @@ class PropertiesDlg(QDialog):
|
||||
|
||||
self.buttonBox.accepted.connect(self.accept)
|
||||
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):
|
||||
self.apply()
|
||||
@ -728,7 +724,6 @@ class PropertiesDlg(QDialog):
|
||||
|
||||
|
||||
class PropTab(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(PropTab, self).__init__(parent)
|
||||
|
||||
@ -737,7 +732,6 @@ class PropTab(QWidget):
|
||||
|
||||
|
||||
class InputsTab(PropTab):
|
||||
|
||||
def __init__(self, parent):
|
||||
super(InputsTab, self).__init__(parent)
|
||||
|
||||
@ -775,15 +769,13 @@ class InputsTab(PropTab):
|
||||
self.setLayout(layout)
|
||||
|
||||
def getValues(self):
|
||||
values = {}
|
||||
values["data/dataRoot"] = self.dataDirEdit.text()
|
||||
values["user/FullName"] = self.fullNameEdit.text()
|
||||
values["data/Structure"] = self.structureSelect.currentText()
|
||||
values = {"data/dataRoot": self.dataDirEdit.text(),
|
||||
"user/FullName": self.fullNameEdit.text(),
|
||||
"data/Structure": self.structureSelect.currentText()}
|
||||
return values
|
||||
|
||||
|
||||
class OutputsTab(PropTab):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(OutputsTab, self).__init__(parent)
|
||||
|
||||
@ -808,12 +800,11 @@ class OutputsTab(PropTab):
|
||||
self.setLayout(layout)
|
||||
|
||||
def getValues(self):
|
||||
values = {}
|
||||
values["output/Format"] = self.eventOutputComboBox.currentText()
|
||||
values = {"output/Format": self.eventOutputComboBox.currentText()}
|
||||
return values
|
||||
|
||||
class PhasesTab(PropTab):
|
||||
|
||||
class PhasesTab(PropTab):
|
||||
def __init__(self, parent=None):
|
||||
super(PhasesTab, self).__init__(parent)
|
||||
|
||||
@ -821,7 +812,6 @@ class PhasesTab(PropTab):
|
||||
|
||||
|
||||
class GraphicsTab(PropTab):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(GraphicsTab, self).__init__(parent)
|
||||
|
||||
@ -850,13 +840,12 @@ class NewEventDlg(QDialog):
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
def getValues(self):
|
||||
return {'origintime' : self.eventTimeEdit.dateTime().toPython(),
|
||||
'latitude' : self.latEdit.text(),
|
||||
'longitude' : self.lonEdit.text(),
|
||||
'depth' : self.depEdit.text()}
|
||||
return {'origintime': self.eventTimeEdit.dateTime().toPython(),
|
||||
'latitude': self.latEdit.text(),
|
||||
'longitude': self.lonEdit.text(),
|
||||
'depth': self.depEdit.text()}
|
||||
|
||||
def setupUI(self):
|
||||
|
||||
# create widget objects
|
||||
timeLabel = QLabel()
|
||||
timeLabel.setText("Select time: ")
|
||||
@ -887,8 +876,8 @@ class NewEventDlg(QDialog):
|
||||
|
||||
self.setLayout(grid)
|
||||
|
||||
class FilterOptionsDialog(QDialog):
|
||||
|
||||
class FilterOptionsDialog(QDialog):
|
||||
def __init__(self, parent=None, titleString="Filter options",
|
||||
filterOptions=None):
|
||||
"""
|
||||
@ -925,8 +914,10 @@ class FilterOptionsDialog(QDialog):
|
||||
|
||||
if _enable:
|
||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
||||
if self.getFilterOptions().getFilterType() in ['bandpass', 'bandstop']:
|
||||
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1])
|
||||
if self.getFilterOptions().getFilterType() in ['bandpass',
|
||||
'bandstop']:
|
||||
self.freqmaxSpinBox.setValue(
|
||||
self.getFilterOptions().getFreq()[1])
|
||||
else:
|
||||
try:
|
||||
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq())
|
||||
@ -963,7 +954,7 @@ class FilterOptionsDialog(QDialog):
|
||||
|
||||
self.freqmaxSpinBox.setEnabled(_enable)
|
||||
|
||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|
|
||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
|
||||
QDialogButtonBox.Cancel)
|
||||
|
||||
grid = QGridLayout()
|
||||
@ -980,7 +971,6 @@ class FilterOptionsDialog(QDialog):
|
||||
self.buttonBox.accepted.connect(self.accept)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
|
||||
def updateUi(self):
|
||||
_enable = False
|
||||
if self.selectTypeCombo.currentText() not in ['bandpass', 'bandstop']:
|
||||
@ -993,10 +983,9 @@ class FilterOptionsDialog(QDialog):
|
||||
self.freqmaxLabel.setEnabled(_enable)
|
||||
self.freqmaxSpinBox.setEnabled(_enable)
|
||||
|
||||
|
||||
self.getFilterOptions().setFilterType(self.selectTypeCombo.currentText())
|
||||
freq = []
|
||||
freq.append(self.freqminSpinBox.value())
|
||||
self.getFilterOptions().setFilterType(
|
||||
self.selectTypeCombo.currentText())
|
||||
freq = [self.freqminSpinBox.value()]
|
||||
if _enable:
|
||||
if self.freqminSpinBox.value() > self.freqmaxSpinBox.value():
|
||||
QMessageBox.warning(self, "Value error",
|
||||
@ -1019,7 +1008,6 @@ class FilterOptionsDialog(QDialog):
|
||||
|
||||
|
||||
class LoadDataDlg(QDialog):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(LoadDataDlg, self).__init__(parent)
|
||||
|
||||
@ -1027,8 +1015,8 @@ class LoadDataDlg(QDialog):
|
||||
|
||||
|
||||
class HelpForm(QDialog):
|
||||
|
||||
def __init__(self, page=QUrl('https://ariadne.geophysik.rub.de/trac/PyLoT'), parent=None):
|
||||
def __init__(self, page=QUrl('https://ariadne.geophysik.rub.de/trac/PyLoT'),
|
||||
parent=None):
|
||||
super(HelpForm, self).__init__(parent)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||
self.setAttribute(Qt.WA_GroupLeader)
|
||||
|
Loading…
Reference in New Issue
Block a user