merged 3 files

Merge branch 'develop' of ariadne.geophysik.ruhr-uni-bochum.de:/data/git/pylot into develop

Conflicts:
	pylot/core/active/activeSeismoPick.py
	pylot/core/active/seismicshot.py
	pylot/core/active/surveyPlotTools.py
This commit is contained in:
Marcel Paffrath 2015-10-19 13:15:28 +02:00
commit 195352a7ca
31 changed files with 454 additions and 289 deletions

View File

@ -8,11 +8,11 @@ import glob
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from obspy.core import read from obspy.core import read
from pylot.core.util import _getVersionString
from pylot.core.read.data import Data from pylot.core.read.data import Data
from pylot.core.read.inputs import AutoPickParameter from pylot.core.read.inputs import AutoPickParameter
from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.pick.autopick import autopickevent from pylot.core.pick.autopick import autopickevent
from pylot.core.util.version import get_git_version as _getVersionString
__version__ = _getVersionString() __version__ = _getVersionString()

View File

@ -1,10 +1,10 @@
<RCC> <RCC>
<qresource> <qresource>
<file>icons/pylot.ico</file> <file>icons/pylot.ico</file>
<file>icons/pylot.png</file> <file>icons/pylot.png</file>
<file>icons/printer.png</file> <file>icons/printer.png</file>
<file>icons/delete.png</file> <file>icons/delete.png</file>
<file>icons/key_E.png</file> <file>icons/key_E.png</file>
<file>icons/key_N.png</file> <file>icons/key_N.png</file>
<file>icons/key_P.png</file> <file>icons/key_P.png</file>
<file>icons/key_Q.png</file> <file>icons/key_Q.png</file>
@ -14,7 +14,7 @@
<file>icons/key_U.png</file> <file>icons/key_U.png</file>
<file>icons/key_V.png</file> <file>icons/key_V.png</file>
<file>icons/key_W.png</file> <file>icons/key_W.png</file>
<file>icons/key_Z.png</file> <file>icons/key_Z.png</file>
<file>icons/filter.png</file> <file>icons/filter.png</file>
<file>icons/sync.png</file> <file>icons/sync.png</file>
<file>icons/zoom_0.png</file> <file>icons/zoom_0.png</file>

View File

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@ -1 +1,2 @@
# -*- coding: utf-8 -*-
__author__ = 'sebastianw' __author__ = 'sebastianw'

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys import sys
import numpy as np import numpy as np
from pylot.core.active import seismicshot from pylot.core.active import seismicshot
@ -166,8 +167,8 @@ class Survey(object):
def countAllTraces(self): def countAllTraces(self):
numtraces = 0 numtraces = 0
for line in self.getShotlist(): for shot in self.getShotlist():
for line in self.getReceiverlist(): for rec in self.getReceiverlist():
numtraces += 1 numtraces += 1
return numtraces return numtraces

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import numpy as np import numpy as np
def vgrids2VTK(inputfile = 'vgrids.in', outputfile = 'vgrids.vtk'): def vgrids2VTK(inputfile = 'vgrids.in', outputfile = 'vgrids.vtk'):

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys import sys
from obspy import read from obspy import read
from obspy import Stream from obspy import Stream

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys import sys
import numpy as np import numpy as np
from scipy.interpolate import griddata from scipy.interpolate import griddata

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys import sys
import numpy as np import numpy as np
from scipy.interpolate import griddata from scipy.interpolate import griddata

View File

