bugfixes in order to make the GUI work

This commit is contained in:
Sebastian Wehling-Benatelli 2015-02-17 13:17:01 +01:00
parent 091ab23b90
commit d15441900e
6 changed files with 24 additions and 24 deletions

View File

@ -35,7 +35,8 @@ from obspy.core import UTCDateTime
from pylot.core.read import Data, FilterOptions from pylot.core.read import Data, FilterOptions
from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \ from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \
checkurl, FormatError, layoutStationButtons, FilterOptionsDialog, \ checkurl, FormatError, layoutStationButtons, FilterOptionsDialog, \
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
DatastructureError
from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.structure import DATASTRUCTURE
@ -93,14 +94,17 @@ class MainWindow(QMainWindow):
self.dirty = False self.dirty = False
self.loadData() self.loadData()
self.updateFilterOptions() self.updateFilterOptions()
def setupUi(self):
try: try:
self.startTime = min( self.startTime = min(
[tr.stats.starttime for tr in self.data.wfdata]) [tr.stats.starttime for tr in self.data.wfdata])
except: except:
self.startTime = UTCDateTime() self.startTime = UTCDateTime()
def setupUi(self):
self.setWindowIcon(QIcon(":/icon.ico")) self.setWindowIcon(QIcon(":/icon.ico"))
xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)') 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 # create central matplotlib figure canvas widget
self.DataPlot = MPLWidget(parent=self, xlabel=xlab, ylabel=None, self.DataPlot = MPLWidget(parent=self, xlabel=xlab, ylabel=None,
title=plottitle) title=plottitle)
statsButtons = layoutStationButtons(self.getData(), self.getComponent())
_layout.addLayout(statsButtons)
_layout.addWidget(self.DataPlot) _layout.addWidget(self.DataPlot)
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon) openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
@ -147,7 +150,7 @@ class MainWindow(QMainWindow):
QCoreApplication.instance().quit, QCoreApplication.instance().quit,
QKeySequence.Close, quitIcon, QKeySequence.Close, quitIcon,
"Close event and quit PyLoT") "Close event and quit PyLoT")
filterAction = self.createAction("&Filter ...", self.filterData, filterAction = self.createAction("&Filter ...", self.filterWaveformData,
"Ctrl+F", QIcon(":/filter.png"), "Ctrl+F", QIcon(":/filter.png"),
"""Toggle un-/filtered waveforms """Toggle un-/filtered waveforms
to be displayed, according to the to be displayed, according to the
@ -194,9 +197,6 @@ class MainWindow(QMainWindow):
status.addPermanentWidget(self.eventLabel) status.addPermanentWidget(self.eventLabel)
status.showMessage("Ready", 500) status.showMessage("Ready", 500)
statsButtons = layoutStationButtons(self.getData(), self.getComponent())
_layout.addLayout(statsButtons)
_layout.addWidget(self.DataPlot)
_widget.setLayout(_layout) _widget.setLayout(_layout)
self.setCentralWidget(_widget) self.setCentralWidget(_widget)
@ -294,16 +294,17 @@ class MainWindow(QMainWindow):
else: else:
if self.dataStructure: if self.dataStructure:
searchPath = self.dataStructure.expandDataPath() searchPath = self.dataStructure.expandDataPath()
fnames, = QFileDialog.getOpenFileNames(self, fnames = QFileDialog.getOpenFileNames(self,
"Select waveform " "Select waveform "
"files:", "files:",
dir=searchPath) dir=searchPath)
self.fnames = fnames self.fnames = fnames
else: else:
raise ValueError('dataStructure not specified') raise DatastructureError('not specified')
return self.fnames return self.fnames
except ValueError: except DatastructureError, e:
print e
props = PropertiesDlg(self) props = PropertiesDlg(self)
if props.exec_() == QDialog.Accepted: if props.exec_() == QDialog.Accepted:
return self.getWFFnames() return self.getWFFnames()
@ -349,12 +350,12 @@ class MainWindow(QMainWindow):
self.data.setWFData(self.fnames) self.data.setWFData(self.fnames)
elif self.fnames is None and self.okToContinue(): elif self.fnames is None and self.okToContinue():
self.data.setWFData(self.getWFFnames()) self.data.setWFData(self.getWFFnames())
self.plotData() self.plotWaveformData()
def plotData(self): def plotWaveformData(self):
self.getData().plotData(self.getDataWidget()) self.getData().plotData(self.getDataWidget())
def filterData(self): def filterWaveformData(self):
if self.getData(): if self.getData():
kwargs = {} kwargs = {}
freq = self.getFilterOptions().getFreq() freq = self.getFilterOptions().getFreq()

View File

@ -242,8 +242,7 @@ class PilotDataStructure(object):
def expandDataPath(self): def expandDataPath(self):
datapath = os.path.join(self.getFields()['ROOT'], datapath = os.path.join(self.getFields()['ROOT'],
self.getFields()['DATABASE'], self.getFields()['DATABASE'])
"*{0}".format(self.getFields()['SUFFIX']))
return datapath return datapath

View File

@ -1,6 +1,6 @@
from pylot.core.util.connection import checkurl from pylot.core.util.connection import checkurl
from pylot.core.util.defaults import FILTERDEFAULTS 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.layouts import layoutStationButtons
from pylot.core.util.utils import fnConstructor, createArrival, createEvent,\ from pylot.core.util.utils import fnConstructor, createArrival, createEvent,\
createPick, createAmplitude, createOrigin, createMagnitude, getOwner, \ createPick, createAmplitude, createOrigin, createMagnitude, getOwner, \

View File

@ -10,4 +10,7 @@ class OptionsError(Exception):
pass pass
class FormatError(Exception): class FormatError(Exception):
pass pass
class DatastructureError(Exception):
pass

View File

@ -118,8 +118,7 @@ def createEvent(origintime, cinfo, etype, resID=None, authority_id=None):
def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station, def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
wfseedstr, wfseedstr, authority_id):
authority_id):
''' '''
createPick - function to create an ObsPy Pick createPick - function to create an ObsPy Pick

View File

@ -110,9 +110,7 @@ class PropertiesDlg(QDialog):
def accept(self, *args, **kwargs): def accept(self, *args, **kwargs):
self.apply() self.apply()
self.destroy() self.destroy()
return self.accepted
def reject(self, *args, **kwargs):
self.destroy()
def apply(self): def apply(self):
for widint in range(self.tabWidget.count()): for widint in range(self.tabWidget.count()):