32 records = h5file.get_all_record_ids()
33 total_records = len(records)
34 if args.n_records == -1:
35 args.n_records = total_records
36 if args.n_records > total_records:
37 raise Exception(f
"Number of specified records is greater than the total {total}")
39 n_links = len([f
for f
in h5file.get_fragment_dataset_paths(records[0])
if "WIB" in f])
40 if args.link >= n_links:
41 raise Exception(f
"Link number out of range.")
43 out_name = f
"wib_link_{args.link}.bin"
44 with open(out_name,
"wb")
as bf:
47 for i
in range(args.n_records):
48 header = h5file.get_record_header_dataset_path(records[i])
51 fragments = h5file.get_fragment_dataset_paths(records[i])
52 fragments = [f
for f
in fragments
if "WIB" in f]
54 Debug(f
"loading fragment: {fragments[args.link]}")
55 f = h5file.get_frag(fragments[args.link])
57 WIB2Frame_size = fddetdataformats.WIBEthFrame.sizeof()
59 n_frames = (f.get_size() - f.get_header().sizeof()) // WIB2Frame_size
60 for j
in range(n_frames):
61 Debug(f.get_fragment_type())
62 Debug(f.get_element_id())
64 data = fddetdataformats.WIBEthFrame(f.get_data(j * WIB2Frame_size))
66 Debug(f
"{data.sizeof()=}")
68 bf.write(bytearray(data.get_bytes()))
70 print(f
"writing {total_frames} WIB2 frames to binary file.",
"\r")
71 print(f
"wrote {args.n_records} fragments from wib link {args.link} to file {out_name}.")