@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os import os
import numpy as np import numpy as np
from obspy.core import read from obspy.core import read
@ -31,8 +34,7 @@ class SeismicShot(object):
self.snr = {} self.snr = {}
self.snrthreshold = {} self.snrthreshold = {}
self.timeArray = {} self.timeArray = {}
self.paras = {} self.paras = {'shotname': obsfile}
self.paras['shotname'] = obsfile
def removeEmptyTraces(self): def removeEmptyTraces(self):
traceIDs = [] traceIDs = []
@ -154,7 +156,7 @@ class SeismicShot(object):
def getPickError(self, traceID): def getPickError(self, traceID):
pickerror = abs(self.getEarliest(traceID) - self.getLatest(traceID)) pickerror = abs(self.getEarliest(traceID) - self.getLatest(traceID))
if np.isnan(pickerror) == True: if np.isnan(pickerror) == True:
print "SPE is NaN for shot %s, traceID %s"%(self.getShotnumber(), traceID) print("SPE is NaN for shot %s, traceID %s"%(self.getShotnumber(), traceID))
return pickerror return pickerror
def getStreamTraceIDs(self): def getStreamTraceIDs(self):
@ -179,7 +181,7 @@ class SeismicShot(object):
def getPickwindow(self, traceID): def getPickwindow(self, traceID):
try: try:
self.pickwindow[traceID] self.pickwindow[traceID]
except KeyError, e: except KeyError as e:
print('no pickwindow for trace %s, set to %s' % (traceID, self.getCut())) print('no pickwindow for trace %s, set to %s' % (traceID, self.getCut()))
self.setPickwindow(traceID, self.getCut()) self.setPickwindow(traceID, self.getCut())
return self.pickwindow[traceID] return self.pickwindow[traceID]
@ -262,17 +264,21 @@ class SeismicShot(object):
return Stream(traces) return Stream(traces)
else: else:
self.setPick(traceID, None) self.setPick(traceID, None)
print 'Warning: ambigious or empty traceID: %s' % traceID print('Warning: ambigious or empty traceID: %s' % traceID)
#raise ValueError('ambigious or empty traceID: %s' % traceID) #raise ValueError('ambigious or empty traceID: %s' % traceID)
def pickTraces(self, traceID, windowsize, folm = 0.6, HosAic = 'hos'): ########## input variables ########## def pickTraces(self, traceID, pickmethod, windowsize, folm = 0.6, HosAic = 'hos'): ########## input variables ##########
# LOCALMAX NOT IMPLEMENTED!
''' '''
Intitiate picking for a trace. Intitiate picking for a trace.
:param: traceID :param: traceID
:type: int :type: int
:param: pickmethod, use either 'threshold' or 'localmax' method. (localmax not yet implemented 04_08_15)
:type: string
:param: cutwindow (equals HOScf 'cut' variable) :param: cutwindow (equals HOScf 'cut' variable)
:type: tuple :type: tuple
@ -296,7 +302,13 @@ class SeismicShot(object):
self.timeArray[traceID] = hoscf.getTimeArray() self.timeArray[traceID] = hoscf.getTimeArray()
aiccftime, hoscftime = self.threshold(hoscf, aiccf, windowsize, self.getPickwindow(traceID), folm) if pickmethod == 'threshold':
aiccftime, hoscftime = self.threshold(hoscf, aiccf, windowsize, self.getPickwindow(traceID), folm)
#setpick = {'threshold':self.threshold,
# 'localmax':self.localmax}
#aiccftime, hoscftime = setpick[pickmethod](hoscf, aiccf, windowsize, pickwindow)
setHosAic = {'hos': hoscftime, setHosAic = {'hos': hoscftime,
'aic': aiccftime} 'aic': aiccftime}
@ -497,6 +509,7 @@ class SeismicShot(object):
:param: (tnoise, tgap, tsignal), as used in pylot SNR :param: (tnoise, tgap, tsignal), as used in pylot SNR
''' '''
from pylot.core.pick.utils import getSNR from pylot.core.pick.utils import getSNR
tgap = self.getTgap() tgap = self.getTgap()

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import math import math
import numpy as np import numpy as np

View File

