Source code for rta_selection.dl2_reader

import astropy.units as u
import pandas as pd
from astropy.table import QTable


[docs] def read_data_dl2_to_QTable(filename): """ Read data DL2 files from lstchain and return QTable format, along with a dict of target parameters for IRF interpolation Parameters ---------- filename: path to the lstchain DL2 file Returns ------- data: `astropy.table.QTable` """ # Mapping name_mapping = { "gammaness": "gh_score", "alt_tel": "pointing_alt", "az_tel": "pointing_az", } unit_mapping = { "reco_energy": u.TeV, "pointing_alt": u.rad, "pointing_az": u.rad, "reco_alt": u.rad, "reco_az": u.rad, "trigger_time": u.s, "reco_src_x": u.m, "reco_src_y": u.m, } # TODO: make key configurable data = pd.read_hdf(filename, key="/dl2/event/telescope/parameters/LST_LSTCam") # TODO: optimizer loading to avoid re-naming / copies? data = data.rename(columns=name_mapping) data = QTable.from_pandas(data) # TODO: read hdf5 with astropy directly... # Make the columns as Quantity for k, v in unit_mapping.items(): data[k] *= v return data