예제 #1
0
def read_simu_info_hdf5(filename):
    """
    Read simu info from an hdf5 file

    Returns
    -------
    `ctapipe.containers.SimulationConfigContainer`
    """

    with HDF5TableReader(filename) as reader:
        mc_reader = reader.read("/simulation/run_config",
                                SimulationConfigContainer())
        mc = next(mc_reader)

    return mc
예제 #2
0
 def _parse_mc_headers(self):
     """
     Construct a dict of SimulationConfigContainers from the
     self.file_.root.configuration.simulation.run.
     These are used to match the correct header to each event
     """
     # Just returning next(reader) would work as long as there are no merged files
     # The reader ignores obs_id making the setup somewhat tricky
     # This is ugly but supports multiple headers so each event can have
     # the correct mcheader assigned by matching the obs_id
     # Alternatively this becomes a flat list
     # and the obs_id matching part needs to be done in _generate_events()
     mc_headers = {}
     if "simulation" in self.file_.root.configuration:
         reader = HDF5TableReader(self.file_).read(
             "/configuration/simulation/run", SimulationConfigContainer()
         )
         row_iterator = self.file_.root.configuration.simulation.run.iterrows()
         for row in row_iterator:
             mc_headers[row["obs_id"]] = next(reader)
     return mc_headers
예제 #3
0
 def _parse_simulation_configs(self):
     """
     Construct a dict of SimulationConfigContainers from the
     self.file_.root.configuration.simulation.run.
     These are used to match the correct header to each event
     """
     # Just returning next(reader) would work as long as there are no merged files
     # The reader ignores obs_id making the setup somewhat tricky
     # This is ugly but supports multiple headers so each event can have
     # the correct mcheader assigned by matching the obs_id
     # Alternatively this becomes a flat list
     # and the obs_id matching part needs to be done in _generate_events()
     simulation_configs = {}
     if "simulation" in self.file_.root.configuration:
         reader = HDF5TableReader(self.file_).read(
             "/configuration/simulation/run",
             containers=[
                 SimulationConfigContainer(),
                 EventIndexContainer()
             ],
         )
         for (config, index) in reader:
             simulation_configs[index.obs_id] = config
     return simulation_configs