[bugfix] fixed some bugs resulting from restructuring of serial/parallel picking

This commit is contained in:
Marcel Paffrath 2018-07-12 15:56:34 +02:00
parent 319343499b
commit 3b52b7a28f
3 changed files with 20 additions and 18 deletions

View File

@ -53,7 +53,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
:type savepath: str
:param savexml: export results in XML file if True
:type savexml: bool
:param station: list of station names or 'all' to pick all stations
:param station: choose specific station name or 'all' to pick all stations
:type station: str
:param iplot: logical variable for plotting: 0=none, 1=partial, 2=all
:type iplot: int
@ -149,8 +149,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
datastructure.modifyFields(**dsfields)
datastructure.setExpandFields(exf)
# check if default location routine NLLoc is available
if real_None(parameter['nllocbin']):
# check if default location routine NLLoc is available and all stations are used
if real_None(parameter['nllocbin']) and station=='all':
locflag = 1
# get NLLoc-root path
nllocroot = parameter.get('nllocroot')

View File

@ -70,21 +70,14 @@ def autopickevent(data, param, iplot=0, fig_dict=None, fig_dict_wadatijack=None,
for station in stations:
topick = data.select(station=station)
if iplot is None or iplot == 'None' or iplot == 0:
input_tuples.append((topick, param, apverbose, metadata, origin))
if iplot > 0:
all_onsets[station] = autopickstation(topick, param, verbose=apverbose,
iplot=iplot, fig_dict=fig_dict,
metadata=metadata, origin=origin)[0]
input_tuples.append((topick, param, apverbose, iplot, fig_dict, metadata, origin))
if iplot > 0:
print('iPlot Flag active: NO MULTIPROCESSING possible.')
return all_onsets
ncores = 1
# rename str for ncores in case ncores == 0 (use all cores)
# rename ncores for string representation in case ncores == 0 (use all cores)
ncores_str = ncores if ncores != 0 else 'all available'
print('Autopickstation: Distribute autopicking for {} '
'stations on {} cores.'.format(len(input_tuples), ncores_str))
@ -93,7 +86,6 @@ def autopickevent(data, param, iplot=0, fig_dict=None, fig_dict_wadatijack=None,
else:
results = parallel_picking(input_tuples, ncores)
for result, station in results:
if type(result) == dict:
all_onsets[station] = result
@ -102,6 +94,10 @@ def autopickevent(data, param, iplot=0, fig_dict=None, fig_dict_wadatijack=None,
result = 'Picker exited unexpectedly.'
print('Could not pick a station: {}\nReason: {}'.format(station, result))
# no Wadati/JK for single station (also valid for tuning mode)
if len(stations) == 1:
return all_onsets
# quality control
# median check and jackknife on P-onset times
jk_checked_onsets = checkPonsets(all_onsets, mdttolerance, jackfactor, iplot, fig_dict_wadatijack)
@ -132,10 +128,12 @@ def call_autopickstation(input_tuple):
:return: dictionary containing P pick, S pick and station name
:rtype: dict
"""
wfstream, pickparam, verbose, metadata, origin = input_tuple
wfstream, pickparam, verbose, iplot, fig_dict, metadata, origin = input_tuple
if fig_dict:
print('Running in interactive mode')
# multiprocessing not possible with interactive plotting
try:
return autopickstation(wfstream, pickparam, verbose, iplot=0, metadata=metadata, origin=origin)
return autopickstation(wfstream, pickparam, verbose, fig_dict=fig_dict, iplot=iplot, metadata=metadata, origin=origin)
except Exception as e:
return e, wfstream[0].stats.station

View File

@ -118,8 +118,12 @@ def gen_Pool(ncores=0):
"""
import multiprocessing
if ncores == 0:
ncores = multiprocessing.cpu_count()
ncores_max = multiprocessing.cpu_count()
if ncores == 0 or ncores > ncores_max:
ncores = ncores_max
if ncores > ncores_max:
print('Reduced number of requested CPU slots to available number: {}'.format(ncores))
print('gen_Pool: Generated multiprocessing Pool with {} cores\n'.format(ncores))