diff --git a/src/ctapipe_io_lst/__init__.py b/src/ctapipe_io_lst/__init__.py index b77dc64a..1fd94115 100644 --- a/src/ctapipe_io_lst/__init__.py +++ b/src/ctapipe_io_lst/__init__.py @@ -929,6 +929,9 @@ def fill_trigger_info(self, array_event): if trigger.event_type == EventType.UNKNOWN: self.log.warning(f'Event {array_event.index.event_id} has unknown event type, trigger: {trigger_bits:08b}') + if CTAPIPE_0_20: + array_event.r1.tel[tel_id].event_type = trigger.event_type + def tag_flatfield_events(self, array_event): ''' Use a heuristic based on R1 waveforms to recognize flat field events diff --git a/src/ctapipe_io_lst/pixels.py b/src/ctapipe_io_lst/pixels.py new file mode 100644 index 00000000..a8752063 --- /dev/null +++ b/src/ctapipe_io_lst/pixels.py @@ -0,0 +1,25 @@ +import numpy as np +from astropy.table import Table +from .constants import N_PIXELS_MODULE + +def get_pixel_table(pixel_id_map, module_id_map): + """ + Construct a table of pixel / module ids from the mappings in CameraConfiguration + """ + module_index = np.repeat(np.arange(len(module_id_map)), N_PIXELS_MODULE) + pixel_index = np.arange(len(pixel_id_map)) + + local_pixel_index = pixel_index % N_PIXELS_MODULE + hardware_pixel_id = module_id_map * N_PIXELS_MODULE + local_pixel_index + + table = Table(dict( + pixel_id=pixel_id_map, + pixel_index=pixel_index, + hardware_pixel_id=hardware_pixel_id, + module_id=module_id_map, + local_pixel_index=local_pixel_index, + module_index=module_index, + )) + + table.sort("pixel_id") + return table diff --git a/src/ctapipe_io_lst/tests/test_lsteventsource.py b/src/ctapipe_io_lst/tests/test_lsteventsource.py index 63ed6292..337abe07 100644 --- a/src/ctapipe_io_lst/tests/test_lsteventsource.py +++ b/src/ctapipe_io_lst/tests/test_lsteventsource.py @@ -318,8 +318,7 @@ def test_pedestal_events(tmp_path): assert event.trigger.event_type == EventType.SKY_PEDESTAL else: assert event.trigger.event_type != EventType.SKY_PEDESTAL - - + assert event.r1.tel[1].event_type == event.trigger.event_type @pytest.mark.parametrize(