[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:
parent
0e566f9748
commit
1d9e52f577
39
QtPyLoT.py
39
QtPyLoT.py
@ -65,7 +65,8 @@ from pylot.core.pick.compare import Comparison
|
||||
from pylot.core.pick.utils import symmetrize_error
|
||||
from pylot.core.io.phases import picksdict_from_picks
|
||||
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, \
|
||||
OverwriteError, ProcessingError
|
||||
from pylot.core.util.connection import checkurl
|
||||
@ -180,8 +181,15 @@ class MainWindow(QMainWindow):
|
||||
# setup UI
|
||||
self.setupUi()
|
||||
|
||||
self.filteroptions = {'P': FilterOptions(),
|
||||
'S': FilterOptions()}
|
||||
filter_info = readFilterInformation(self._inputs)
|
||||
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_autopicks = {}
|
||||
self.loc = False
|
||||
@ -1543,16 +1551,23 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def adjustFilterOptions(self):
|
||||
fstring = "Filter Options"
|
||||
filterDlg = FilterOptionsDialog(titleString=fstring,
|
||||
parent=self)
|
||||
if filterDlg.exec_():
|
||||
filteroptions = filterDlg.getFilterOptions()
|
||||
self.filterDlg = FilterOptionsDialog(titleString=fstring,
|
||||
parent=self)
|
||||
if self.filterDlg.exec_():
|
||||
filteroptions = self.filterDlg.getFilterOptions()
|
||||
self.setFilterOptions(filteroptions)
|
||||
if self.filterAction.isChecked():
|
||||
kwargs = self.getFilterOptions().parseFilterOptions()
|
||||
self.pushFilterWF(kwargs)
|
||||
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):
|
||||
return self.filteroptions
|
||||
# try:
|
||||
@ -1584,7 +1599,7 @@ class MainWindow(QMainWindow):
|
||||
maxP, maxS = self._inputs['maxfreq']
|
||||
orderP, orderS = self._inputs['filter_order']
|
||||
typeP, typeS = self._inputs['filter_type']
|
||||
|
||||
|
||||
filterP = self.getFilterOptions()['P']
|
||||
filterP.setFreq([minP, maxP])
|
||||
filterP.setOrder(orderP)
|
||||
@ -1595,6 +1610,8 @@ class MainWindow(QMainWindow):
|
||||
filterS.setOrder(orderS)
|
||||
filterS.setFilterType(typeS)
|
||||
|
||||
self.checkFilterOptions()
|
||||
|
||||
def updateFilterOptions(self):
|
||||
try:
|
||||
settings = QSettings()
|
||||
@ -2496,10 +2513,8 @@ class MainWindow(QMainWindow):
|
||||
def setParameter(self, show=True):
|
||||
if not self.paraBox:
|
||||
self.paraBox = PylotParaBox(self._inputs)
|
||||
self.paraBox._apply.clicked.connect(self._setDirty)
|
||||
self.paraBox._okay.clicked.connect(self._setDirty)
|
||||
self.paraBox._apply.clicked.connect(self.filterOptionsFromParameter)
|
||||
self.paraBox._okay.clicked.connect(self.filterOptionsFromParameter)
|
||||
self.paraBox.accepted.connect(self._setDirty)
|
||||
self.paraBox.accepted.connect(self.filterOptionsFromParameter)
|
||||
if show:
|
||||
self.paraBox.params_to_gui()
|
||||
self.paraBox.show()
|
||||
|
@ -50,9 +50,9 @@ for regional distance seismicity
|
||||
|
||||
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.
|
||||
|
||||
|
@ -159,8 +159,7 @@ def buildPyLoT(verbosity=None):
|
||||
|
||||
def installPyLoT(verbosity=None):
|
||||
files_to_copy = {'autoPyLoT_local.in':['~', '.pylot'],
|
||||
'autoPyLoT_regional.in':['~', '.pylot'],
|
||||
'filter.in':['~', '.pylot']}
|
||||
'autoPyLoT_regional.in':['~', '.pylot']}
|
||||
if verbosity > 0:
|
||||
print ('starting installation of PyLoT ...')
|
||||
if verbosity > 1:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user