added parameters tab to TuneAutopicker widget. Enabled direct call of autoPyLoT with AP-Settings object

This commit is contained in:
Marcel Paffrath 2017-05-10 15:46:08 +02:00
parent d96bc3c621
commit 862fb3240a
4 changed files with 47 additions and 13 deletions

View File

@ -29,7 +29,7 @@ from pylot.core.util.version import get_git_version as _getVersionString
__version__ = _getVersionString()
def autoPyLoT(inputfile, fnames=None, savepath=None, iplot=0):
def autoPyLoT(parameter=None, inputfile=None, fnames=None, savepath=None, iplot=0):
"""
Determine phase onsets automatically utilizing the automatic picking
algorithms by Kueperkoch et al. 2010/2012.
@ -55,8 +55,22 @@ def autoPyLoT(inputfile, fnames=None, savepath=None, iplot=0):
***********************************'''.format(version=_getVersionString())
print(splash)
if not parameter:
if inputfile:
parameter = AutoPickParameter(inputfile)
else:
print('No parameters set and no input file given. Choose either of both.')
return
else:
if not type(parameter) == AutoPickParameter:
print('Wrong input type for parameter: {}'.format(type(parameter)))
return
if inputfile:
print('Parameters set and input file given. Choose either of both.')
return
# reading parameter file
parameter = AutoPickParameter(inputfile)
data = Data()
@ -79,7 +93,7 @@ def autoPyLoT(inputfile, fnames=None, savepath=None, iplot=0):
datastructure.setExpandFields(exf)
# check if default location routine NLLoc is available
if parameter.hasParam('nllocbin'):
if parameter['nllocbin']:
locflag = 1
# get NLLoc-root path
nllocroot = parameter.get('nllocroot')

View File

@ -1 +1 @@
7d56-dirty
d96b-dirty

View File

@ -117,7 +117,7 @@ class AutoPickParameter(object):
# Boolean test
def __nonzero__(self):
return self.__parameter
return bool(self.__parameter)
def __getitem__(self, key):
return self.__parameter[key]

View File

@ -1269,16 +1269,20 @@ class PickDlg(QDialog):
class TuneAutopicker(QWidget):
def __init__(self, fig_dict, station, parent=None):
def __init__(self, fig_dict, station, ap, parent=None):
QtGui.QWidget.__init__(self, parent)
if not station in fig_dict:
print('Station not found')
return
self.ap = ap
self.fd = fig_dict[station]
self.layout = QtGui.QHBoxLayout()
self.setLayout(self.layout)
self.init_figure_tabs()
self.add_parameter()
self.layout.setStretch(0,3)
self.layout.setStretch(1,1)
def init_figure_tabs(self):
self.main_tabs = QtGui.QTabWidget()
self.p_tabs = QtGui.QTabWidget()
@ -1286,6 +1290,10 @@ class TuneAutopicker(QWidget):
self.layout.addWidget(self.main_tabs)
self.init_tab_names()
self.fill_tabs()
def add_parameter(self):
self.parameters = AutoPickParaBox(self.ap)
self.layout.addWidget(self.parameters)
def init_tab_names(self):
self.ptb_names = ['aicFig', 'slenght', 'checkZ4S', 'refPpick', 'el_Ppick', 'fm_picker']
@ -1302,15 +1310,27 @@ class TuneAutopicker(QWidget):
def fill_p_tabs(self):
for name in self.ptb_names:
figure = self.fd[name]
self.p_tabs.addTab(figure.canvas, name)
figure.tight_layout()
try:
figure = self.fd[name]
id = self.p_tabs.addTab(figure.canvas, name)
self.p_tabs.setTabEnabled(id, True)
figure.tight_layout()
except Exception as e:
id = self.p_tabs.addTab(QtGui.QWidget(), name)
self.p_tabs.setTabEnabled(id, False)
print('Could not initiate figure {}.'.format(name))
def fill_s_tabs(self):
for name in self.stb_names:
figure = self.fd[name]
self.s_tabs.addTab(figure.canvas, name)
figure.tight_layout()
try:
figure = self.fd[name]
id = self.s_tabs.addTab(figure.canvas, name)
self.s_tabs.setTabEnabled(id, True)
figure.tight_layout()
except Exception as e:
id = self.s_tabs.addTab(QtGui.QWidget(), name)
self.s_tabs.setTabEnabled(id, False)
print('Could not initiate figure {}.'.format(name))
class PropertiesDlg(QDialog):