37raiseException(f"Number of specified records is greater than the total {total}")
38
39 n_links = len([f for f in h5file.get_fragment_dataset_paths(records[0]) if"WIB"in f]) # exclude other fragments in the record that are not WIB frames
68 bf.write(bytearray(data.get_bytes())) # write binary data to the file
69 total_frames += j
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}.")
72return
73
74if __name__ == "__main__":
75 parser = argparse.ArgumentParser(description = 'Python script to write WIB2 frames from DUNE-DAQ HDF5 files to binary files.')
76 parser.add_argument(dest = "file_name", help = 'path to HDF5 file')
77 parser.add_argument("-l", "--link", dest = "link", type = int, help = "link number to conver to binary", required = True)
78 parser.add_argument('-n', '--num-of-records', dest = "n_records", type = int, help = 'specify number of records to be parsed, -1 will parse all records', default = 0, required = True)
79 parser.add_argument("--debug", dest = "debug", action = "store_true", help = "Debugging information")