@@ -325,8 +325,11 @@ def gLikeLimits_to_lklcomLimits(input_dir,
325
325
326
326
# Getting the txt files of the input directory.
327
327
files = np .array ([x for x in os .listdir (input_dir ) if x .endswith (".txt" )])
328
+ channels = np .unique ([file .split ("_" )[0 ] for file in files ])
328
329
# Looping over the files and store the likelihood or ts tables into the lklcom hdf5 file.
329
330
svUL = {}
331
+ for channel in channels :
332
+ svUL [channel ] = {}
330
333
for file in files :
331
334
# Parsing the file name.
332
335
file_info = file .replace ('.txt' ,'' ).split ("_" )
@@ -341,14 +344,17 @@ def gLikeLimits_to_lklcomLimits(input_dir,
341
344
# Going through the table in the txt file and storing the entries in a 2D array.
342
345
table = np .array ([[i for i in line .split ()] for line in txt_file ], dtype = np .float32 )
343
346
344
- # Dumping the upper
347
+ # Dumping the upper limits
345
348
346
- col_name = "data"
347
349
if simulation != - 1 :
348
350
col_name = "simu_{}" .format (simulation )
349
- svUL [col_name ] = table [1 ]
351
+ else :
352
+ col_name = "data"
353
+ svUL [file_info [0 ]]['masses' ] = table [0 ]
354
+ svUL [file_info [0 ]][col_name ] = table [1 ]
350
355
351
- pd .DataFrame (data = svUL ).to_hdf (output_file , key = '{}/{}' .format (file_info [0 ], file_info [1 ]), mode = "a" )
356
+ for channel in channels :
357
+ pd .DataFrame (data = svUL [channel ]).to_hdf (output_file , key = '{}/{}' .format (channel , file_info [1 ]), mode = "a" )
352
358
353
359
def _gLikeLimits_to_lklcomLimits ():
354
360
"""
@@ -384,9 +390,13 @@ def merge_to_lklcom(input_dir,
384
390
385
391
# Getting the h5 files of the input directory.
386
392
files = np .array ([x for x in os .listdir (input_dir ) if x .endswith (".h5" ) or x .endswith (".hdf5" )])
387
-
393
+ channels = np .unique ([file .split ("_" )[0 ] for file in files ])
394
+
388
395
j_nuisance = False
389
396
svUL , svUL_Jnuisance = {}, {}
397
+ for channel in channels :
398
+ svUL [channel ] = {}
399
+ svUL_Jnuisance [channel ] = {}
390
400
for file in files :
391
401
# Parsing the file name.
392
402
file_info = file .replace ('.hdf5' ,'' ).replace ('.h5' ,'' ).split ("_" )
@@ -395,17 +405,18 @@ def merge_to_lklcom(input_dir,
395
405
data = pd .HDFStore ("{}/{}" .format (input_dir , file ), 'r' )
396
406
397
407
if '/masses' in data .keys ():
398
- svUL ['masses' ] = svUL_Jnuisance ['masses' ] = data ['masses' ][0 ]
408
+ svUL [file_info [ 0 ]][ 'masses' ] = svUL_Jnuisance [ file_info [ 0 ]] ['masses' ] = data ['masses' ][0 ]
399
409
if '/sigmavULs' in data .keys ():
400
- svUL [file_info [1 ]] = data ['sigmavULs' ][0 ]
410
+ svUL [file_info [0 ]][ file_info [ 1 ]] = data ['sigmavULs' ][0 ]
401
411
if '/sigmavULs_Jnuisance' in data .keys ():
402
412
j_nuisance = True
403
- svUL_Jnuisance [file_info [1 ]] = data ['sigmavULs_Jnuisance' ][0 ]
413
+ svUL_Jnuisance [file_info [0 ]][ file_info [ 1 ]] = data ['sigmavULs_Jnuisance' ][0 ]
404
414
405
415
# Write the panda DataFrames into the hdf5 file
406
- pd .DataFrame (data = svUL ).to_hdf (output_file , key = '{}/sigmavULs' .format (file_info [0 ]), mode = 'a' )
407
- if j_nuisance :
408
- pd .DataFrame (data = svUL_Jnuisance ).to_hdf (output_file , key = '{}/sigmavULs_Jnuisance' .format (file_info [0 ]), mode = 'a' )
416
+ for channel in channels :
417
+ pd .DataFrame (data = svUL [channel ]).to_hdf (output_file , key = '{}/sigmavULs' .format (channel ), mode = 'a' )
418
+ if j_nuisance :
419
+ pd .DataFrame (data = svUL_Jnuisance [channel ]).to_hdf (output_file , key = '{}/sigmavULs_Jnuisance' .format (channel ), mode = 'a' )
409
420
410
421
def _merge_to_lklcom ():
411
422
"""
0 commit comments