huge structural rearrangement to resolve circular import problems

[add] new feature added to QtPyLoT capable of automatically picking an event from overview window
This commit is contained in:
2015-07-10 09:22:58 +02:00
parent f704d8b258
commit ea976295d0
13 changed files with 128 additions and 162 deletions

View File

@@ -1,10 +1 @@
from pylot.core.util.connection import checkurl
from pylot.core.util.defaults import FILTERDEFAULTS
from pylot.core.util.errors import OptionsError, FormatError, DatastructureError
from pylot.core.util.utils import fnConstructor, createArrival, createEvent,\
createPick, createAmplitude, createOrigin, createMagnitude, getOwner, \
getHash, getLogin, createCreationInfo, createResourceID, prepTimeAxis, \
getGlobalTimes, scaleWFData, demeanWFData
from pylot.core.util.widgets import PickDlg, HelpForm, FilterOptionsDialog,\
PropertiesDlg, NewEventDlg, MPLWidget, createAction
from pylot.core.util.version import get_git_version as _getVersionString

View File

@@ -6,7 +6,7 @@ Created on Wed Jan 26 17:47:25 2015
@author: sebastianw
"""
from pylot.core.read import SeiscompDataStructure, PilotDataStructure
from pylot.core.read.data import SeiscompDataStructure, PilotDataStructure
DATASTRUCTURE = {'PILOT': PilotDataStructure, 'SeisComP': SeiscompDataStructure,
None: None}

View File

@@ -17,7 +17,8 @@ class WorkerThread(QThread):
picks = self.func(self.data, self.param)
try:
self.parent().addPicks(picks)
for station in picks:
self.parent().addPicks(station, picks[station])
except AttributeError:
print picks

View File

@@ -10,7 +10,6 @@ import hashlib
import numpy as np
from obspy.core import UTCDateTime
import obspy.core.event as ope
from pylot.core.pick.utils import getnoisewin
def runProgram(cmd, parameter=None):
"""
@@ -119,28 +118,20 @@ def scaleWFData(data, factor=None, components='all'):
return data
def demeanWFData(data, t0, win, gap):
def demeanTrace(trace, window):
"""
returns the DATA where each trace is demean by the average value within
a desired time window WIN before T0 and a GAP
:param data: waveform stream object
:type data: `~obspy.core.stream.Stream`
:param t0: time before which the noise
:type t0: float
:param win: time window for average calculation
:type win: tuple
:param gap: gap window to avoid polluting the average
:type gap: float
:return: data
:rtype: `~obspy.core.stream.Stream`
WINDOW
:param trace: waveform trace object
:type trace: `~obspy.core.stream.Trace`
:param inoise: range of indices of DATA within the WINDOW
:type window: tuple
:return: trace
:rtype: `~obspy.core.stream.Trace`
"""
starttime = getGlobalTimes(data)[0]
for tr in data:
stime = tr.stats.starttime - starttime
t = prepTimeAxis(stime, tr)
inoise = getnoisewin(t, t0, win, gap)
tr.data -= tr.data[inoise].mean()
return data
trace.data -= trace.data[window].mean()
return trace
def getGlobalTimes(stream):
min_start = UTCDateTime()

View File

@@ -19,12 +19,12 @@ from PySide.QtGui import QAction, QApplication, QComboBox, QDateTimeEdit, \
from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
from PySide.QtWebKit import QWebView
from obspy import Stream, UTCDateTime
from pylot.core.read import FilterOptions
from pylot.core.read.inputs import FilterOptions
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin,\
getResolutionWindow
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS
from pylot.core.util import prepTimeAxis, getGlobalTimes, scaleWFData, \
demeanWFData
from pylot.core.util.utils import prepTimeAxis, getGlobalTimes, scaleWFData, \
demeanTrace
def createAction(parent, text, slot=None, shortcut=None, icon=None,
@@ -191,6 +191,8 @@ class PickDlg(QDialog):
else:
self.data = data
self.stime, self.etime = getGlobalTimes(self.getWFData())
# initialize plotting widget
self.multicompfig = MPLWidget(self)
@@ -336,6 +338,12 @@ class PickDlg(QDialog):
self.cidrelease = self.connectReleaseEvent(self.panRelease)
self.cidscroll = self.connectScrollEvent(self.scrollZoom)
def getStartTime(self):
return self.stime
def getEndTime(self):
return self.etime
def getComponents(self):
return self.components
@@ -446,13 +454,16 @@ class PickDlg(QDialog):
x_res = getResolutionWindow(snr)
data = demeanWFData(data=self.getWFData().copy(), t0=ini_pick,
win=noise_win, gap=gap_win)
# remove mean noise level from waveforms
for trace in wfdata:
t = prepTimeAxis(self.getStartTime(), trace)
inoise = getnoisewin(t, ini_pick, noise_win, gap_win)
trace = demeanTrace(trace=trace, window=inoise)
self.setXLims([ini_pick - x_res, ini_pick + x_res])
self.setYLims(np.array([-noiselevel * 2.5, noiselevel * 2.5]) +
trace_number)
self.getPlotWidget().plotWFData(wfdata=data,
self.getPlotWidget().plotWFData(wfdata=wfdata,
title=self.getStation() +
' picking mode',
zoomx=self.getXLims(),
@@ -482,7 +493,10 @@ class PickDlg(QDialog):
filteroptions = self.getFilterOptions(phase).parseFilterOptions()
data.filter(**filteroptions)
data = demeanWFData(data=data, t0=ini_pick, win=noise_win, gap=gap_win)
for trace in data:
t = prepTimeAxis(self.getStartTime(), trace)
inoise = getnoisewin(t, ini_pick, noise_win, gap_win)
trace = demeanTrace(trace, inoise)
horiz_comp = ('n', 'e')
@@ -576,9 +590,9 @@ class PickDlg(QDialog):
else:
return
mpp = picks['mpp']
epp = picks['epp']
lpp = picks['lpp']
mpp = picks['mpp'] - self.getStartTime()
epp = picks['epp'] - self.getStartTime()
lpp = picks['lpp'] - self.getStartTime()
spe = picks['spe']
ax.fill_between([epp, lpp], ylims[0], ylims[1],