diff --git a/QtPyLoT.py b/QtPyLoT.py index 1caf4cd8..1855e491 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -247,19 +247,29 @@ class MainWindow(QMainWindow): pass #self.data.plotData(self.DataPlot) 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): - filterOptions = None + filteroptions = None fstring = "Filter Options ({0})".format(self.getSeismicPhase()) filterDlg = FilterOptionsDialog(titleString=fstring, parent=self, filterOptions=self.getFilterOptions()) if filterDlg.exec_(): - filterOptions = filterDlg.getFilterOptions() + filteroptions = filterDlg.getFilterOptions() - assert isinstance(filterOptions, FilterOptions) - self.setFilterOptions(filterOptions) + assert isinstance(filteroptions, FilterOptions) + self.setFilterOptions(filteroptions) def getFilterOptions(self): return self.filteroptions diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index 5b9250f1..8331c6a6 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -27,7 +27,10 @@ class Data(object): def __init__(self, parent=None, evtdata=None): try: - self.wfdata = read() + if parent: + self.wfdata = read(parent.fnames) + else: + self.wfdata = read() except IOError, e: msg = 'An I/O error occured while loading data!' inform = 'Variable wfdata will be empty.' @@ -53,6 +56,7 @@ class Data(object): else: # create an empty Event object self.newevent = True self.evtdata = Event() + self.orig = self.wfdata.copy() def isNew(self): return self.newevent @@ -77,7 +81,6 @@ class Data(object): not implemented: {1}'''.format(evtformat, e)) def plotData(self, widget): - pass #axes = widget.axes def getID(self): diff --git a/pylot/core/read/inputs.py b/pylot/core/read/inputs.py index ee840b8f..57999fb8 100644 --- a/pylot/core/read/inputs.py +++ b/pylot/core/read/inputs.py @@ -165,34 +165,37 @@ class FilterOptions(object): ''' def __init__(self, filtertype='bandpass', freq=[2., 5.], order=3, **kwargs): - self.setFilterType(filtertype) - self.setFreq(freq) - self.setOrder(order) + self._order = order + self._filtertype = filtertype + self._freq = freq def __str__(self): hrs = '''\n\tFilter parameter:\n Type:\t\t{ftype}\n Frequencies:\t{freq}\n Order:\t\t{order}\n - '''.format(ftype=self.getFilterType(), - freq=self.getFreq(), - order=self.getOrder()) + '''.format(ftype=self.getFilterType, + freq=self.getFreq, + order=self.getOrder) return hrs + @property def getFreq(self): - return self.freq + return self.__getattribute__('_freq') def setFreq(self, freq): - self.freq = freq + self.__setattr__('_freq', freq) + @property def getOrder(self): - return self.order + return self.__getattribute__('_order') def setOrder(self, order): - self.order = order + self.__setattr__('_order', order) + @property def getFilterType(self): - return self.filterType + return self.__getattribute__('_filtertype') def setFilterType(self, filtertype): - self.filterType = filtertype + self.__setattr__('_filtertype', filtertype) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index a6376f73..e937f2cf 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -166,7 +166,7 @@ class FilterOptionsDialog(QDialog): self.freqminSpinBox.setRange(5e-7, 1e6) self.freqminSpinBox.setDecimals(2) self.freqminSpinBox.setSuffix(' Hz') - self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0]) + self.freqminSpinBox.setValue(self.getFilterOptions().getFreq[0]) self.freqmaxLabel = QLabel() self.freqmaxLabel.setText("maximum:") self.freqmaxSpinBox = QDoubleSpinBox() @@ -174,7 +174,7 @@ class FilterOptionsDialog(QDialog): self.freqmaxSpinBox.setDecimals(2) self.freqmaxSpinBox.setSuffix(' Hz') 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"]