[change] several updates updates to filterOptions, FILTERDEFAULTS now loaded from pylot.in, filterOptions should be 'shared' between filterOptionsDialog and pylotParameter

This commit is contained in:
Marcel Paffrath 2017-07-11 16:03:24 +02:00
parent 0e566f9748
commit 1d9e52f577
5 changed files with 70 additions and 53 deletions

View File

@ -65,7 +65,8 @@ 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, OUTPUTFORMATS, SetChannelComponents from pylot.core.util.defaults import FILTERDEFAULTS, OUTPUTFORMATS, SetChannelComponents, \
readFilterInformation
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
@ -180,8 +181,15 @@ class MainWindow(QMainWindow):
# setup UI # setup UI
self.setupUi() self.setupUi()
self.filteroptions = {'P': FilterOptions(), filter_info = readFilterInformation(self._inputs)
'S': FilterOptions()} p_filter = filter_info['P']
s_filter = filter_info['S']
self.filteroptions = {'P': FilterOptions(p_filter['filtertype'],
p_filter['freq'],
p_filter['order']),
'S': FilterOptions(s_filter['filtertype'],
s_filter['freq'],
s_filter['order'])}
self.pylot_picks = {} self.pylot_picks = {}
self.pylot_autopicks = {} self.pylot_autopicks = {}
self.loc = False self.loc = False
@ -1543,16 +1551,23 @@ class MainWindow(QMainWindow):
def adjustFilterOptions(self): def adjustFilterOptions(self):
fstring = "Filter Options" fstring = "Filter Options"
filterDlg = FilterOptionsDialog(titleString=fstring, self.filterDlg = FilterOptionsDialog(titleString=fstring,
parent=self) parent=self)
if filterDlg.exec_(): if self.filterDlg.exec_():
filteroptions = filterDlg.getFilterOptions() filteroptions = self.filterDlg.getFilterOptions()
self.setFilterOptions(filteroptions) self.setFilterOptions(filteroptions)
if self.filterAction.isChecked(): if self.filterAction.isChecked():
kwargs = self.getFilterOptions().parseFilterOptions() kwargs = self.getFilterOptions().parseFilterOptions()
self.pushFilterWF(kwargs) self.pushFilterWF(kwargs)
self.plotWaveformDataThread() self.plotWaveformDataThread()
def checkFilterOptions(self):
fstring = "Filter Options"
self.filterDlg = FilterOptionsDialog(titleString=fstring,
parent=self)
filteroptions = self.filterDlg.getFilterOptions()
self.setFilterOptions(filteroptions)
def getFilterOptions(self): def getFilterOptions(self):
return self.filteroptions return self.filteroptions
# try: # try:
@ -1595,6 +1610,8 @@ class MainWindow(QMainWindow):
filterS.setOrder(orderS) filterS.setOrder(orderS)
filterS.setFilterType(typeS) filterS.setFilterType(typeS)
self.checkFilterOptions()
def updateFilterOptions(self): def updateFilterOptions(self):
try: try:
settings = QSettings() settings = QSettings()
@ -2496,10 +2513,8 @@ class MainWindow(QMainWindow):
def setParameter(self, show=True): def setParameter(self, show=True):
if not self.paraBox: if not self.paraBox:
self.paraBox = PylotParaBox(self._inputs) self.paraBox = PylotParaBox(self._inputs)
self.paraBox._apply.clicked.connect(self._setDirty) self.paraBox.accepted.connect(self._setDirty)
self.paraBox._okay.clicked.connect(self._setDirty) self.paraBox.accepted.connect(self.filterOptionsFromParameter)
self.paraBox._apply.clicked.connect(self.filterOptionsFromParameter)
self.paraBox._okay.clicked.connect(self.filterOptionsFromParameter)
if show: if show:
self.paraBox.params_to_gui() self.paraBox.params_to_gui()
self.paraBox.show() self.paraBox.show()

View File

