Verified Commit 1e57ffb3 authored by Marco Kurzynski's avatar Marco Kurzynski
Browse files

added pool

parent 3667a2ca
......@@ -453,13 +453,6 @@ def process_helper(channel_number, channel_file, records, NBBtemp=None, IBBtemp
iUNCBTO[i], iUNCBTP[i]))
mlt.close()
# Read number of ranges
NRNGS = int(str.strip(os.environ.get('NRNGS')))
# FIXME: Do something in the future if there is more then 1 range
if NRNGS >= 2:
logger.error("Add more code :)")
WN = str.strip(os.environ.get(f'C{channel_number}_WN'))
# Lower bound of spectral range
WNLO = int(str.split(WN)[0])
......
......@@ -26,6 +26,24 @@ logger = logging.getLogger(__name__)
# NBBtemp=317.925
IBBtemp = 273.182
# used in processing pool
def process_record(record, c1_file, c2_file, output_path, no_spectral, times, sceneMirrorPositions):
logger.info('Record {0} scene mirror position = {1}'.format(record, sceneMirrorPositions[record - 1]))
# Returns wavenumbers, obs_ice, pred_ice, obs_3body, pred_3body
logger.debug('Running bbcal')
lw,sw = bbcal.process(str(c1_file), str(c2_file), record, IBBtemp=IBBtemp, output_path=output_path)
IBB = []
NBB = []
if sceneMirrorPositions[record - 1] == 83:
NBB = (record, times[record - 1], lw[5], sw[5])
if no_spectral is False:
make_NBB_plot(str(c1_file), lw, sw, record, output_path)
elif sceneMirrorPositions[record - 1] == 84:
IBB = (record, times[record - 1], lw[6], sw[6])
if no_spectral is False:
make_IBB_plot(str(c1_file), lw, sw, record, output_path)
return NBB,IBB
def to_int(arg):
try:
......@@ -585,20 +603,16 @@ def main(directory, output_dir=None, record_range=None, excluded_records=None, s
IBB = []
if separate is True:
for record in records:
logger.info('Record {0} scene mirror position = {1}'.format(record, sceneMirrorPositions[record - 1]))
# Returns wavenumbers, obs_ice, pred_ice, obs_3body, pred_3body
logger.debug('Running bbcal')
lw,sw = bbcal.process(str(c1_file), str(c2_file), record, IBBtemp=IBBtemp, output_path=output_path)
if sceneMirrorPositions[record - 1] == 83:
NBB.append((record, times[record - 1], lw[5], sw[5]))
if no_spectral is False:
make_NBB_plot(str(c1_file), lw, sw, record, output_path)
elif sceneMirrorPositions[record - 1] == 84:
IBB.append((record, times[record - 1], lw[6], sw[6]))
if no_spectral is False:
make_IBB_plot(str(c1_file), lw, sw, record, output_path)
from multiprocessing import Pool
with Pool(processes = int(str.strip(os.environ.get('NRNGS')))) as p:
from functools import partial
worker = partial(process_record, c1_file=c1_file, c2_file=c2_file, output_path=output_path, no_spectral=no_spectral, times=times, sceneMirrorPositions=sceneMirrorPositions)
data = p.map(worker, records)
for d in data:
if len(d[0]) > 0:
NBB.append(d[0])
if len(d[1]) > 0:
IBB.append(d[1])
if len(NBB) > 0:
with open(os.path.join(output_path, 'NBB.avg'), 'w') as file:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment