Functions | Variables
data_prepare Namespace Reference

Functions

def root_to_numpy (filepath, induct_saveloc, collect_saveloc)
 
def main (input_file, output_dir)
 
def parse_arguments ()
 

Variables

 arguments = parse_arguments()
 

Detailed Description

Prepare training data in numpy format from TH2s.

Function Documentation

def data_prepare.main (   input_file,
  output_dir 
)

Definition at line 33 of file data_prepare.py.

33 def main(input_file, output_dir):
34 
35  induct_saveloc = os.path.join(output_dir, "induction")
36  if not os.path.exists(induct_saveloc):
37  os.makedirs(induct_saveloc)
38 
39  collect_saveloc = os.path.join(output_dir, "collection")
40  if not os.path.exists(collect_saveloc):
41  os.makedirs(collect_saveloc)
42 
43  root_to_numpy(input_file, induct_saveloc, collect_saveloc)
44 
45 
def root_to_numpy(filepath, induct_saveloc, collect_saveloc)
Definition: data_prepare.py:11
def main(input_file, output_dir)
Definition: data_prepare.py:33
def data_prepare.parse_arguments ( )

Definition at line 46 of file data_prepare.py.

47 
48  parser = argparse.ArgumentParser()
49 
50  parser.add_argument("input_file")
51  parser.add_argument("output_dir")
52 
53  args = parser.parse_args()
54 
55  return (args.input_file, args.output_dir)
56 
57 
def parse_arguments()
Definition: data_prepare.py:46
def data_prepare.root_to_numpy (   filepath,
  induct_saveloc,
  collect_saveloc 
)

Definition at line 11 of file data_prepare.py.

11 def root_to_numpy(filepath, induct_saveloc, collect_saveloc):
12  file = uproot.open(filepath)
13 
14  for idx, key in enumerate(file['infilldata'].keys()):
15  z, _ = file['infilldata'][key].numpy()
16 
17  # print(z.dtype)
18  # plt.imshow(z.T, aspect='auto', vmin=-20, vmax=20, cmap='coolwarm')
19  # plt.show()
20 
21  if ('ROP0' in key) or ('ROP1' in key):
22  with open(os.path.join(induct_saveloc, "{}.npy".format(key[:-2])), "w") as f:
23  np.save(f, z)
24 
25  elif ('ROP2' in key) or ('ROP3' in key):
26  with open(os.path.join(collect_saveloc, "{}.npy".format(key[:-2])), "w") as f:
27  np.save(f, z)
28 
29  if (idx + 1) % 50 == 0:
30  print("{}/{}".format(idx + 1, len(file["dec"].keys())))
31 
32 
int open(const char *, int)
Opens a file descriptor.
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def root_to_numpy(filepath, induct_saveloc, collect_saveloc)
Definition: data_prepare.py:11

Variable Documentation

data_prepare.arguments = parse_arguments()

Definition at line 59 of file data_prepare.py.