Skip to content

Commit

Permalink
mods for multiprocessing and language changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kdere committed Mar 8, 2024
1 parent c746e8e commit 89da385
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ChiantiPy/core/Mspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class mspectrum(ionTrails, specTrails):
verbose: whether to allow certain print statements
'''
def __init__(self, temperature, eDensity, wavelength, filter=(chfilters.gaussianR, 1000.), label=0,
elementList = None, ionList = None, minAbund=None, keepIons=0, abundance=None, doLines=1,
doContinuum=1, allLines = 1, em=None, proc=3, verbose = 0, timeout=0.1):
elementList = None, ionList = None, minAbund=None, keepIons=0, abundance=None, doLines=True,
doContinuum=True, allLines = True, em=None, proc=3, verbose = False, timeout=0.1):
#
wavelength = np.atleast_1d(wavelength)
if wavelength.size < 2:
Expand Down Expand Up @@ -193,7 +193,7 @@ def __init__(self, temperature, eDensity, wavelength, filter=(chfilters.gaussian
#

self.ionGate(elementList = elementList, ionList = ionList, minAbund=minAbund, doLines=doLines,
doContinuum=doContinuum, verbose = 0)
doContinuum=doContinuum, verbose = False)
# print(' \n in mspectrum \n')
# for one in self.Todo.keys():
# print(' %s %s'%(one, self.Todo[one]))
Expand All @@ -217,6 +217,11 @@ def __init__(self, temperature, eDensity, wavelength, filter=(chfilters.gaussian
ffWorkerQSize = ffWorkerQ.qsize()
fbWorkerQSize = fbWorkerQ.qsize()
ionWorkerQSize = ionWorkerQ.qsize()

nCores = mp.cpu_count()
proc = min(proc, nCores)
if verbose:
print('# of processors/cores = %i'%(proc))
if doContinuum:
ffProcesses = []
for i in range(proc):
Expand Down Expand Up @@ -256,8 +261,6 @@ def __init__(self, temperature, eDensity, wavelength, filter=(chfilters.gaussian
#
if doLines:
ionProcesses = []
if ionWorkerQSize < proc:
proc = ionWorkerQSize
for i in range(proc):
p = mp.Process(target=mputil.doIonQ, args=(ionWorkerQ, ionDoneQ))
p.start()
Expand Down

0 comments on commit 89da385

Please sign in to comment.