@ -50,9 +50,9 @@ for regional distance seismicity
cp path-to-pylot/inputs/autoPyLoT_regional.in ~/.pylot/autoPyLoT.in cp path-to-pylot/inputs/autoPyLoT_regional.in ~/.pylot/autoPyLoT.in
and some extra information on filtering, error estimates (just needed for reading old PILOT data) and the Richter magnitude scaling relation and some extra information on error estimates (just needed for reading old PILOT data) and the Richter magnitude scaling relation
cp path-to-pylot/inputs/filter.in path-to-pylot/inputs/PILOT_TimeErrors.in path-to-pylot/inputs/richter_scaling.data ~/.pylot/ cp path-to-pylot/inputs/PILOT_TimeErrors.in path-to-pylot/inputs/richter_scaling.data ~/.pylot/
You may need to do some modifications to these files. Especially folder names should be reviewed. You may need to do some modifications to these files. Especially folder names should be reviewed.

View File

@ -159,8 +159,7 @@ def buildPyLoT(verbosity=None):
def installPyLoT(verbosity=None): def installPyLoT(verbosity=None):
files_to_copy = {'autoPyLoT_local.in':['~', '.pylot'], files_to_copy = {'autoPyLoT_local.in':['~', '.pylot'],
'autoPyLoT_regional.in':['~', '.pylot'], 'autoPyLoT_regional.in':['~', '.pylot']}
'filter.in':['~', '.pylot']}
if verbosity > 0: if verbosity > 0:
print ('starting installation of PyLoT ...') print ('starting installation of PyLoT ...')
if verbosity > 1: if verbosity > 1:

View File

