diff --git a/QtPyLoT.py b/QtPyLoT.py index 202460ca..bc973612 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -35,7 +35,8 @@ from obspy.core import UTCDateTime from pylot.core.read import Data, FilterOptions from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \ checkurl, FormatError, layoutStationButtons, FilterOptionsDialog, \ - NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm + NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \ + DatastructureError from pylot.core.util.structure import DATASTRUCTURE @@ -93,14 +94,17 @@ class MainWindow(QMainWindow): self.dirty = False self.loadData() self.updateFilterOptions() + + + + def setupUi(self): + try: self.startTime = min( [tr.stats.starttime for tr in self.data.wfdata]) except: self.startTime = UTCDateTime() - - def setupUi(self): self.setWindowIcon(QIcon(":/icon.ico")) xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)') @@ -113,8 +117,7 @@ class MainWindow(QMainWindow): # create central matplotlib figure canvas widget self.DataPlot = MPLWidget(parent=self, xlabel=xlab, ylabel=None, title=plottitle) - statsButtons = layoutStationButtons(self.getData(), self.getComponent()) - _layout.addLayout(statsButtons) + _layout.addWidget(self.DataPlot) openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon) @@ -147,7 +150,7 @@ class MainWindow(QMainWindow): QCoreApplication.instance().quit, QKeySequence.Close, quitIcon, "Close event and quit PyLoT") - filterAction = self.createAction("&Filter ...", self.filterData, + filterAction = self.createAction("&Filter ...", self.filterWaveformData, "Ctrl+F", QIcon(":/filter.png"), """Toggle un-/filtered waveforms to be displayed, according to the @@ -194,9 +197,6 @@ class MainWindow(QMainWindow): status.addPermanentWidget(self.eventLabel) status.showMessage("Ready", 500) - statsButtons = layoutStationButtons(self.getData(), self.getComponent()) - _layout.addLayout(statsButtons) - _layout.addWidget(self.DataPlot) _widget.setLayout(_layout) self.setCentralWidget(_widget) @@ -294,16 +294,17 @@ class MainWindow(QMainWindow): else: if self.dataStructure: searchPath = self.dataStructure.expandDataPath() - fnames, = QFileDialog.getOpenFileNames(self, + fnames = QFileDialog.getOpenFileNames(self, "Select waveform " "files:", dir=searchPath) self.fnames = fnames else: - raise ValueError('dataStructure not specified') + raise DatastructureError('not specified') return self.fnames - except ValueError: + except DatastructureError, e: + print e props = PropertiesDlg(self) if props.exec_() == QDialog.Accepted: return self.getWFFnames() @@ -349,12 +350,12 @@ class MainWindow(QMainWindow): self.data.setWFData(self.fnames) elif self.fnames is None and self.okToContinue(): self.data.setWFData(self.getWFFnames()) - self.plotData() + self.plotWaveformData() - def plotData(self): + def plotWaveformData(self): self.getData().plotData(self.getDataWidget()) - def filterData(self): + def filterWaveformData(self): if self.getData(): kwargs = {} freq = self.getFilterOptions().getFreq() diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index 164fd39b..e6048ee8 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -242,8 +242,7 @@ class PilotDataStructure(object): def expandDataPath(self): datapath = os.path.join(self.getFields()['ROOT'], - self.getFields()['DATABASE'], - "*{0}".format(self.getFields()['SUFFIX'])) + self.getFields()['DATABASE']) return datapath diff --git a/pylot/core/util/__init__.py b/pylot/core/util/__init__.py index e73d5455..0d9575d0 100755 --- a/pylot/core/util/__init__.py +++ b/pylot/core/util/__init__.py @@ -1,6 +1,6 @@ from pylot.core.util.connection import checkurl from pylot.core.util.defaults import FILTERDEFAULTS -from pylot.core.util.errors import OptionsError, FormatError +from pylot.core.util.errors import OptionsError, FormatError, DatastructureError from pylot.core.util.layouts import layoutStationButtons from pylot.core.util.utils import fnConstructor, createArrival, createEvent,\ createPick, createAmplitude, createOrigin, createMagnitude, getOwner, \ diff --git a/pylot/core/util/errors.py b/pylot/core/util/errors.py index e2157135..6ae3b8fe 100644 --- a/pylot/core/util/errors.py +++ b/pylot/core/util/errors.py @@ -10,4 +10,7 @@ class OptionsError(Exception): pass class FormatError(Exception): - pass \ No newline at end of file + pass + +class DatastructureError(Exception): + pass diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index b69347f3..805bef25 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -118,8 +118,7 @@ def createEvent(origintime, cinfo, etype, resID=None, authority_id=None): def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station, - wfseedstr, - authority_id): + wfseedstr, authority_id): ''' createPick - function to create an ObsPy Pick diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 65c5406d..601c6d6e 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -110,9 +110,7 @@ class PropertiesDlg(QDialog): def accept(self, *args, **kwargs): self.apply() self.destroy() - - def reject(self, *args, **kwargs): - self.destroy() + return self.accepted def apply(self): for widint in range(self.tabWidget.count()):