Skip to content

Commit

Permalink
change to keep tables in memory
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmarshall committed Feb 19, 2024
1 parent feda106 commit 3841122
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
16 changes: 6 additions & 10 deletions scripts/build_evt.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,24 @@ def replace_evt_with_key(dic, new_key):
rand_num = f"{rng.integers(0,99999):05d}"
temp_output = f"{args.output}.{rand_num}"

tables = {}
for key, config in evt_config.items():
build_evt(
tables[key] = build_evt(
f_tcm=args.tcm_file,
f_dsp=args.dsp_file,
f_hit=args.hit_file,
f_evt=temp_output,
f_evt=None,
evt_config=config,
evt_group=f"evt/{key}" if key != "all" else "evt",
tcm_group="hardware_tcm_1",
dsp_group="dsp",
hit_group="hit",
tcm_id_table_pattern="ch{}",
wo_mode="a",
tcm_id_table_pattern="ch{}"
)

tables = {}
for key in evt_config:
tables[key] = sto.read(f"evt/{key}" if key != "all" else "evt", temp_output)[0]

tbl = Table(col_dict=tables)
sto.write(obj=tbl, name="evt", lh5_file=args.output, wo_mode="a")
os.remove(temp_output)
sto.write(obj=tbl, name="evt", lh5_file=temp_output, wo_mode="a")

os.rename(temp_output, args.output)
t_elap = time.time() - t_start
log.info(f"Done! Time elapsed: {t_elap:.2f} sec.")
20 changes: 8 additions & 12 deletions scripts/build_skm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,22 @@ def group_files(fs_evt, fs_hit, fs_dsp, fs_tcm):
log.debug(log_string)
tables = {}
for key, config in skm_config.items():
build_skm(
f_evt,
f_hit,
f_dsp,
f_tcm,
f"{args.output}.{rand_num+1:05d}",
config,
wo_mode="a",
tables[key] = build_skm(
f_evt = f_evt,
f_hit = f_hit,
f_dsp = f_dsp,
f_tcm = f_tcm,
f_skm= None,
skm_conf = config,
skm_group=f"skm/{key}" if key != "all" else "skm",
evt_group="evt",
tcm_group="hardware_tcm_1",
dsp_group="dsp",
hit_group="hit",
tcm_id_table_pattern="ch{}",
)
tables[key] = sto.read(
f"skm/{key}" if key != "all" else "skm", f"{args.output}.{rand_num+1:05d}"
)[0]

tbl = Table(col_dict=tables)
sto.write(obj=tbl, name="skm", lh5_file=temp_output, wo_mode="a")
os.remove(f"{args.output}.{rand_num+1:05d}")

os.rename(temp_output, args.output)

0 comments on commit 3841122

Please sign in to comment.