2 Prepare training data in numpy format from TH2s. 8 from matplotlib
import pyplot
as plt
12 file = uproot.open(filepath)
15 z, _ = file[
'infilldata'][key].
numpy()
21 if (
'ROP0' in key)
or (
'ROP1' in key):
22 with
open(os.path.join(induct_saveloc,
"{}.npy".
format(key[:-2])),
"w")
as f:
25 elif (
'ROP2' in key)
or (
'ROP3' in key):
26 with
open(os.path.join(collect_saveloc,
"{}.npy".
format(key[:-2])),
"w")
as f:
29 if (idx + 1) % 50 == 0:
30 print(
"{}/{}".
format(idx + 1, len(file[
"dec"].
keys())))
33 def main(input_file, output_dir):
35 induct_saveloc = os.path.join(output_dir,
"induction")
36 if not os.path.exists(induct_saveloc):
37 os.makedirs(induct_saveloc)
39 collect_saveloc = os.path.join(output_dir,
"collection")
40 if not os.path.exists(collect_saveloc):
41 os.makedirs(collect_saveloc)
48 parser = argparse.ArgumentParser()
50 parser.add_argument(
"input_file")
51 parser.add_argument(
"output_dir")
53 args = parser.parse_args()
55 return (args.input_file, args.output_dir)
58 if __name__ ==
"__main__":
int open(const char *, int)
Opens a file descriptor.
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def root_to_numpy(filepath, induct_saveloc, collect_saveloc)
def main(input_file, output_dir)