@ -1,16 +1,69 @@
import numpy as np #!/usr/bin/env python
# -*- coding: utf-8 -*-
from pylab import *
startpos = []
endpos = []
def generateSurvey(obsdir, shotlist):
from obspy.core import read
from pylot.core.active import seismicshot
shot_dict = {}
for shotnumber in shotlist: # loop over data files
# generate filenames and read manual picks to a list
obsfile = obsdir + str(shotnumber) + '_pickle.dat'
#obsfile = obsdir + str(shotnumber) + '.dat'
if not obsfile in shot_dict.keys():
shot_dict[shotnumber] = []
shot_dict[shotnumber] = seismicshot.SeismicShot(obsfile)
shot_dict[shotnumber].setParameters('shotnumber', shotnumber)
return shot_dict
def setParametersForShots(cutwindow, tmovwind, tsignal, tgap, receiverfile, sourcefile, shot_dict):
for shot in shot_dict.values():
shot.setCut(cutwindow)
shot.setTmovwind(tmovwind)
shot.setTsignal(tsignal)
shot.setTgap(tgap)
shot.setRecfile(receiverfile)
shot.setSourcefile(sourcefile)
shot.setOrder(order = 4)
def removeEmptyTraces(shot_dict):
filename = 'removeEmptyTraces.out'
filename2 = 'updateTraces.out'
outfile = open(filename, 'w')
outfile2 = open(filename2, 'w')
for shot in shot_dict.values():
del_traceIDs = shot.updateTraceList()
removed = shot.removeEmptyTraces()
if removed is not None:
outfile.writelines('shot: %s, removed empty traces: %s\n' %(shot.getShotnumber(), removed))
outfile2.writelines('shot: %s, removed traceID(s) %s because they were not found in the corresponding stream\n' %(shot.getShotnumber(), del_traceIDs))
print '\nremoveEmptyTraces, updateTraces: Finished! See %s and %s for more information of removed traces.\n' %(filename, filename2)
outfile.close()
outfile2.close()
def readParameters(parfile, parameter): def readParameters(parfile, parameter):
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
parameterConfig = ConfigParser() parameterConfig = ConfigParser()
parameterConfig.read('parfile') parameterConfig.read('parfile')
value = parameterConfig.get('vars', parameter).split('#')[0] value = parameterConfig.get('vars', parameter).split('\t')[0]
value = value.replace(" ", "")
return value return value
def setArtificialPick(shot_dict, traceID, pick):
for shot in shot_dict.values():
shot.setPick(traceID, pick)
shot.setPickwindow(traceID, shot.getCut())
def fitSNR4dist(shot_dict, shiftdist = 5): def fitSNR4dist(shot_dict, shiftdist = 5):
import numpy as np
dists = [] dists = []
picks = [] picks = []
snrs = [] snrs = []
@ -31,6 +84,7 @@ def fitSNR4dist(shot_dict, shiftdist = 5):
plotFittedSNR(dists, snrthresholds, snrs) plotFittedSNR(dists, snrthresholds, snrs)
return fit_fn #### ZU VERBESSERN, sollte fertige funktion wiedergeben return fit_fn #### ZU VERBESSERN, sollte fertige funktion wiedergeben
def plotFittedSNR(dists, snrthresholds, snrs): def plotFittedSNR(dists, snrthresholds, snrs):
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
plt.interactive(True) plt.interactive(True)
@ -42,12 +96,84 @@ def plotFittedSNR(dists, snrthresholds, snrs):
plt.legend() plt.legend()
def setFittedSNR(shot_dict, shiftdist = 5, p1 = 0.004, p2 = -0.004): def setFittedSNR(shot_dict, shiftdist = 5, p1 = 0.004, p2 = -0.004):
import numpy as np
#fit_fn = fitSNR4dist(shot_dict) #fit_fn = fitSNR4dist(shot_dict)
fit_fn = np.poly1d([p1, p2]) fit_fn = np.poly1d([p1, p2])
for shot in shot_dict.values(): for shot in shot_dict.values():
for traceID in shot.getTraceIDlist(): ### IMPROVE for traceID in shot.getTraceIDlist(): ### IMPROVE
shot.setSNRthreshold(traceID, 1/(fit_fn(shot.getDistance(traceID) + shiftdist)**2)) ### s.o. shot.setSNRthreshold(traceID, 1/(fit_fn(shot.getDistance(traceID) + shiftdist)**2)) ### s.o.
print "\nsetFittedSNR: Finished setting of fitted SNR-threshold" print "setFittedSNR: Finished setting of fitted SNR-threshold"
#def linearInterp(dist_med, dist_start
def exportFMTOMO(shot_dict, directory = 'FMTOMO_export', sourcefile = 'input_sf.in', ttFileExtension = '.tt'):
count = 0
fmtomo_factor = 1000 # transforming [m/s] -> [km/s]
LatAll = []; LonAll = []; DepthAll = []
srcfile = open(directory + '/' + sourcefile, 'w')
srcfile.writelines('%10s\n' %len(shot_dict)) # number of sources
for shotnumber in getShotlist(shot_dict):
shot = getShotForShotnumber(shot_dict, shotnumber)
ttfilename = str(shotnumber) + ttFileExtension
(x, y, z) = shot.getSrcLoc() # getSrcLoc returns (x, y, z)
srcfile.writelines('%10s %10s %10s\n' %(getAngle(y), getAngle(x), (-1)*z)) # lat, lon, depth
LatAll.append(getAngle(y)); LonAll.append(getAngle(x)); DepthAll.append((-1)*z)
srcfile.writelines('%10s\n' %1) #
srcfile.writelines('%10s %10s %10s\n' %(1, 1, ttfilename))
ttfile = open(directory + '/' + ttfilename, 'w')
traceIDlist = shot.getTraceIDlist()
traceIDlist.sort()
ttfile.writelines(str(countPickedTraces(shot)) + '\n')
for traceID in traceIDlist:
if shot.getPick(traceID) is not None:
pick = shot.getPick(traceID) * fmtomo_factor
delta = shot.getPickError(traceID) * fmtomo_factor
(x, y, z) = shot.getRecLoc(traceID)
ttfile.writelines('%20s %20s %20s %10s %10s\n' %(getAngle(y), getAngle(x), (-1)*z, pick, delta))
LatAll.append(getAngle(y)); LonAll.append(getAngle(x)); DepthAll.append((-1)*z)
count += 1
ttfile.close()
srcfile.close()
print 'Wrote output for %s traces' %count
print 'WARNING: output generated for FMTOMO-obsdata. Obsdata seems to take Lat, Lon, Depth and creates output for FMTOMO as Depth, Lat, Lon'
print 'Dimensions of the seismic Array, transformed for FMTOMO, are Depth(%s, %s), Lat(%s, %s), Lon(%s, %s)'%(
min(DepthAll), max(DepthAll), min(LatAll), max(LatAll), min(LonAll), max(LonAll))
def getShotlist(shot_dict):
shotlist = []
for shot in shot_dict.values():
shotlist.append(shot.getShotnumber())
shotlist.sort()
return shotlist
def getShotForShotnumber(shot_dict, shotnumber):
for shot in shot_dict.values():
if shot.getShotnumber() == shotnumber:
return shot
def getAngle(distance):
'''
Function returns the angle on a Sphere of the radius R = 6371 [km] for a distance [km].
'''
import numpy as np
PI = np.pi
R = 6371.
angle = distance * 180 / (PI * R)
return angle
def countPickedTraces(shot):
numtraces = 0
for traceID in shot.getTraceIDlist():
if shot.getPick(traceID) is not None:
numtraces += 1
print "countPickedTraces: Found %s picked traces in shot number %s" %(numtraces, shot.getShotnumber())
return numtraces
def countAllPickedTraces(shot_dict):
traces = 0
for shot in shot_dict.values():
traces += countPickedTraces(shot)
return traces
def findTracesInRanges(shot_dict, distancebin, pickbin): def findTracesInRanges(shot_dict, distancebin, pickbin):
''' '''
@ -61,6 +187,7 @@ def findTracesInRanges(shot_dict, distancebin, pickbin):
:param: pickbin :param: pickbin
:type: tuple, (t1[s], t2[s]) :type: tuple, (t1[s], t2[s])
''' '''
shots_found = {} shots_found = {}
for shot in shot_dict.values(): for shot in shot_dict.values():
@ -72,3 +199,6 @@ def findTracesInRanges(shot_dict, distancebin, pickbin):
shots_found[shot.getShotnumber()].append(traceID) shots_found[shot.getShotnumber()].append(traceID)
return shots_found return shots_found

