code changes for parallelization

This commit is contained in:
Marcel Paffrath 2016-05-25 14:24:19 +02:00
parent 8ca87bc777
commit 5057664b1d
2 changed files with 19 additions and 12 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,11 +206,11 @@ 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)):
@ -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 = 16)
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()