Merge branch 'develop'

This commit is contained in:
Sebastian Wehling-Benatelli 2016-05-27 07:45:04 +02:00
commit a1d29a45cb
3 changed files with 28 additions and 16 deletions

View File

@ -9,6 +9,12 @@ from pylot.core.util.utils import worker, _pickle_method
copy_reg.pickle(types.MethodType, _pickle_method)
def ppick(shot):
picks = []
for traceID in shot.getTraceIDlist():
picks.append((shot.getShotnumber(), traceID, shot.pickTrace(traceID)))
return picks
class Survey(object):
def __init__(self, path, sourcefile, receiverfile, useDefaultParas=False):
'''
@ -200,14 +206,14 @@ class Survey(object):
plt.xlabel('Difference in time (auto - manual) [s]')
return diffs
def pickShot(self, shTr):
shotnumber, traceID = shTr
shot = self.getShotForShotnumber(shotnumber)
traceID, pick = shot.pickTrace(traceID)
return shotnumber, traceID, pick
# def pickShot(self, shTr):
# shotnumber, traceID = shTr
# shot = self.getShotForShotnumber(shotnumber)
# traceID, pick = shot.pickTrace(traceID)
# return shotnumber, traceID, pick
def pickAllShots(self, vmin=333, vmax=5500, folm=0.6, HosAic='hos',
aicwindow=(10, 0)):
aicwindow=(10, 0), cores = 1):
'''
Automatically pick all traces of all shots of the survey.
@ -228,7 +234,7 @@ class Survey(object):
count = 0
tpicksum = starttime - starttime
shTr = []
shotlist = []
for shot in self.data.values():
tstartpick = datetime.now()
@ -237,13 +243,14 @@ class Survey(object):
count += 1
#shot.pickParallel(folm)
shot.setPickParameters(folm = folm, method = HosAic, aicwindow = aicwindow)
for traceID in shot.getTraceIDlist():
shTr.append((shot.getShotnumber(), traceID))
shotlist.append(shot)
picks = worker(self.pickShot, shTr, async = True)
picks = worker(ppick, shotlist, cores)
for shotnumber, traceID, pick in picks.get():
self.getShotForShotnumber(shotnumber).setPick(traceID, pick)
for item in picks:
for it in item:
shotnumber, traceID, pick = it
self.getShotForShotnumber(shotnumber).setPick(traceID, pick)
# tpicksum += (datetime.now() - tstartpick);
# tpick = tpicksum / count

View File

@ -383,7 +383,7 @@ class SeismicShot(object):
setHosAic = {'hos': hoscftime,
'aic': aiccftime}
return traceID, setHosAic[self.getMethod()]
return setHosAic[self.getMethod()]
def setEarllatepick(self, traceID, nfac=1.5):
tgap = self.getTgap()

View File

@ -9,25 +9,29 @@ import re
import subprocess
from obspy.core import UTCDateTime
def _pickle_method(m):
if m.im_self is None:
return getattr, (m.im_class, m.im_func.func_name)
else:
return getattr, (m.im_self, m.im_func.func_name)
def worker(func, input, cores = 'max', async = False):
return result
def worker(func, input, cores='max', async=False):
import multiprocessing
if cores == 'max':
cores = multiprocessing.cpu_count()
pool = multiprocessing.Pool(cores)
pool = multiprocessing.Pool(cores)
if async == True:
result = pool.map_async(func, input)
else:
result = pool.map(func, input)
pool.close()
return result
def demeanTrace(trace, window):
"""
returns the DATA where each trace is demean by the average value within
@ -249,6 +253,7 @@ def runProgram(cmd, parameter=None):
output = subprocess.check_output('{} | tee /dev/stderr'.format(cmd),
shell=True)
if __name__ == "__main__":
import doctest