non-working commit of autoPyLoT functionality in overview window

This commit is contained in:
Sebastian Wehling-Benatelli 2015-07-09 11:37:03 +02:00
parent 120f2743d2
commit 398a25f902
5 changed files with 80 additions and 28 deletions

View File

@ -34,15 +34,16 @@ from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
QActionGroup
QActionGroup, QListWidget
import numpy as np
from obspy.core import UTCDateTime
from pylot.core.read import Data, FilterOptions
from pylot.core.read import Data, FilterOptions, AutoPickParameter
from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \
checkurl, FormatError, FilterOptionsDialog, \
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
DatastructureError, createAction, getLogin, createCreationInfo, PickDlg
from pylot.core.util.thread import WorkerThread
from pylot.core.util.structure import DATASTRUCTURE
import icons_rc
@ -147,11 +148,13 @@ class MainWindow(QMainWindow):
filter_icon = QIcon()
filter_icon.addPixmap(QPixmap(':/icons/filter.png'))
z_icon = QIcon()
z_icon.addPixmap((QPixmap(':/icons/key_Z.png')))
z_icon.addPixmap(QPixmap(':/icons/key_Z.png'))
n_icon = QIcon()
n_icon.addPixmap((QPixmap(':/icons/key_N.png')))
n_icon.addPixmap(QPixmap(':/icons/key_N.png'))
e_icon = QIcon()
e_icon.addPixmap((QPixmap(':/icons/key_E.png')))
e_icon.addPixmap(QPixmap(':/icons/key_E.png'))
auto_icon = QIcon()
auto_icon.addPixmap(QPixmap(':/icons/sync.png'))
newEventAction = self.createAction(self, "&New event ...",
self.createNewEvent,
@ -261,6 +264,17 @@ class MainWindow(QMainWindow):
componentToolBar.setObjectName("PhaseTools")
self.addActions(componentToolBar, componentActions)
auto_pick = self.createAction(parent=self, text='autoPick',
slot=self.autoPick, shortcut='Alt+Ctrl+A',
icon=auto_icon, tip='Automatically pick'
' the entire dataset'
' displayed!',
checkable=False)
autoPickToolBar = self.addToolBar("autoPyLoT")
autoPickActions = (auto_pick,)
self.addActions(autoPickToolBar, autoPickActions)
# pickToolBar = self.addToolBar("PickTools")
# pickToolActions = (selectStation, )
# pickToolBar.setObjectName("PickTools")
@ -570,6 +584,20 @@ class MainWindow(QMainWindow):
else:
self.updateStatus('picks discarded ({0})'.format(station))
def autoPick(self):
list = QListWidget()
autopick_parameter = AutoPickParameter('autoPyLoT_local.in')
list.addItem(str(autopick_parameter))
# Create the worker thread and run it
self.thread = WorkerThread(parent=self,
func=autopickevent,
data=self.getData().getWFData(),
param=autopick_parameter)
self.thread.message.connect(list.addItem)
self.thread.start()
def addPicks(self, station, picks):
stat_picks = self.getPicksOnStation(station)
if not stat_picks:

View File

@ -15,6 +15,7 @@
<file>icons/key_W.png</file>
<file>icons/key_Z.png</file>
<file>icons/filter.png</file>
<file>icons/sync.png</file>
<file>icons/zoom_in.png</file>
<file>icons/zoom_out.png</file>
<file>splash/splash.png</file>

File diff suppressed because one or more lines are too long

View File

@ -12,8 +12,25 @@ import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
from obspy.core import Stream, UTCDateTime
from pylot.core.pick.run_autopicking import run_autopicking
import warnings
import pdb
def autopickevent(data, param):
stations = []
for n in len(data):
station = data[n].stats.station
if station not in stations:
stations.append(station)
else:
continue
for station in stations:
topick = data.select(station=station)
stat_picks = run_autopicking(topick, param)
def earllatepicker(X, nfac, TSNR, Pick1, iplot=None):
'''
Function to derive earliest and latest possible pick after Diehl & Kissling (2009)

View File

@ -4,8 +4,9 @@ from PySide.QtCore import QThread, Signal
class WorkerThread(QThread):
message = Signal(str)
def __init__(self, func, data, param):
def __init__(self, parent, func, data, param):
super(WorkerThread, self).__init__()
self.setParent(parent)
self.func = func
self.data = data
self.param = param
@ -13,7 +14,12 @@ class WorkerThread(QThread):
def run(self):
sys.stdout = self
self.func(self.data, self.param)
picks = self.func(self.data, self.param)
try:
self.parent().addPicks(picks)
except AttributeError:
print picks
def write(self, text):
self.message.emit(text)