non-working commit of autoPyLoT functionality in overview window
This commit is contained in:
parent
120f2743d2
commit
398a25f902
38
QtPyLoT.py
38
QtPyLoT.py
@ -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:
|
||||
|
@ -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
@ -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)
|
||||
@ -254,7 +271,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
|
||||
FM = '+'
|
||||
elif P1[0] > 0 and P2[0] <= 0:
|
||||
FM = '+'
|
||||
|
||||
|
||||
print 'fmpicker: Found polarity %s' % FM
|
||||
|
||||
if iplot > 1:
|
||||
@ -530,7 +547,7 @@ def wadaticheck(pickdic, dttolerance, iplot):
|
||||
print 'wadaticheck: Not enough S-P times available for reliable regression!'
|
||||
print 'Skip wadati check!'
|
||||
wfitflag = 1
|
||||
|
||||
|
||||
# plot results
|
||||
if iplot > 1:
|
||||
plt.figure(iplot)
|
||||
@ -615,12 +632,12 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot):
|
||||
print 'checksignallength: Signal shorter than required minimum signal length!'
|
||||
print 'Presumably picked noise peak, pick is rejected!'
|
||||
returnflag = 0
|
||||
|
||||
|
||||
if iplot == 2:
|
||||
plt.figure(iplot)
|
||||
p1, = plt.plot(t,x, 'k')
|
||||
p2, = plt.plot(t[inoise], e[inoise], 'c')
|
||||
p3, = plt.plot(t[isignal],e[isignal], 'r')
|
||||
p3, = plt.plot(t[isignal],e[isignal], 'r')
|
||||
p2, = plt.plot(t[inoise], e[inoise])
|
||||
p3, = plt.plot(t[isignal],e[isignal], 'r')
|
||||
p4, = plt.plot([t[isignal[0]], t[isignal[len(isignal)-1]]], \
|
||||
@ -642,7 +659,7 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot):
|
||||
|
||||
def checkPonsets(pickdic, dttolerance, iplot):
|
||||
'''
|
||||
Function to check statistics of P-onset times: Control deviation from
|
||||
Function to check statistics of P-onset times: Control deviation from
|
||||
median (maximum adjusted deviation = dttolerance) and apply pseudo-
|
||||
bootstrapping jackknife.
|
||||
|
||||
@ -722,7 +739,7 @@ def checkPonsets(pickdic, dttolerance, iplot):
|
||||
for i in range(0, len(Ppicks)):
|
||||
plt.text(i, Ppicks[i] + 0.2, stations[i])
|
||||
|
||||
plt.xlabel('Number of P Picks')
|
||||
plt.xlabel('Number of P Picks')
|
||||
plt.ylabel('Onset Time [s] from 1.1.1970')
|
||||
plt.legend([p1, p2, p3], ['Skipped P Picks', 'Good P Picks', 'Median'], \
|
||||
loc='best')
|
||||
@ -751,7 +768,7 @@ def jackknife(X, phi, h):
|
||||
: param: h, size of subgroups, optinal, default = 1
|
||||
: type: integer
|
||||
'''
|
||||
|
||||
|
||||
PHI_jack = None
|
||||
PHI_pseudo = None
|
||||
PHI_sub = None
|
||||
@ -786,7 +803,7 @@ def jackknife(X, phi, h):
|
||||
phi_sub = np.var(xx)
|
||||
elif phi == 'MED':
|
||||
phi_sub = np.median(xx)
|
||||
|
||||
|
||||
PHI_sub.append(phi_sub)
|
||||
# pseudo values
|
||||
phi_pseudo = g * phi_sc - ((g - 1) * phi_sub)
|
||||
@ -799,21 +816,21 @@ def jackknife(X, phi, h):
|
||||
|
||||
def checkZ4S(X, pick, zfac, checkwin, iplot):
|
||||
'''
|
||||
Function to compare energy content of vertical trace with
|
||||
energy content of horizontal traces to detect spuriously
|
||||
Function to compare energy content of vertical trace with
|
||||
energy content of horizontal traces to detect spuriously
|
||||
picked S onsets instead of P onsets. Usually, P coda shows
|
||||
larger longitudal energy on vertical trace than on horizontal
|
||||
traces, where the transversal energy is larger within S coda.
|
||||
Be careful: there are special circumstances, where this is not
|
||||
Be careful: there are special circumstances, where this is not
|
||||
the case!
|
||||
|
||||
: param: X, fitered(!) time series, three traces
|
||||
: type: `~obspy.core.stream.Stream`
|
||||
: type: `~obspy.core.stream.Stream`
|
||||
|
||||
: param: pick, initial (AIC) P onset time
|
||||
: type: float
|
||||
|
||||
: param: zfac, factor for threshold determination,
|
||||
|
||||
: param: zfac, factor for threshold determination,
|
||||
vertical energy must exceed coda level times zfac
|
||||
to declare a pick as P onset
|
||||
: type: float
|
||||
@ -841,7 +858,7 @@ def checkZ4S(X, pick, zfac, checkwin, iplot):
|
||||
ndat = X.select(component="N")
|
||||
if len(ndat) == 0: # check for other components
|
||||
ndat = X.select(component="1")
|
||||
|
||||
|
||||
|
||||
z = zdat[0].data
|
||||
tz = np.arange(0, zdat[0].stats.npts / zdat[0].stats.sampling_rate,
|
||||
@ -863,7 +880,7 @@ def checkZ4S(X, pick, zfac, checkwin, iplot):
|
||||
# calculate energy levels
|
||||
zcodalevel = max(absz[isignal])
|
||||
encodalevel = max(absen[isignal])
|
||||
|
||||
|
||||
# calculate threshold
|
||||
minsiglevel = encodalevel * zfac
|
||||
|
||||
@ -873,7 +890,7 @@ def checkZ4S(X, pick, zfac, checkwin, iplot):
|
||||
print 'checkZ4S: Maybe S onset? Skip this P pick!'
|
||||
else:
|
||||
print 'checkZ4S: P onset passes checkZ4S test!'
|
||||
returnflag = 1
|
||||
returnflag = 1
|
||||
|
||||
if iplot > 1:
|
||||
te = np.arange(0, edat[0].stats.npts / edat[0].stats.sampling_rate,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user