3
3
import os
4
4
import pathlib
5
5
6
+ import lgdo .lh5 as lh5
6
7
import numpy as np
7
8
from legendmeta import LegendMetadata
8
9
from legendmeta .catalog import Props
10
+ from lgdo .types import Table
9
11
from pygama .skm .build_skm import build_skm
10
12
from util .FileKey import ProcessingFileKey
11
- import lgdo .lh5 as lh5
12
- from lgdo .types import Table
13
-
14
13
15
- sto = lh5 .LH5Store ()
14
+ sto = lh5 .LH5Store ()
16
15
17
16
18
17
def group_files (fs_evt , fs_hit , fs_dsp , fs_tcm ):
@@ -78,9 +77,11 @@ def group_files(fs_evt, fs_hit, fs_dsp, fs_tcm):
78
77
]["skm_config" ]
79
78
80
79
if isinstance (skm_config_file , dict ):
81
- skm_config = {key :Props .read_from (config_file ) for key , config_file in skm_config_file .items ()}
80
+ skm_config = {
81
+ key : Props .read_from (config_file ) for key , config_file in skm_config_file .items ()
82
+ }
82
83
else :
83
- skm_config = {"all" :Props .read_from (skm_config_file )}
84
+ skm_config = {"all" : Props .read_from (skm_config_file )}
84
85
85
86
if isinstance (args .hit_files , list ) and args .hit_files [0 ].split ("." )[- 1 ] == "filelist" :
86
87
hit_files = args .hit_files [0 ]
@@ -125,11 +126,10 @@ def group_files(fs_evt, fs_hit, fs_dsp, fs_tcm):
125
126
pathlib .Path (os .path .dirname (args .output )).mkdir (parents = True , exist_ok = True )
126
127
127
128
rng = np .random .default_rng ()
128
- rand_num = rng .integers (0 ,99999 )
129
+ rand_num = rng .integers (0 , 99999 )
129
130
temp_output = f"{ args .output } .{ rand_num :05d} "
130
131
131
132
for f_evt , f_hit , f_dsp , f_tcm in input_files :
132
-
133
133
log_string = f"running files evt:{ os .path .basename (f_evt )} , hit:{ os .path .basename (f_hit )} ,"
134
134
log_string += f"\n dsp:{ os .path .basename (f_dsp )} , tcm: { os .path .basename (f_tcm )} "
135
135
log .debug (log_string )
@@ -150,10 +150,11 @@ def group_files(fs_evt, fs_hit, fs_dsp, fs_tcm):
150
150
hit_group = "hit" ,
151
151
tcm_id_table_pattern = "ch{}" ,
152
152
)
153
- tables [key ] = sto .read (f"skm/{ key } " if key != "all" else "skm" , f"{ args .output } .{ rand_num + 1 :05d} " )[0 ]
154
- tbl = Table (col_dict = tables )
155
- sto .write (obj = tbl , name = "skm" ,
156
- lh5_file = temp_output , wo_mode = "a" )
153
+ tables [key ] = sto .read (
154
+ f"skm/{ key } " if key != "all" else "skm" , f"{ args .output } .{ rand_num + 1 :05d} "
155
+ )[0 ]
156
+ tbl = Table (col_dict = tables )
157
+ sto .write (obj = tbl , name = "skm" , lh5_file = temp_output , wo_mode = "a" )
157
158
os .remove (f"{ args .output } .{ rand_num + 1 :05d} " )
158
159
159
160
os .rename (temp_output , args .output )
0 commit comments