Skip to content

Commit

Permalink
use new archive feature to allow selective reades
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Jun 27, 2024
1 parent 690665e commit f97a53b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions plenoirf/reduction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ def zip_read_BytesIo(file, internal_path, mode="r"):


def recude_event_table(run_paths, out_path):
evttab = snt.init(dtypes=event_table.structure.dtypes())
opj = os.path.join
for run_path in run_paths:
run_basename = os.path.basename(run_path)
run_id_str = os.path.splitext(run_basename)[0]
buff = zip_read_BytesIo(
file=run_path,
internal_path=opj(run_id_str, "event_table.tar.gz"),
mode="r|gz",
)
part_evttab = snt.read(fileobj=buff, dynamic=False)
evttab = snt.append(evttab, part_evttab)
snt.write(path=out_path, table=evttab)
with snt.archive.open(
out_path, mode="w", dtypes=event_table.structure.dtypes()
) as arc:
for run_path in run_paths:
run_basename = os.path.basename(run_path)
run_id_str = os.path.splitext(run_basename)[0]
buff = zip_read_BytesIo(
file=run_path,
internal_path=os.path.join(run_id_str, "event_table.tar.gz"),
mode="r|gz",
)
run_evttab = snt.read(fileobj=buff, dynamic=False)
arc.append_table(run_evttab)


def reduce_reconstructed_cherenkov(run_paths, out_path):
Expand Down

0 comments on commit f97a53b

Please sign in to comment.