@ -12,38 +12,27 @@ from pylot.core.loc import hyposat
from pylot.core.loc import hypo71 from pylot.core.loc import hypo71
from pylot.core.loc import hypodd from pylot.core.loc import hypodd
from pylot.core.loc import velest from pylot.core.loc import velest
from pylot.core.io.inputs import PylotParameter
def readDefaultFilterInformation(fname):
pparam = PylotParameter(fname)
return readFilterInformation(pparam)
def readFilterInformation(fname): def readFilterInformation(pylot_parameter):
def convert2FreqRange(*args): p_filter = {'filtertype': pylot_parameter['filter_type'][0],
if len(args) > 1: 'freq': [pylot_parameter['minfreq'][0], pylot_parameter['maxfreq'][0]],
return [float(arg) for arg in args] 'order': int(pylot_parameter['filter_order'][0])}
elif len(args) == 1: s_filter = {'filtertype': pylot_parameter['filter_type'][1],
return float(args[0]) 'freq': [pylot_parameter['minfreq'][1], pylot_parameter['maxfreq'][1]],
return None 'order': int(pylot_parameter['filter_order'][1])}
filter_information = {'P': p_filter,
filter_file = open(fname, 'r') 'S': s_filter}
filter_information = dict()
for filter_line in filter_file.readlines():
filter_line = filter_line.split(' ')
for n, pos in enumerate(filter_line):
if pos == '\n':
filter_line[n] = ''
filter_information[filter_line[0]] = {'filtertype': filter_line[1]
if filter_line[1]
else None,
'order': int(filter_line[2])
if filter_line[1]
else None,
'freq': convert2FreqRange(*filter_line[3:])
if filter_line[1]
else None}
return filter_information return filter_information
FILTERDEFAULTS = readFilterInformation(os.path.join(os.path.expanduser('~'), FILTERDEFAULTS = readDefaultFilterInformation(os.path.join(os.path.expanduser('~'),
'.pylot', '.pylot',
'filter.in')) 'pylot.in'))
TIMEERROR_DEFAULTS = os.path.join(os.path.expanduser('~'), TIMEERROR_DEFAULTS = os.path.join(os.path.expanduser('~'),
'.pylot', '.pylot',

View File

@ -2048,7 +2048,7 @@ class TuneAutopicker(QWidget):
return parameters return parameters
def set_stretch(self): def set_stretch(self):
self.tune_layout.setStretch(0, 3) self.tune_layout.setStretch(0, 2)
self.tune_layout.setStretch(1, 1) self.tune_layout.setStretch(1, 1)
def clear_all(self): def clear_all(self):
@ -2080,6 +2080,8 @@ class TuneAutopicker(QWidget):
class PylotParaBox(QtGui.QWidget): class PylotParaBox(QtGui.QWidget):
accepted = QtCore.Signal(str)
rejected = QtCore.Signal(str)
def __init__(self, parameter, parent=None): def __init__(self, parameter, parent=None):
''' '''
Generate Widget containing parameters for PyLoT. Generate Widget containing parameters for PyLoT.
@ -2107,6 +2109,8 @@ class PylotParaBox(QtGui.QWidget):
self._toggle_advanced_settings() self._toggle_advanced_settings()
self.resize(720, 1280) self.resize(720, 1280)
self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
self.accepted.connect(self.params_from_gui)
self.rejected.connect(self.params_to_gui)
def _init_sublayouts(self): def _init_sublayouts(self):
self._main_layout = QtGui.QVBoxLayout() self._main_layout = QtGui.QVBoxLayout()
@ -2137,10 +2141,9 @@ class PylotParaBox(QtGui.QWidget):
self._dialog_buttons.addWidget(self._okay) self._dialog_buttons.addWidget(self._okay)
self._dialog_buttons.addWidget(self._close) self._dialog_buttons.addWidget(self._close)
self._dialog_buttons.addWidget(self._apply) self._dialog_buttons.addWidget(self._apply)
self._okay.clicked.connect(self.params_from_gui) self._okay.clicked.connect(self.accept)
self._okay.clicked.connect(self.close) self._okay.clicked.connect(self.close)
self._apply.clicked.connect(self.params_from_gui) self._apply.clicked.connect(self.accept)
self._close.clicked.connect(self.params_to_gui)
self._close.clicked.connect(self.close) self._close.clicked.connect(self.close)
self.layout.addLayout(self._dialog_buttons) self.layout.addLayout(self._dialog_buttons)
@ -2478,6 +2481,13 @@ class PylotParaBox(QtGui.QWidget):
self._exclusive_widgets = [] self._exclusive_widgets = []
QtGui.QWidget.show(self) QtGui.QWidget.show(self)
def close(self):
self.rejected.emit('reject')
QtGui.QWidget.close(self)
def accept(self):
self.accepted.emit('accept')
def _warn(self, message): def _warn(self, message):
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning, self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
'Warning', message) 'Warning', message)
@ -3058,8 +3068,10 @@ class FilterOptionsDialog(QDialog):
QDialog.accept(self) QDialog.accept(self)
def updateUi(self): def updateUi(self):
returnvals = []
for foWidget in self.filterOptionWidgets.values(): for foWidget in self.filterOptionWidgets.values():
foWidget.updateUi() returnvals.append(foWidget.updateUi())
return returnvals
def getFilterOptions(self): def getFilterOptions(self):
filteroptions = {'P': self.filterOptionWidgets['P'].getFilterOptions(), filteroptions = {'P': self.filterOptionWidgets['P'].getFilterOptions(),
@ -3174,15 +3186,17 @@ class FilterOptionsWidget(QWidget):
if not isSorted(freq): if not isSorted(freq):
QMessageBox.warning(self, "Value error", QMessageBox.warning(self, "Value error",
"Maximum frequency must be at least the " "Maximum frequency must be at least the "
"same value as minimum frequency (notch)!") "same value as minimum frequency (notch)! "
"Adjusted maximum frequency automatically!")
self.freqmaxSpinBox.setValue(freq[0]) self.freqmaxSpinBox.setValue(freq[0])
self.freqmaxSpinBox.selectAll() self.freqmaxSpinBox.selectAll()
self.freqmaxSpinBox.setFocus() self.freqmaxSpinBox.setFocus()
return return False
self.getFilterOptions().setFilterType(type) self.getFilterOptions().setFilterType(type)
self.getFilterOptions().setFreq(freq) self.getFilterOptions().setFreq(freq)
self.getFilterOptions().setOrder(self.orderSpinBox.value()) self.getFilterOptions().setOrder(self.orderSpinBox.value())
return True
def getFilterOptions(self): def getFilterOptions(self):
return self.filterOptions return self.filterOptions