[add] --ncores flag added to autoPyLoT call, also enabled in GUI widget
This commit is contained in:
@@ -21,7 +21,7 @@ from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \
|
||||
from pylot.core.util.utils import getPatternLine, gen_Pool
|
||||
|
||||
|
||||
def autopickevent(data, param, iplot=0, fig_dict=None):
|
||||
def autopickevent(data, param, iplot=0, fig_dict=None, ncores=0):
|
||||
stations = []
|
||||
all_onsets = {}
|
||||
input_tuples = []
|
||||
@@ -50,7 +50,7 @@ def autopickevent(data, param, iplot=0, fig_dict=None):
|
||||
print('iPlot Flag active: NO MULTIPROCESSING possible.')
|
||||
return all_onsets
|
||||
|
||||
pool = gen_Pool()
|
||||
pool = gen_Pool(ncores)
|
||||
result = pool.map(call_autopickstation, input_tuples)
|
||||
pool.close()
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ def restitute_trace(input_tuple):
|
||||
return tr, remove_trace
|
||||
|
||||
|
||||
def restitute_data(data, invtype, inobj, unit='VEL', force=False):
|
||||
def restitute_data(data, invtype, inobj, unit='VEL', force=False, ncores=0):
|
||||
"""
|
||||
takes a data stream and a path_to_inventory and returns the corrected
|
||||
waveform data stream
|
||||
@@ -293,7 +293,7 @@ def restitute_data(data, invtype, inobj, unit='VEL', force=False):
|
||||
input_tuples.append((tr, invtype, inobj, unit, force))
|
||||
data.remove(tr)
|
||||
|
||||
pool = gen_Pool()
|
||||
pool = gen_Pool(ncores)
|
||||
result = pool.map(restitute_trace, input_tuples)
|
||||
pool.close()
|
||||
|
||||
|
||||
@@ -33,10 +33,14 @@ def getindexbounds(f, eta):
|
||||
return mi, l, u
|
||||
|
||||
|
||||
def gen_Pool(ncores='max'):
|
||||
def gen_Pool(ncores=0):
|
||||
'''
|
||||
:param ncores: number of CPU cores for multiprocessing.Pool, if ncores == 0 use all available
|
||||
:return: multiprocessing.Pool object
|
||||
'''
|
||||
import multiprocessing
|
||||
|
||||
if ncores == 'max':
|
||||
if ncores == 0:
|
||||
ncores = multiprocessing.cpu_count()
|
||||
|
||||
pool = multiprocessing.Pool(ncores)
|
||||
|
||||
@@ -2869,7 +2869,6 @@ class AutoPickDlg(QDialog):
|
||||
maxcores = multiprocessing.cpu_count()
|
||||
self.sb_ncores.setMinimum(1)
|
||||
self.sb_ncores.setMaximum(maxcores)
|
||||
self.sb_ncores.setEnabled(False) # not yet implemented in autoPyLoT
|
||||
self.layout_ncores.addWidget(self.label_ncores)
|
||||
self.layout_ncores.addWidget(self.sb_ncores)
|
||||
self.layout_ncores.setStretch(0, 1)
|
||||
@@ -2903,7 +2902,7 @@ class AutoPickDlg(QDialog):
|
||||
|
||||
def accept(self):
|
||||
self.exportParameter()
|
||||
self.job_widget.start(self.pp_export)
|
||||
self.job_widget.start(self.pp_export, self.sb_ncores.value())
|
||||
QDialog.accept(self)
|
||||
|
||||
|
||||
@@ -2931,7 +2930,7 @@ class Submit2Grid(QWidget):
|
||||
default_command = 'qsub -l low -cwd -q TARGET_MACHINE -pe mpi-fu NCORES'
|
||||
self.textedit.setText(default_command)
|
||||
|
||||
def start(self, pp_export):
|
||||
def start(self, pp_export, ncores=None):
|
||||
self.genShellScript(pp_export)
|
||||
self.execute_script()
|
||||
|
||||
@@ -2966,12 +2965,14 @@ class SubmitLocal(QWidget):
|
||||
def start(self):
|
||||
print('subprocess Popen')
|
||||
|
||||
def start(self, pp_export):
|
||||
self.execute_command(pp_export)
|
||||
def start(self, pp_export, ncores):
|
||||
self.execute_command(pp_export, ncores)
|
||||
|
||||
def execute_command(self, pp_export):
|
||||
def execute_command(self, pp_export, ncores):
|
||||
command = self.script_fn
|
||||
command.append(pp_export)
|
||||
command.append('--ncores')
|
||||
command.append(str(ncores))
|
||||
cmd_str = str()
|
||||
for item in command:
|
||||
cmd_str += item + ' '
|
||||
|
||||
Reference in New Issue
Block a user