[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:
@@ -12,38 +12,27 @@ from pylot.core.loc import hyposat
|
||||
from pylot.core.loc import hypo71
|
||||
from pylot.core.loc import hypodd
|
||||
from pylot.core.loc import velest
|
||||
from pylot.core.io.inputs import PylotParameter
|
||||
|
||||
|
||||
def readFilterInformation(fname):
|
||||
def convert2FreqRange(*args):
|
||||
if len(args) > 1:
|
||||
return [float(arg) for arg in args]
|
||||
elif len(args) == 1:
|
||||
return float(args[0])
|
||||
return None
|
||||
|
||||
filter_file = open(fname, 'r')
|
||||
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}
|
||||
def readDefaultFilterInformation(fname):
|
||||
pparam = PylotParameter(fname)
|
||||
return readFilterInformation(pparam)
|
||||
|
||||
def readFilterInformation(pylot_parameter):
|
||||
p_filter = {'filtertype': pylot_parameter['filter_type'][0],
|
||||
'freq': [pylot_parameter['minfreq'][0], pylot_parameter['maxfreq'][0]],
|
||||
'order': int(pylot_parameter['filter_order'][0])}
|
||||
s_filter = {'filtertype': pylot_parameter['filter_type'][1],
|
||||
'freq': [pylot_parameter['minfreq'][1], pylot_parameter['maxfreq'][1]],
|
||||
'order': int(pylot_parameter['filter_order'][1])}
|
||||
filter_information = {'P': p_filter,
|
||||
'S': s_filter}
|
||||
return filter_information
|
||||
|
||||
|
||||
FILTERDEFAULTS = readFilterInformation(os.path.join(os.path.expanduser('~'),
|
||||
'.pylot',
|
||||
'filter.in'))
|
||||
FILTERDEFAULTS = readDefaultFilterInformation(os.path.join(os.path.expanduser('~'),
|
||||
'.pylot',
|
||||
'pylot.in'))
|
||||
|
||||
TIMEERROR_DEFAULTS = os.path.join(os.path.expanduser('~'),
|
||||
'.pylot',
|
||||
|
||||
@@ -2048,7 +2048,7 @@ class TuneAutopicker(QWidget):
|
||||
return parameters
|
||||
|
||||
def set_stretch(self):
|
||||
self.tune_layout.setStretch(0, 3)
|
||||
self.tune_layout.setStretch(0, 2)
|
||||
self.tune_layout.setStretch(1, 1)
|
||||
|
||||
def clear_all(self):
|
||||
@@ -2079,7 +2079,9 @@ class TuneAutopicker(QWidget):
|
||||
self.qmb.show()
|
||||
|
||||
|
||||
class PylotParaBox(QtGui.QWidget):
|
||||
class PylotParaBox(QtGui.QWidget):
|
||||
accepted = QtCore.Signal(str)
|
||||
rejected = QtCore.Signal(str)
|
||||
def __init__(self, parameter, parent=None):
|
||||
'''
|
||||
Generate Widget containing parameters for PyLoT.
|
||||
@@ -2106,7 +2108,9 @@ class PylotParaBox(QtGui.QWidget):
|
||||
self.params_to_gui()
|
||||
self._toggle_advanced_settings()
|
||||
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):
|
||||
self._main_layout = QtGui.QVBoxLayout()
|
||||
@@ -2137,10 +2141,9 @@ class PylotParaBox(QtGui.QWidget):
|
||||
self._dialog_buttons.addWidget(self._okay)
|
||||
self._dialog_buttons.addWidget(self._close)
|
||||
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._apply.clicked.connect(self.params_from_gui)
|
||||
self._close.clicked.connect(self.params_to_gui)
|
||||
self._apply.clicked.connect(self.accept)
|
||||
self._close.clicked.connect(self.close)
|
||||
self.layout.addLayout(self._dialog_buttons)
|
||||
|
||||
@@ -2478,6 +2481,13 @@ class PylotParaBox(QtGui.QWidget):
|
||||
self._exclusive_widgets = []
|
||||
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):
|
||||
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
|
||||
'Warning', message)
|
||||
@@ -3058,8 +3068,10 @@ class FilterOptionsDialog(QDialog):
|
||||
QDialog.accept(self)
|
||||
|
||||
def updateUi(self):
|
||||
returnvals = []
|
||||
for foWidget in self.filterOptionWidgets.values():
|
||||
foWidget.updateUi()
|
||||
returnvals.append(foWidget.updateUi())
|
||||
return returnvals
|
||||
|
||||
def getFilterOptions(self):
|
||||
filteroptions = {'P': self.filterOptionWidgets['P'].getFilterOptions(),
|
||||
@@ -3174,15 +3186,17 @@ class FilterOptionsWidget(QWidget):
|
||||
if not isSorted(freq):
|
||||
QMessageBox.warning(self, "Value error",
|
||||
"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.selectAll()
|
||||
self.freqmaxSpinBox.setFocus()
|
||||
return
|
||||
return False
|
||||
|
||||
self.getFilterOptions().setFilterType(type)
|
||||
self.getFilterOptions().setFreq(freq)
|
||||
self.getFilterOptions().setOrder(self.orderSpinBox.value())
|
||||
return True
|
||||
|
||||
def getFilterOptions(self):
|
||||
return self.filterOptions
|
||||
|
||||
Reference in New Issue
Block a user