get values for filter parameters from widget
This commit is contained in:
parent
9e7f20a9fb
commit
d665e47d02
20
QtPyLoT.py
20
QtPyLoT.py
@ -247,19 +247,29 @@ class MainWindow(QMainWindow):
|
|||||||
pass #self.data.plotData(self.DataPlot)
|
pass #self.data.plotData(self.DataPlot)
|
||||||
|
|
||||||
def filterData(self):
|
def filterData(self):
|
||||||
pass
|
if self.getData():
|
||||||
|
kwargs = {}
|
||||||
|
freq = self.filteroptions.getFreq()
|
||||||
|
if len(freq) > 1:
|
||||||
|
kwargs['freqmin'] = freq[0]
|
||||||
|
kwargs['freqmax'] = freq[1]
|
||||||
|
else:
|
||||||
|
kwargs['freq'] = freq
|
||||||
|
kwargs['type'] = self.filteroptions.getFilterType()
|
||||||
|
#kwargs['order'] = self.filteroptions.getOrder()
|
||||||
|
self.data.filter(**kwargs)
|
||||||
|
|
||||||
def adjustFilterOptions(self):
|
def adjustFilterOptions(self):
|
||||||
filterOptions = None
|
filteroptions = None
|
||||||
fstring = "Filter Options ({0})".format(self.getSeismicPhase())
|
fstring = "Filter Options ({0})".format(self.getSeismicPhase())
|
||||||
filterDlg = FilterOptionsDialog(titleString=fstring,
|
filterDlg = FilterOptionsDialog(titleString=fstring,
|
||||||
parent=self,
|
parent=self,
|
||||||
filterOptions=self.getFilterOptions())
|
filterOptions=self.getFilterOptions())
|
||||||
if filterDlg.exec_():
|
if filterDlg.exec_():
|
||||||
filterOptions = filterDlg.getFilterOptions()
|
filteroptions = filterDlg.getFilterOptions()
|
||||||
|
|
||||||
assert isinstance(filterOptions, FilterOptions)
|
assert isinstance(filteroptions, FilterOptions)
|
||||||
self.setFilterOptions(filterOptions)
|
self.setFilterOptions(filteroptions)
|
||||||
|
|
||||||
def getFilterOptions(self):
|
def getFilterOptions(self):
|
||||||
return self.filteroptions
|
return self.filteroptions
|
||||||
|
@ -27,6 +27,9 @@ class Data(object):
|
|||||||
|
|
||||||
def __init__(self, parent=None, evtdata=None):
|
def __init__(self, parent=None, evtdata=None):
|
||||||
try:
|
try:
|
||||||
|
if parent:
|
||||||
|
self.wfdata = read(parent.fnames)
|
||||||
|
else:
|
||||||
self.wfdata = read()
|
self.wfdata = read()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
msg = 'An I/O error occured while loading data!'
|
msg = 'An I/O error occured while loading data!'
|
||||||
@ -53,6 +56,7 @@ class Data(object):
|
|||||||
else: # create an empty Event object
|
else: # create an empty Event object
|
||||||
self.newevent = True
|
self.newevent = True
|
||||||
self.evtdata = Event()
|
self.evtdata = Event()
|
||||||
|
self.orig = self.wfdata.copy()
|
||||||
|
|
||||||
def isNew(self):
|
def isNew(self):
|
||||||
return self.newevent
|
return self.newevent
|
||||||
@ -77,7 +81,6 @@ class Data(object):
|
|||||||
not implemented: {1}'''.format(evtformat, e))
|
not implemented: {1}'''.format(evtformat, e))
|
||||||
|
|
||||||
def plotData(self, widget):
|
def plotData(self, widget):
|
||||||
|
|
||||||
pass #axes = widget.axes
|
pass #axes = widget.axes
|
||||||
|
|
||||||
def getID(self):
|
def getID(self):
|
||||||
|
@ -165,34 +165,37 @@ class FilterOptions(object):
|
|||||||
'''
|
'''
|
||||||
def __init__(self, filtertype='bandpass', freq=[2., 5.], order=3,
|
def __init__(self, filtertype='bandpass', freq=[2., 5.], order=3,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
self.setFilterType(filtertype)
|
self._order = order
|
||||||
self.setFreq(freq)
|
self._filtertype = filtertype
|
||||||
self.setOrder(order)
|
self._freq = freq
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
hrs = '''\n\tFilter parameter:\n
|
hrs = '''\n\tFilter parameter:\n
|
||||||
Type:\t\t{ftype}\n
|
Type:\t\t{ftype}\n
|
||||||
Frequencies:\t{freq}\n
|
Frequencies:\t{freq}\n
|
||||||
Order:\t\t{order}\n
|
Order:\t\t{order}\n
|
||||||
'''.format(ftype=self.getFilterType(),
|
'''.format(ftype=self.getFilterType,
|
||||||
freq=self.getFreq(),
|
freq=self.getFreq,
|
||||||
order=self.getOrder())
|
order=self.getOrder)
|
||||||
return hrs
|
return hrs
|
||||||
|
|
||||||
|
@property
|
||||||
def getFreq(self):
|
def getFreq(self):
|
||||||
return self.freq
|
return self.__getattribute__('_freq')
|
||||||
|
|
||||||
def setFreq(self, freq):
|
def setFreq(self, freq):
|
||||||
self.freq = freq
|
self.__setattr__('_freq', freq)
|
||||||
|
|
||||||
|
@property
|
||||||
def getOrder(self):
|
def getOrder(self):
|
||||||
return self.order
|
return self.__getattribute__('_order')
|
||||||
|
|
||||||
def setOrder(self, order):
|
def setOrder(self, order):
|
||||||
self.order = order
|
self.__setattr__('_order', order)
|
||||||
|
|
||||||
|
@property
|
||||||
def getFilterType(self):
|
def getFilterType(self):
|
||||||
return self.filterType
|
return self.__getattribute__('_filtertype')
|
||||||
|
|
||||||
def setFilterType(self, filtertype):
|
def setFilterType(self, filtertype):
|
||||||
self.filterType = filtertype
|
self.__setattr__('_filtertype', filtertype)
|
||||||
|
@ -166,7 +166,7 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.freqminSpinBox.setRange(5e-7, 1e6)
|
self.freqminSpinBox.setRange(5e-7, 1e6)
|
||||||
self.freqminSpinBox.setDecimals(2)
|
self.freqminSpinBox.setDecimals(2)
|
||||||
self.freqminSpinBox.setSuffix(' Hz')
|
self.freqminSpinBox.setSuffix(' Hz')
|
||||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq[0])
|
||||||
self.freqmaxLabel = QLabel()
|
self.freqmaxLabel = QLabel()
|
||||||
self.freqmaxLabel.setText("maximum:")
|
self.freqmaxLabel.setText("maximum:")
|
||||||
self.freqmaxSpinBox = QDoubleSpinBox()
|
self.freqmaxSpinBox = QDoubleSpinBox()
|
||||||
@ -174,7 +174,7 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.freqmaxSpinBox.setDecimals(2)
|
self.freqmaxSpinBox.setDecimals(2)
|
||||||
self.freqmaxSpinBox.setSuffix(' Hz')
|
self.freqmaxSpinBox.setSuffix(' Hz')
|
||||||
if self.filterOptions.filterType in ['bandpass', 'bandstop']:
|
if self.filterOptions.filterType in ['bandpass', 'bandstop']:
|
||||||
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1])
|
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq[1])
|
||||||
|
|
||||||
typeOptions = ["bandpass", "bandstop", "lowpass", "highpass"]
|
typeOptions = ["bandpass", "bandstop", "lowpass", "highpass"]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user