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

@ -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,8 +302,14 @@ class SeismicShot(object):
self.timeArray[traceID] = hoscf.getTimeArray() self.timeArray[traceID] = hoscf.getTimeArray()
if pickmethod == 'threshold':
aiccftime, hoscftime = self.threshold(hoscf, aiccf, windowsize, self.getPickwindow(traceID), folm) 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.

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Created Oct/Nov 2014 Created Oct/Nov 2014

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

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

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