Failure in getting dead pixel mask for events close to (sub)run start
When running magic-cta-pipe
on some OFF data, specifically on run 05085314 of AT2019pqh from 2019-09-25, hillas_preprocessing_MAGICCleaning.py
(or also hillas_preprocessing_MAGICCleaning_stereo.py
) fails when trying to retrieve the dead pixels mask for the first event, for the M2 telescope. Here below the error message:
deadpixel_mask = badpixel_calculator.get_deadpixel_mask(event)
File "/home/condor/execute/dir_21741/utils/MAGIC_Badpixels.py",
line 310, in get_deadpixel_mask
i_min_dead = np.where(event_time >= self.sample_ranges_dead[tel_id
- 1][:,0])[0][-1]
IndexError: index -1 is out of bounds for axis 0 with size 0]
The fact that it fails at the first processed event and for M2 was verified "offline" running the code via ipython.
Looking at the code in MAGIC_Badpixels.py
, I understand that dead pixels masks are sampled in every subrun (typically around 20 times). The code simply compares the time of the event with the sampling times of the dead pixels masks, with something like event_time >= sampling_times
, which returns an array of indices, and then takes the last element in the array. The problem in this case is that the first sampling time could be greater that the time of the event e.g. when the event is close to the start of the (sub)run. Therefore, the returned array by the previous operation is empty, and trying to take an element from an empty array is an error, which is the one me and Elisabetta got.