View File

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@ -6,7 +6,7 @@ from obspy.signal.trigger import coincidenceTrigger
class CoincidenceTimes(): class CoincidenceTimes(object):
def __init__(self, st, comp='Z', coinum=4, sta=1., lta=10., on=5., off=1.): def __init__(self, st, comp='Z', coinum=4, sta=1., lta=10., on=5., off=1.):
_type = 'recstalta' _type = 'recstalta'

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Created August/September 2015. Created August/September 2015.
@ -142,7 +143,7 @@ class DCfc(Magnitude):
''' '''
def calcsourcespec(self): def calcsourcespec(self):
print ("Calculating source spectrum ....") print ("Calculating source spectrum ....")
self.w0 = None # DC-value self.w0 = None # DC-value
self.fc = None # corner frequency self.fc = None # corner frequency

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Created Oct/Nov 2014 Created Oct/Nov 2014
@ -319,7 +320,7 @@ class ARZcf(CharacteristicFunction):
cf = np.zeros(len(xnp)) cf = np.zeros(len(xnp))
loopstep = self.getARdetStep() loopstep = self.getARdetStep()
arcalci = ldet + self.getOrder() #AR-calculation index arcalci = ldet + self.getOrder() #AR-calculation index
for i in range(ldet + self.getOrder(), tend - lpred - 1): for i in range(ldet + self.getOrder(), tend - lpred - 1):
if i == arcalci: if i == arcalci:
#determination of AR coefficients #determination of AR coefficients
#to speed up calculation, AR-coefficients are calculated only every i+loopstep[1]! #to speed up calculation, AR-coefficients are calculated only every i+loopstep[1]!
@ -366,7 +367,7 @@ class ARZcf(CharacteristicFunction):
rhs = np.zeros(self.getOrder()) rhs = np.zeros(self.getOrder())
for k in range(0, self.getOrder()): for k in range(0, self.getOrder()):
for i in range(rind, ldet+1): for i in range(rind, ldet+1):
ki = k + 1 ki = k + 1
rhs[k] = rhs[k] + data[i] * data[i - ki] rhs[k] = rhs[k] + data[i] * data[i - ki]
#recursive calculation of data array (second sum at left part of eq. 6.5 in Kueperkoch et al. 2012) #recursive calculation of data array (second sum at left part of eq. 6.5 in Kueperkoch et al. 2012)

