Classes | Functions | Variables
add_attributes Namespace Reference

Classes

class  progbar
 

Functions

def determine_index_cols (h5group)
 
def encode_index_cols (index_cols)
 
def parent_table (group_name)
 
def write_attributes (h5group, verbose=False, dry_run=True)
 
def insert (astring, substr, pos, overwrite=True)
 

Variables

list required_indices = ['run', 'subrun', 'cycle', 'evt']
 
list other_indices = ['subevt']
 
 parser = argparse.ArgumentParser('Add index columns to the input h5 file(s)')
 
 nargs
 
 help
 
 action
 
 args = parser.parse_args()
 
 files = args.files
 
 prog
 
 g = h5file.get(group_name)
 
 verbose
 
 dry_run
 

Function Documentation

def add_attributes.determine_index_cols (   h5group)

Definition at line 29 of file add_attributes.py.

Referenced by write_attributes().

29 def determine_index_cols(h5group):
30  index_cols = []
31  dsets = h5group.keys()
32  for required in required_indices:
33  if required in dsets: index_cols.append(required)
34  for other in other_indices:
35  if other in dsets: index_cols.append(other)
36 
37  for dset in h5group.keys():
38  if dset.endswith('_idx'): index_cols.append(dset)
39  return index_cols
40 
def determine_index_cols(h5group)
def add_attributes.encode_index_cols (   index_cols)

Definition at line 41 of file add_attributes.py.

Referenced by write_attributes().

41 def encode_index_cols(index_cols):
42  return [','.join(index_cols)]
43 
44 
45 # nova group naming scheme provides a full "path" to the data
46 # as arranged in standard record where nested objects
47 # are separated by a '.'
48 # The parentage can then be determined by removing
49 # name after the last '.'
def encode_index_cols(index_cols)
def add_attributes.insert (   astring,
  substr,
  pos,
  overwrite = True 
)
def add_attributes.parent_table (   group_name)

Definition at line 50 of file add_attributes.py.

Referenced by write_attributes().

50 def parent_table(group_name):
51  if '.' not in group_name:
52  return ['/']
53  else:
54  return ['.'.join(group_name.split('.')[:-1])]
55 
56 
57 # function to write all attributes
def parent_table(group_name)
def add_attributes.write_attributes (   h5group,
  verbose = False,
  dry_run = True 
)

Definition at line 58 of file add_attributes.py.

References determine_index_cols(), encode_index_cols(), novadaq::HexUtils.format(), parent_table(), and print.

58 def write_attributes(h5group, verbose=False, dry_run=True):
59  if verbose:
60  print(h5group.name)
61  # index_cols
62  index_cols = determine_index_cols(g)
63  attr_index_cols = encode_index_cols(index_cols)
64  if verbose:
65  try:
66  existing_index_cols = g.attrs['index_cols']
67  except KeyError:
68  existing_index_cols = 'None'
69 
70  finally:
71  print('\t|index_cols: {} ---> {}'.format(existing_index_cols, attr_index_cols))
72 
73  if not dry_run: h5group.attrs['index_cols' ] = attr_index_cols
74 
75  # parent_table
76  attr_parent_table = parent_table(h5group.name)
77  if verbose:
78  try:
79  existing_parent_table = g.attrs['parent_table']
80  except KeyError:
81  existing_parent_table = 'None'
82  finally:
83  print('\t|parent_table: {} ---> {}'.format(existing_parent_table, attr_parent_table))
84 
85  if not dry_run: h5group.attrs['parent_table'] = attr_parent_table
86 
87 
88 
89 # progress bar for funzies
def parent_table(group_name)
def write_attributes(h5group, verbose=False, dry_run=True)
def determine_index_cols(h5group)
def encode_index_cols(index_cols)
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14

Variable Documentation

add_attributes.action

Definition at line 115 of file add_attributes.py.

add_attributes.args = parser.parse_args()

Definition at line 118 of file add_attributes.py.

add_attributes.dry_run

Definition at line 131 of file add_attributes.py.

add_attributes.files = args.files

Definition at line 120 of file add_attributes.py.

add_attributes.g = h5file.get(group_name)

Definition at line 127 of file add_attributes.py.

add_attributes.help

Definition at line 114 of file add_attributes.py.

add_attributes.nargs

Definition at line 114 of file add_attributes.py.

list add_attributes.other_indices = ['subevt']

Definition at line 27 of file add_attributes.py.

add_attributes.parser = argparse.ArgumentParser('Add index columns to the input h5 file(s)')

Definition at line 113 of file add_attributes.py.

add_attributes.prog
list add_attributes.required_indices = ['run', 'subrun', 'cycle', 'evt']

Definition at line 26 of file add_attributes.py.

add_attributes.verbose