currently working on the plotting of waveforms; changes made to meet pre-requisites to data plotting
This commit is contained in:
parent
ef50c3d4d8
commit
64158174e6
29
QtPyLoT.py
29
QtPyLoT.py
@ -39,6 +39,8 @@ from pylot.core.util import checkurl
|
|||||||
from pylot.core.util import FormatError
|
from pylot.core.util import FormatError
|
||||||
from pylot.core.util import layoutStationButtons
|
from pylot.core.util import layoutStationButtons
|
||||||
from pylot.core.util import (FilterOptionsDialog,
|
from pylot.core.util import (FilterOptionsDialog,
|
||||||
|
NewEventDlg,
|
||||||
|
createEvent,
|
||||||
MPLWidget,
|
MPLWidget,
|
||||||
PropertiesDlg,
|
PropertiesDlg,
|
||||||
HelpForm)
|
HelpForm)
|
||||||
@ -150,8 +152,9 @@ class MainWindow(QMainWindow):
|
|||||||
filt = """Supported event formats (*.mat *.qml *.xml *.kor
|
filt = """Supported event formats (*.mat *.qml *.xml *.kor
|
||||||
*.evt)"""
|
*.evt)"""
|
||||||
caption = 'Select event to open'
|
caption = 'Select event to open'
|
||||||
self.fname = QFileDialog().getOpenFileName(self, caption=caption,
|
self.fname = QFileDialog().getOpenFileName(self,
|
||||||
filter=filt)
|
caption=caption,
|
||||||
|
filter=filt)
|
||||||
else:
|
else:
|
||||||
self.fname = unicode(action.data().toString())
|
self.fname = unicode(action.data().toString())
|
||||||
if not self.okToContinue():
|
if not self.okToContinue():
|
||||||
@ -162,6 +165,9 @@ class MainWindow(QMainWindow):
|
|||||||
self.fname = fname
|
self.fname = fname
|
||||||
self.data = Data(evtdata=self.fname)
|
self.data = Data(evtdata=self.fname)
|
||||||
|
|
||||||
|
def getWFFnames(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def saveData(self):
|
def saveData(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
exform = settings.value('data/exportFormat', 'None')
|
exform = settings.value('data/exportFormat', 'None')
|
||||||
@ -202,6 +208,11 @@ class MainWindow(QMainWindow):
|
|||||||
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
|
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
|
||||||
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
||||||
helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton)
|
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,
|
openEventAction = self.createAction("&Open event ...", self.loadData,
|
||||||
QKeySequence.Open, openIcon,
|
QKeySequence.Open, openIcon,
|
||||||
"Open an event.")
|
"Open an event.")
|
||||||
@ -242,7 +253,8 @@ class MainWindow(QMainWindow):
|
|||||||
homepage (internet connection available),
|
homepage (internet connection available),
|
||||||
or shipped documentation files.""")
|
or shipped documentation files.""")
|
||||||
self.fileMenu = self.menuBar().addMenu('&File')
|
self.fileMenu = self.menuBar().addMenu('&File')
|
||||||
self.fileMenuActions = (openEventAction, saveEventAction,
|
self.fileMenuActions = (newEventAction, openEventAction,
|
||||||
|
saveEventAction, None,
|
||||||
prefsEventAction, quitAction)
|
prefsEventAction, quitAction)
|
||||||
self.fileMenu.aboutToShow.connect(self.updateFileMenu)
|
self.fileMenu.aboutToShow.connect(self.updateFileMenu)
|
||||||
self.updateFileMenu()
|
self.updateFileMenu()
|
||||||
@ -253,7 +265,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.addMenuActions(self.editMenu, editActions)
|
self.addMenuActions(self.editMenu, editActions)
|
||||||
|
|
||||||
self.helpMenu = self.menuBar().addMenu('&Help')
|
self.helpMenu = self.menuBar().addMenu('&Help')
|
||||||
helpActions = (helpAction)
|
|
||||||
helpActions = (helpAction, )
|
helpActions = (helpAction, )
|
||||||
self.addMenuActions(self.helpMenu, helpActions)
|
self.addMenuActions(self.helpMenu, helpActions)
|
||||||
|
|
||||||
@ -271,7 +282,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.setCentralWidget(_widget)
|
self.setCentralWidget(_widget)
|
||||||
|
|
||||||
def addMenuActions(self, menu, actions):
|
def addMenuActions(self, menu, actions):
|
||||||
for action in (actions):
|
for action in actions:
|
||||||
if action is None:
|
if action is None:
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
else:
|
else:
|
||||||
@ -357,6 +368,14 @@ class MainWindow(QMainWindow):
|
|||||||
def printEvent(self):
|
def printEvent(self):
|
||||||
pass
|
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):
|
def closeEvent(self, event):
|
||||||
if self.okToContinue():
|
if self.okToContinue():
|
||||||
self.closing.emit()
|
self.closing.emit()
|
||||||
|
@ -1 +1 @@
|
|||||||
2961-dirty
|
ef50-dirty
|
||||||
|
@ -30,9 +30,7 @@ class Data(object):
|
|||||||
def __init__(self, parent=None, evtdata=None):
|
def __init__(self, parent=None, evtdata=None):
|
||||||
try:
|
try:
|
||||||
if parent:
|
if parent:
|
||||||
self.wfdata = read(parent.fnames)
|
self.wfdata = read(parent.getWFFnames())
|
||||||
else:
|
|
||||||
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!'
|
||||||
inform = 'Variable wfdata will be empty.'
|
inform = 'Variable wfdata will be empty.'
|
||||||
@ -45,7 +43,7 @@ class Data(object):
|
|||||||
warnio.setStandarButtons(QMessageBox.Ok)
|
warnio.setStandarButtons(QMessageBox.Ok)
|
||||||
warnio.setIcon(QMessageBox.Warning)
|
warnio.setIcon(QMessageBox.Warning)
|
||||||
else:
|
else:
|
||||||
print msg, '\n', details
|
print msg, "\n", details
|
||||||
self.wfdata = Stream()
|
self.wfdata = Stream()
|
||||||
else:
|
else:
|
||||||
self.wfdata = Stream()
|
self.wfdata = Stream()
|
||||||
@ -56,7 +54,7 @@ class Data(object):
|
|||||||
cat = readEvents(evtdata)
|
cat = readEvents(evtdata)
|
||||||
self.evtdata = cat[0]
|
self.evtdata = cat[0]
|
||||||
elif evtdata is not None:
|
elif evtdata is not None:
|
||||||
cat = readMatPhases(evtdata)
|
cat = self.readMatPhases(evtdata)
|
||||||
else: # create an empty Event object
|
else: # create an empty Event object
|
||||||
self.newevent = True
|
self.newevent = True
|
||||||
self.evtdata = Event()
|
self.evtdata = Event()
|
||||||
@ -78,6 +76,8 @@ class Data(object):
|
|||||||
|
|
||||||
if fnout is None:
|
if fnout is None:
|
||||||
ID = self.evtdata.getEventID()
|
ID = self.evtdata.getEventID()
|
||||||
|
else:
|
||||||
|
ID = self.getID()
|
||||||
# handle forbidden filenames especially on windows systems
|
# handle forbidden filenames especially on windows systems
|
||||||
fnout = fnConstructor(ID)
|
fnout = fnConstructor(ID)
|
||||||
|
|
||||||
|
@ -4,10 +4,12 @@ from pylot.core.util.errors import OptionsError
|
|||||||
from pylot.core.util.errors import FormatError
|
from pylot.core.util.errors import FormatError
|
||||||
from pylot.core.util.layouts import layoutStationButtons
|
from pylot.core.util.layouts import layoutStationButtons
|
||||||
from pylot.core.util.utils import fnConstructor
|
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 PickDlg
|
||||||
from pylot.core.util.widgets import HelpForm
|
from pylot.core.util.widgets import HelpForm
|
||||||
from pylot.core.util.widgets import FilterOptionsDialog
|
from pylot.core.util.widgets import FilterOptionsDialog
|
||||||
from pylot.core.util.widgets import PropertiesDlg
|
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.widgets import MPLWidget
|
||||||
from pylot.core.util.version import get_git_version as _getVersionString
|
from pylot.core.util.version import get_git_version as _getVersionString
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from obspy.core.event import *
|
||||||
|
|
||||||
def fnConstructor(s):
|
def fnConstructor(s):
|
||||||
|
|
||||||
@ -17,3 +17,8 @@ def fnConstructor(s):
|
|||||||
if badsuffix.match(fn):
|
if badsuffix.match(fn):
|
||||||
fn = '_' + fn
|
fn = '_' + fn
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
def createEvent(origintime, latitude, longitude, depth, **kwargs):
|
||||||
|
evt = Event()
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ Created on Wed Mar 19 11:27:35 2014
|
|||||||
@author: sebastianw
|
@author: sebastianw
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
import matplotlib
|
import matplotlib
|
||||||
|
|
||||||
matplotlib.use('Qt4Agg')
|
matplotlib.use('Qt4Agg')
|
||||||
@ -15,6 +16,7 @@ from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
|||||||
from PySide.QtGui import (QAction,
|
from PySide.QtGui import (QAction,
|
||||||
QApplication,
|
QApplication,
|
||||||
QComboBox,
|
QComboBox,
|
||||||
|
QDateTimeEdit,
|
||||||
QDialog,
|
QDialog,
|
||||||
QDialogButtonBox,
|
QDialogButtonBox,
|
||||||
QDoubleSpinBox,
|
QDoubleSpinBox,
|
||||||
@ -204,6 +206,66 @@ class GraphicsTab(PropTab):
|
|||||||
pass
|
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):
|
class FilterOptionsDialog(QDialog):
|
||||||
|
|
||||||
def __init__(self, parent=None, titleString="Filter options",
|
def __init__(self, parent=None, titleString="Filter options",
|
||||||
|
Loading…
Reference in New Issue
Block a user