currently working on the plotting of waveforms; changes made to meet pre-requisites to data plotting

This commit is contained in:
Sebastian Wehling-Benatelli 2015-01-22 16:41:52 +01:00
parent ef50c3d4d8
commit 64158174e6
6 changed files with 100 additions and 12 deletions

View File

@ -39,6 +39,8 @@ from pylot.core.util import checkurl
from pylot.core.util import FormatError
from pylot.core.util import layoutStationButtons
from pylot.core.util import (FilterOptionsDialog,
NewEventDlg,
createEvent,
MPLWidget,
PropertiesDlg,
HelpForm)
@ -150,8 +152,9 @@ class MainWindow(QMainWindow):
filt = """Supported event formats (*.mat *.qml *.xml *.kor
*.evt)"""
caption = 'Select event to open'
self.fname = QFileDialog().getOpenFileName(self, caption=caption,
filter=filt)
self.fname = QFileDialog().getOpenFileName(self,
caption=caption,
filter=filt)
else:
self.fname = unicode(action.data().toString())
if not self.okToContinue():
@ -162,6 +165,9 @@ class MainWindow(QMainWindow):
self.fname = fname
self.data = Data(evtdata=self.fname)
def getWFFnames(self):
pass
def saveData(self):
settings = QSettings()
exform = settings.value('data/exportFormat', 'None')
@ -202,6 +208,11 @@ class MainWindow(QMainWindow):
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton)
newIcon = self.style().standardIcon(QStyle.SP_FileIcon)
newEventAction = self.createAction("&New event ...",
self.createNewEvent,
QKeySequence.New, newIcon,
"Create a new event.")
openEventAction = self.createAction("&Open event ...", self.loadData,
QKeySequence.Open, openIcon,
"Open an event.")
@ -242,7 +253,8 @@ class MainWindow(QMainWindow):
homepage (internet connection available),
or shipped documentation files.""")
self.fileMenu = self.menuBar().addMenu('&File')
self.fileMenuActions = (openEventAction, saveEventAction,
self.fileMenuActions = (newEventAction, openEventAction,
saveEventAction, None,
prefsEventAction, quitAction)
self.fileMenu.aboutToShow.connect(self.updateFileMenu)
self.updateFileMenu()
@ -253,7 +265,6 @@ class MainWindow(QMainWindow):
self.addMenuActions(self.editMenu, editActions)
self.helpMenu = self.menuBar().addMenu('&Help')
helpActions = (helpAction)
helpActions = (helpAction, )
self.addMenuActions(self.helpMenu, helpActions)
@ -271,7 +282,7 @@ class MainWindow(QMainWindow):
self.setCentralWidget(_widget)
def addMenuActions(self, menu, actions):
for action in (actions):
for action in actions:
if action is None:
menu.addSeparator()
else:
@ -357,6 +368,14 @@ class MainWindow(QMainWindow):
def printEvent(self):
pass
def createNewEvent(self):
if self.okToContinue():
new = NewEventDlg()
if new.exec_():
evtpar = new.getValues()
self.data = Data(self, evtdata=createEvent(**evtpar))
self.dirty = True
def closeEvent(self, event):
if self.okToContinue():
self.closing.emit()

View File

@ -1 +1 @@
2961-dirty
ef50-dirty

View File

@ -30,9 +30,7 @@ class Data(object):
def __init__(self, parent=None, evtdata=None):
try:
if parent:
self.wfdata = read(parent.fnames)
else:
self.wfdata = read()
self.wfdata = read(parent.getWFFnames())
except IOError, e:
msg = 'An I/O error occured while loading data!'
inform = 'Variable wfdata will be empty.'
@ -45,7 +43,7 @@ class Data(object):
warnio.setStandarButtons(QMessageBox.Ok)
warnio.setIcon(QMessageBox.Warning)
else:
print msg, '\n', details
print msg, "\n", details
self.wfdata = Stream()
else:
self.wfdata = Stream()
@ -56,7 +54,7 @@ class Data(object):
cat = readEvents(evtdata)
self.evtdata = cat[0]
elif evtdata is not None:
cat = readMatPhases(evtdata)
cat = self.readMatPhases(evtdata)
else: # create an empty Event object
self.newevent = True
self.evtdata = Event()
@ -78,6 +76,8 @@ class Data(object):
if fnout is None:
ID = self.evtdata.getEventID()
else:
ID = self.getID()
# handle forbidden filenames especially on windows systems
fnout = fnConstructor(ID)

View File

@ -4,10 +4,12 @@ from pylot.core.util.errors import OptionsError
from pylot.core.util.errors import FormatError
from pylot.core.util.layouts import layoutStationButtons
from pylot.core.util.utils import fnConstructor
from pylot.core.util.utils import createEvent
from pylot.core.util.widgets import PickDlg
from pylot.core.util.widgets import HelpForm
from pylot.core.util.widgets import FilterOptionsDialog
from pylot.core.util.widgets import PropertiesDlg
from pylot.core.util.widgets import NewEventDlg
from pylot.core.util.widgets import MPLWidget
from pylot.core.util.version import get_git_version as _getVersionString

View File

@ -3,7 +3,7 @@
# -*- coding: utf-8 -*-
import re
from obspy.core.event import *
def fnConstructor(s):
@ -17,3 +17,8 @@ def fnConstructor(s):
if badsuffix.match(fn):
fn = '_' + fn
return fn
def createEvent(origintime, latitude, longitude, depth, **kwargs):
evt = Event()

View File

@ -5,6 +5,7 @@ Created on Wed Mar 19 11:27:35 2014
@author: sebastianw
"""
import datetime
import matplotlib
matplotlib.use('Qt4Agg')
@ -15,6 +16,7 @@ from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from PySide.QtGui import (QAction,
QApplication,
QComboBox,
QDateTimeEdit,
QDialog,
QDialogButtonBox,
QDoubleSpinBox,
@ -204,6 +206,66 @@ class GraphicsTab(PropTab):
pass
class NewEventDlg(QDialog):
def __init__(self, parent=None, titleString="Create a new event"):
"""
QDialog object utilized to create a new event manually.
"""
super(NewEventDlg, self).__init__()
self.setupUI()
now = datetime.datetime.now()
self.eventTimeEdit.setDateTime(now)
# event dates in the future are forbidden
self.eventTimeEdit.setMaximumDateTime(now)
self.latEdit.setText("51.0000")
self.lonEdit.setText("7.0000")
self.depEdit.setText("10.0")
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
def getValues(self):
if self.accepted():
return {'origintime' : self.eventTimeEdit.dateTime().toPyDateTime(),
'latitude' : self.latEdit.text(),
'longitude' : self.lonEdit.text(),
'depth' : self.depEdit.text()}
def setupUI(self):
# create widget objects
timeLabel = QLabel()
timeLabel.setText("Select time: ")
self.eventTimeEdit = QDateTimeEdit()
latLabel = QLabel()
latLabel.setText("Latitude: ")
self.latEdit = QLineEdit()
lonLabel = QLabel()
lonLabel.setText("Longitude: ")
self.lonEdit = QLineEdit()
depLabel = QLabel()
depLabel.setText("Depth: ")
self.depEdit = QLineEdit()
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
grid = QGridLayout()
grid.addWidget(timeLabel, 0, 0)
grid.addWidget(self.eventTimeEdit, 0, 1)
grid.addWidget(latLabel, 1, 0)
grid.addWidget(self.latEdit, 1, 1)
grid.addWidget(lonLabel, 2, 0)
grid.addWidget(self.lonEdit, 2, 1)
grid.addWidget(depLabel, 3, 0)
grid.addWidget(self.depEdit, 3, 1)
grid.addWidget(self.buttonBox, 4, 1)
self.setLayout(grid)
class FilterOptionsDialog(QDialog):
def __init__(self, parent=None, titleString="Filter options",