View File

@ -312,7 +312,7 @@ class PragPicker(AutoPicking):
else: else:
for i in range(1, len(self.cf)): for i in range(1, len(self.cf)):
if i > ismooth: if i > ismooth:
ii1 = i - ismooth; ii1 = i - ismooth
cfsmooth[i] = cfsmooth[i - 1] + (self.cf[i] - self.cf[ii1]) / ismooth cfsmooth[i] = cfsmooth[i - 1] + (self.cf[i] - self.cf[ii1]) / ismooth
else: else:
cfsmooth[i] = np.mean(self.cf[1 : i]) cfsmooth[i] = np.mean(self.cf[1 : i])

View File

@ -1 +1,2 @@
# -*- coding: utf-8 -*-
# #

View File

@ -317,29 +317,29 @@ def autopickstation(wfstream, pickparam):
data = Data() data = Data()
[corzdat, restflag] = data.restituteWFData(invdir, zdat) [corzdat, restflag] = data.restituteWFData(invdir, zdat)
if restflag == 1: if restflag == 1:
# integrate to displacement # integrate to displacement
corintzdat = integrate.cumtrapz(corzdat[0], None, corzdat[0].stats.delta) corintzdat = integrate.cumtrapz(corzdat[0], None, corzdat[0].stats.delta)
# class needs stream object => build it # class needs stream object => build it
z_copy = zdat.copy() z_copy = zdat.copy()
z_copy[0].data = corintzdat z_copy[0].data = corintzdat
# largest detectable period == window length # largest detectable period == window length
# after P pulse for calculating source spectrum # after P pulse for calculating source spectrum
winzc = (1 / bpz2[0]) * z_copy[0].stats.sampling_rate winzc = (1 / bpz2[0]) * z_copy[0].stats.sampling_rate
impickP = mpickP * z_copy[0].stats.sampling_rate impickP = mpickP * z_copy[0].stats.sampling_rate
wfzc = z_copy[0].data[impickP : impickP + winzc] wfzc = z_copy[0].data[impickP : impickP + winzc]
# calculate spectrum using only first cycles of # calculate spectrum using only first cycles of
# waveform after P onset! # waveform after P onset!
zc = crossings_nonzero_all(wfzc) zc = crossings_nonzero_all(wfzc)
if np.size(zc) == 0: if np.size(zc) == 0:
print ("Something is wrong with the waveform, " \ print ("Something is wrong with the waveform, " \
"no zero crossings derived!") "no zero crossings derived!")
print ("Cannot calculate source spectrum!") print ("Cannot calculate source spectrum!")
else: else:
calcwin = (zc[3] - zc[0]) * z_copy[0].stats.delta calcwin = (zc[3] - zc[0]) * z_copy[0].stats.delta
# calculate source spectrum and get w0 and fc # calculate source spectrum and get w0 and fc
specpara = DCfc(z_copy, mpickP, calcwin, iplot) specpara = DCfc(z_copy, mpickP, calcwin, iplot)
w0 = specpara.getw0() w0 = specpara.getw0()
fc = specpara.getfc() fc = specpara.getfc()
print ("autopickstation: P-weight: %d, SNR: %f, SNR[dB]: %f, " \ print ("autopickstation: P-weight: %d, SNR: %f, SNR[dB]: %f, " \
"Polarity: %s" % (Pweight, SNRP, SNRPdB, FM)) "Polarity: %s" % (Pweight, SNRP, SNRPdB, FM))

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
# #
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
@ -495,9 +496,9 @@ def wadaticheck(pickdic, dttolerance, iplot):
if len(SPtimes) >= 3: if len(SPtimes) >= 3:
# calculate slope # calculate slope
p1 = np.polyfit(Ppicks, SPtimes, 1) p1 = np.polyfit(Ppicks, SPtimes, 1)
wdfit = np.polyval(p1, Ppicks) wdfit = np.polyval(p1, Ppicks)
wfitflag = 0 wfitflag = 0
# calculate vp/vs ratio before check # calculate vp/vs ratio before check
@ -534,40 +535,40 @@ def wadaticheck(pickdic, dttolerance, iplot):
pickdic[key]['S']['marked'] = marker pickdic[key]['S']['marked'] = marker
if len(checkedPpicks) >= 3: if len(checkedPpicks) >= 3:
# calculate new slope # calculate new slope
p2 = np.polyfit(checkedPpicks, checkedSPtimes, 1) p2 = np.polyfit(checkedPpicks, checkedSPtimes, 1)
wdfit2 = np.polyval(p2, checkedPpicks) wdfit2 = np.polyval(p2, checkedPpicks)
# calculate vp/vs ratio after check # calculate vp/vs ratio after check
cvpvsr = p2[0] + 1 cvpvsr = p2[0] + 1
print ("wadaticheck: Average Vp/Vs ratio after check: %f" % cvpvsr) print ("wadaticheck: Average Vp/Vs ratio after check: %f" % cvpvsr)
print ("wadatacheck: Skipped %d S pick(s)" % ibad) print ("wadatacheck: Skipped %d S pick(s)" % ibad)
else: else:
print ("###############################################") print ("###############################################")
print ("wadatacheck: Not enough checked S-P times available!") print ("wadatacheck: Not enough checked S-P times available!")
print ("Skip Wadati check!") print ("Skip Wadati check!")
checkedonsets = pickdic checkedonsets = pickdic
else: else:
print ("wadaticheck: Not enough S-P times available for reliable regression!") print ("wadaticheck: Not enough S-P times available for reliable regression!")
print ("Skip wadati check!") print ("Skip wadati check!")
wfitflag = 1 wfitflag = 1
# plot results # plot results
if iplot > 1: if iplot > 1:
plt.figure(iplot) plt.figure(iplot)
f1, = plt.plot(Ppicks, SPtimes, 'ro') f1, = plt.plot(Ppicks, SPtimes, 'ro')
if wfitflag == 0: if wfitflag == 0:
f2, = plt.plot(Ppicks, wdfit, 'k') f2, = plt.plot(Ppicks, wdfit, 'k')
f3, = plt.plot(checkedPpicks, checkedSPtimes, 'ko') f3, = plt.plot(checkedPpicks, checkedSPtimes, 'ko')
f4, = plt.plot(checkedPpicks, wdfit2, 'g') f4, = plt.plot(checkedPpicks, wdfit2, 'g')
plt.title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f,' \ plt.title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f,' \
'Vp/Vs(checked)=%5.2f' % (len(SPtimes), vpvsr, cvpvsr)) 'Vp/Vs(checked)=%5.2f' % (len(SPtimes), vpvsr, cvpvsr))
plt.legend([f1, f2, f3, f4], ['Skipped S-Picks', 'Wadati 1', \ plt.legend([f1, f2, f3, f4], ['Skipped S-Picks', 'Wadati 1', \
'Reliable S-Picks', 'Wadati 2'], loc='best') 'Reliable S-Picks', 'Wadati 2'], loc='best')
else: else:
plt.title('Wadati-Diagram, %d S-P Times' % len(SPtimes)) plt.title('Wadati-Diagram, %d S-P Times' % len(SPtimes))
plt.ylabel('S-P Times [s]') plt.ylabel('S-P Times [s]')
plt.xlabel('P Times [s]') plt.xlabel('P Times [s]')
@ -614,7 +615,7 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot):
print ("Checking signal length ...") print ("Checking signal length ...")
if len(X) > 1: if len(X) > 1:
# all three components available # all three components available
# make sure, all components have equal lengths # make sure, all components have equal lengths
ilen = min([len(X[0].data), len(X[1].data), len(X[2].data)]) ilen = min([len(X[0].data), len(X[1].data), len(X[2].data)])
x1 = X[0][0:ilen] x1 = X[0][0:ilen]
@ -641,7 +642,7 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot):
numoverthr = len(np.where(rms[isignal] >= minsiglevel)[0]) numoverthr = len(np.where(rms[isignal] >= minsiglevel)[0])
if numoverthr >= minnum: if numoverthr >= minnum:
print ("checksignallength: Signal reached required length.") print ("checksignallength: Signal reached required length.")
returnflag = 1 returnflag = 1
else: else:
print ("checksignallength: Signal shorter than required minimum signal length!") print ("checksignallength: Signal shorter than required minimum signal length!")
@ -651,7 +652,7 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot):
if iplot == 2: if iplot == 2:
plt.figure(iplot) plt.figure(iplot)
p1, = plt.plot(t,rms, 'k') p1, = plt.plot(t,rms, 'k')
p2, = plt.plot(t[inoise], rms[inoise], 'c') p2, = plt.plot(t[inoise], rms[inoise], 'c')
p3, = plt.plot(t[isignal],rms[isignal], 'r') p3, = plt.plot(t[isignal],rms[isignal], 'r')
p4, = plt.plot([t[isignal[0]], t[isignal[len(isignal)-1]]], \ p4, = plt.plot([t[isignal[0]], t[isignal[len(isignal)-1]]], \
@ -731,27 +732,27 @@ def checkPonsets(pickdic, dttolerance, iplot):
badjkmarker = 'badjkcheck' badjkmarker = 'badjkcheck'
for i in range(0, len(goodstations)): for i in range(0, len(goodstations)):
# mark P onset as checked and keep P weight # mark P onset as checked and keep P weight
pickdic[goodstations[i]]['P']['marked'] = goodmarker pickdic[goodstations[i]]['P']['marked'] = goodmarker
for i in range(0, len(badstations)): for i in range(0, len(badstations)):
# mark P onset and downgrade P weight to 9 # mark P onset and downgrade P weight to 9
# (not used anymore) # (not used anymore)
pickdic[badstations[i]]['P']['marked'] = badmarker pickdic[badstations[i]]['P']['marked'] = badmarker
pickdic[badstations[i]]['P']['weight'] = 9 pickdic[badstations[i]]['P']['weight'] = 9
for i in range(0, len(badjkstations)): for i in range(0, len(badjkstations)):
# mark P onset and downgrade P weight to 9 # mark P onset and downgrade P weight to 9
# (not used anymore) # (not used anymore)
pickdic[badjkstations[i]]['P']['marked'] = badjkmarker pickdic[badjkstations[i]]['P']['marked'] = badjkmarker
pickdic[badjkstations[i]]['P']['weight'] = 9 pickdic[badjkstations[i]]['P']['weight'] = 9
checkedonsets = pickdic checkedonsets = pickdic
if iplot > 1: if iplot > 1:
p1, = plt.plot(np.arange(0, len(Ppicks)), Ppicks, 'r+', markersize=14) p1, = plt.plot(np.arange(0, len(Ppicks)), Ppicks, 'r+', markersize=14)
p2, = plt.plot(igood, np.array(Ppicks)[igood], 'g*', markersize=14) p2, = plt.plot(igood, np.array(Ppicks)[igood], 'g*', markersize=14)
p3, = plt.plot([0, len(Ppicks) - 1], [pmedian, pmedian], 'g', \ p3, = plt.plot([0, len(Ppicks) - 1], [pmedian, pmedian], 'g', \
linewidth=2) linewidth=2)
for i in range(0, len(Ppicks)): for i in range(0, len(Ppicks)):
plt.text(i, Ppicks[i] + 0.2, stations[i]) 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.ylabel('Onset Time [s] from 1.1.1970')
@ -791,37 +792,37 @@ def jackknife(X, phi, h):
g = len(X) / h g = len(X) / h
if type(g) is not int: if type(g) is not int:
print ("jackknife: Cannot divide quantity X in equal sized subgroups!") print ("jackknife: Cannot divide quantity X in equal sized subgroups!")
print ("Choose another size for subgroups!") print ("Choose another size for subgroups!")
return PHI_jack, PHI_pseudo, PHI_sub return PHI_jack, PHI_pseudo, PHI_sub
else: else:
# estimator of undisturbed spot check # estimator of undisturbed spot check
if phi == 'MEA': if phi == 'MEA':
phi_sc = np.mean(X) phi_sc = np.mean(X)
elif phi == 'VAR': elif phi == 'VAR':
phi_sc = np.var(X) phi_sc = np.var(X)
elif phi == 'MED': elif phi == 'MED':
phi_sc = np.median(X) phi_sc = np.median(X)
# estimators of subgroups # estimators of subgroups
PHI_pseudo = [] PHI_pseudo = []
PHI_sub = [] PHI_sub = []
for i in range(0, g - 1): for i in range(0, g - 1):
# subgroup i, remove i-th sample # subgroup i, remove i-th sample
xx = X[:] xx = X[:]
del xx[i] del xx[i]
# calculate estimators of disturbed spot check # calculate estimators of disturbed spot check
if phi == 'MEA': if phi == 'MEA':
phi_sub = np.mean(xx) phi_sub = np.mean(xx)
elif phi == 'VAR': elif phi == 'VAR':
phi_sub = np.var(xx) phi_sub = np.var(xx)
elif phi == 'MED': elif phi == 'MED':
phi_sub = np.median(xx) phi_sub = np.median(xx)
PHI_sub.append(phi_sub) PHI_sub.append(phi_sub)
# pseudo values # pseudo values
phi_pseudo = g * phi_sc - ((g - 1) * phi_sub) phi_pseudo = g * phi_sc - ((g - 1) * phi_sub)
PHI_pseudo.append(phi_pseudo) PHI_pseudo.append(phi_pseudo)
# jackknife estimator # jackknife estimator
PHI_jack = np.mean(PHI_pseudo) PHI_jack = np.mean(PHI_pseudo)
@ -901,17 +902,17 @@ def checkZ4S(X, pick, zfac, checkwin, iplot):
# vertical P-coda level must exceed horizontal P-coda level # vertical P-coda level must exceed horizontal P-coda level
# zfac times encodalevel # zfac times encodalevel
if zcodalevel < minsiglevel: if zcodalevel < minsiglevel:
print ("checkZ4S: Maybe S onset? Skip this P pick!") print ("checkZ4S: Maybe S onset? Skip this P pick!")
else: else:
print ("checkZ4S: P onset passes checkZ4S test!") print ("checkZ4S: P onset passes checkZ4S test!")
returnflag = 1 returnflag = 1
if iplot > 1: if iplot > 1:
te = np.arange(0, edat[0].stats.npts / edat[0].stats.sampling_rate, te = np.arange(0, edat[0].stats.npts / edat[0].stats.sampling_rate,
edat[0].stats.delta) edat[0].stats.delta)
tn = np.arange(0, ndat[0].stats.npts / ndat[0].stats.sampling_rate, tn = np.arange(0, ndat[0].stats.npts / ndat[0].stats.sampling_rate,
ndat[0].stats.delta) ndat[0].stats.delta)
plt.plot(tz, z / max(z), 'k') plt.plot(tz, z / max(z), 'k')
plt.plot(tz[isignal], z[isignal] / max(z), 'r') plt.plot(tz[isignal], z[isignal] / max(z), 'r')
plt.plot(te, edat[0].data / max(edat[0].data) + 1, 'k') plt.plot(te, edat[0].data / max(edat[0].data) + 1, 'k')
plt.plot(te[isignal], edat[0].data[isignal] / max(edat[0].data) + 1, 'r') plt.plot(te[isignal], edat[0].data[isignal] / max(edat[0].data) + 1, 'r')

View File

@ -1 +1 @@
# -*- coding: utf-8 -*-

View File

@ -208,8 +208,7 @@ class FilterOptions(object):
def parseFilterOptions(self): def parseFilterOptions(self):
if self.getFilterType(): if self.getFilterType():
robject = {'type':self.getFilterType()} robject = {'type': self.getFilterType(), 'corners': self.getOrder()}
robject['corners'] = self.getOrder()
if len(self.getFreq()) > 1: if len(self.getFreq()) > 1:
robject['freqmin'] = self.getFreq()[0] robject['freqmin'] = self.getFreq()[0]
robject['freqmax'] = self.getFreq()[1] robject['freqmax'] = self.getFreq()[1]

View File

@ -1 +1,2 @@
# -*- coding: utf-8 -*-
from pylot.core.util.version import get_git_version as _getVersionString from pylot.core.util.version import get_git_version as _getVersionString

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
''' '''
Created on 10.11.2014 Created on 10.11.2014

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
''' '''
Created on 10.11.2014 Created on 10.11.2014

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys import sys
from PySide.QtCore import QThread, Signal from PySide.QtCore import QThread, Signal

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
# #
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, time import sys, time
from PySide.QtGui import QApplication from PySide.QtGui import QApplication

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys import sys
import matplotlib import matplotlib

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, time import sys, time
from PySide.QtGui import QApplication from PySide.QtGui import QApplication

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, time import sys, time
from PySide.QtGui import QApplication from PySide.QtGui import QApplication
@ -9,7 +11,7 @@ dialogs = [FilterOptionsDialog, PropertiesDlg, HelpForm]
app = QApplication(sys.argv) app = QApplication(sys.argv)
for dlg in dialogs: for dlg in dialogs:
win = dlg() win = dlg()
win.show() win.show()
time.sleep(1) time.sleep(1)
win.destroy() win.destroy()