error with hdf5header
I am trying to access the ngen
variable from some h5 files of ARCA6. To do so I do:
def get_total_ngen(files_dir):
...:
...: '''
...:
...: Function that reads a list of h5 files and returns the total number of generated neutrino events.
...:
...: '''
...:
...: n_files = 0
...:
...: total_n_gen = 0
...:
...: for i in os.listdir(files_dir):
...: if i.endswith('.h5'):
...:
...: n_files = n_files + 1
...:
...: header = HDF5Header.from_hdf5(files_dir + str(i))
...:
...: n_gen = header.genvol.numberOfEvents
...:
...: total_n_gen = total_n_gen + n_gen
...:
...: return total_n_gen, n_files
...:
this function has worked fine with FULL-ARCA MC v5 and v6, but with ARCA6 MC I get:
get_total_ngen("/sps/km3net/users/nvanderm/ML_project/inference_files/nueNC/")
---------------------------------------------------------------------------
NoSuchNodeError Traceback (most recent call last)
<ipython-input-8-e172da733b52> in <module>
----> 1 get_total_ngen("/sps/km3net/users/nvanderm/ML_project/inference_files/nueNC/")
<ipython-input-7-2f7497ae43d9> in get_total_ngen(files_dir)
14 n_files = n_files + 1
15
---> 16 header = HDF5Header.from_hdf5(files_dir + str(i))
17
18 n_gen = header.genvol.numberOfEvents
~/.local/lib/python3.7/site-packages/km3pipe/io/hdf5.py in from_hdf5(cls, filename)
145 def from_hdf5(cls, filename):
146 with tb.open_file(filename, "r") as f:
--> 147 table = f.get_node("/raw_header")
148 return cls.from_pytable(table)
149
/pbs/throng/km3net/software/python/3.7.5/lib/python3.7/site-packages/tables/file.py in get_node(self, where, name, classname)
1605 basepath = where
1606 nodepath = join_path(basepath, name or '') or '/'
-> 1607 node = self._get_node(nodepath)
1608 else:
1609 raise TypeError(
/pbs/throng/km3net/software/python/3.7.5/lib/python3.7/site-packages/tables/file.py in _get_node(self, nodepath)
1554 return self.root
1555
-> 1556 node = self._node_manager.get_node(nodepath)
1557 assert node is not None, "unable to instantiate node ``%s``" % nodepath
1558
/pbs/throng/km3net/software/python/3.7.5/lib/python3.7/site-packages/tables/file.py in get_node(self, key)
415
416 if self.node_factory:
--> 417 node = self.node_factory(key)
418 self.cache_node(node, key)
419
/pbs/throng/km3net/software/python/3.7.5/lib/python3.7/site-packages/tables/group.py in _g_load_child(self, childname)
1135 childname = join_path(self._v_file.root_uep, childname)
1136 # Is the node a group or a leaf?
-> 1137 node_type = self._g_check_has_child(childname)
1138
1139 # Nodes that HDF5 report as H5G_UNKNOWN
/pbs/throng/km3net/software/python/3.7.5/lib/python3.7/site-packages/tables/group.py in _g_check_has_child(self, name)
375 raise NoSuchNodeError(
376 "group ``%s`` does not have a child named ``%s``"
--> 377 % (self._v_pathname, name))
378 return node_type
379
NoSuchNodeError: group ``/`` does not have a child named ``/raw_header``
I don't understand where this difference comes from as these files have been produced the same way the old ones were.
Edited by Alba Domi