@@ -1158,9 +1158,17 @@ def fill_r0r1_camera_container(self, zfits_event):
1158
1158
)
1159
1159
expected_pixels = self .nectarcam_service .pixel_ids
1160
1160
1161
+ has_low_gain = (zfits_event .pixel_status & PixelStatus .LOW_GAIN_STORED ).astype (
1162
+ bool
1163
+ )
1164
+ has_high_gain = (
1165
+ zfits_event .pixel_status & PixelStatus .HIGH_GAIN_STORED
1166
+ ).astype (bool )
1167
+ not_broken = (has_low_gain | has_high_gain ).astype (bool )
1168
+
1161
1169
# broken pixels have both false, so gain selected means checking
1162
1170
# if there are any pixels where exactly one of high or low gain is stored
1163
- # gain_selected = np.any(has_low_gain != has_high_gain)
1171
+ gain_selected = np .any (has_low_gain != has_high_gain )
1164
1172
1165
1173
# fill value for broken pixels
1166
1174
@@ -1177,15 +1185,41 @@ def fill_r0r1_camera_container(self, zfits_event):
1177
1185
# we assume that either all pixels are gain selected or none
1178
1186
# only broken pixels are allowed to be missing completely
1179
1187
1180
- reshaped_waveform = zfits_event .waveform .reshape (N_GAINS , n_pixels , n_samples )
1181
- # re-order the waveform following the expected_pixels_id values
1182
- # could also just do waveform = reshaped_waveform[np.argsort(expected_ids)]
1183
- reordered_waveform = np .full (
1184
- (N_GAINS , N_PIXELS , N_SAMPLES ), fill , dtype = dtype
1185
- ) # VIM : use empty ?
1186
- reordered_waveform [:, expected_pixels , :] = reshaped_waveform
1187
- r0 = R0CameraContainer (waveform = reordered_waveform )
1188
- r1 = R1CameraContainer ()
1188
+ if gain_selected :
1189
+ # print("GAIN SELECTED")
1190
+ selected_gain = np .where (has_high_gain , 0 , 1 )
1191
+ waveform = np .full (
1192
+ (N_GAINS , n_pixels , n_samples ), fill , dtype = dtype
1193
+ ) # VIM : Replace full by empty ?
1194
+ waveform [not_broken ] = zfits_event .waveform .reshape ((- 1 , n_samples ))[
1195
+ not_broken
1196
+ ]
1197
+
1198
+ reordered_waveform = np .full (
1199
+ (N_GAINS , N_PIXELS , N_SAMPLES ), fill , dtype = dtype
1200
+ ) # VIM : Replace full by empty ?
1201
+ reordered_waveform [expected_pixels ] = waveform
1202
+
1203
+ reordered_selected_gain = np .full (N_PIXELS , - 1 , dtype = np .int8 )
1204
+ reordered_selected_gain [expected_pixels ] = selected_gain
1205
+
1206
+ r0 = R0CameraContainer ()
1207
+ r1 = R1CameraContainer (
1208
+ waveform = reordered_waveform ,
1209
+ selected_gain_channel = reordered_selected_gain ,
1210
+ )
1211
+ else :
1212
+ reshaped_waveform = zfits_event .waveform .reshape (
1213
+ N_GAINS , n_pixels , n_samples
1214
+ )
1215
+ # re-order the waveform following the expected_pixels_id values
1216
+ # could also just do waveform = reshaped_waveform[np.argsort(expected_ids)]
1217
+ reordered_waveform = np .full (
1218
+ (N_GAINS , N_PIXELS , N_SAMPLES ), fill , dtype = dtype
1219
+ ) # VIM : use empty ?
1220
+ reordered_waveform [:, expected_pixels , :] = reshaped_waveform
1221
+ r0 = R0CameraContainer (waveform = reordered_waveform )
1222
+ r1 = R1CameraContainer ()
1189
1223
1190
1224
if not self .pre_v6_data :
1191
1225
if r0 .waveform is not None :
0 commit comments