@@ -479,27 +479,30 @@ def fill_from_cta_r1(self, array_event, zfits_event):
479
479
offset = self .data_stream .waveform_offset
480
480
pixel_id_map = self .camera_config .pixel_id_map
481
481
482
- # FIXME: missing modules / pixels
483
- # FIXME: DVR? should not happen in r1 but dl0, but our own converter uses the old R1
484
-
485
482
# reorder to nominal pixel order
486
483
pixel_status = _reorder_pixel_status (
487
- zfits_event .pixel_status , pixel_id_map , set_dvr_bits = True
484
+ zfits_event .pixel_status , pixel_id_map , set_dvr_bits = not self . dvr_applied ,
488
485
)
489
486
490
487
n_channels = zfits_event .num_channels
491
- n_pixels = zfits_event .num_pixels
492
488
n_samples = zfits_event .num_samples
493
489
490
+ if self .dvr_applied :
491
+ stored_pixels = (zfits_event .pixel_status & PixelStatus .DVR_STATUS ) > 0
492
+ n_pixels = np .count_nonzero (stored_pixels )
493
+ else :
494
+ stored_pixels = slice (None ) # all pixels stored
495
+ n_pixels = zfits_event .num_pixels
496
+
494
497
readout_shape = (n_channels , n_pixels , n_samples )
495
498
raw_waveform = zfits_event .waveform .reshape (readout_shape )
496
499
waveform = raw_waveform .astype (np .float32 ) / scale - offset
497
500
498
501
reordered_waveform = np .full ((n_channels , N_PIXELS , n_samples ), 0.0 , dtype = np .float32 )
499
- reordered_waveform [:, pixel_id_map ] = waveform
502
+ reordered_waveform [:, pixel_id_map [ stored_pixels ] ] = waveform
500
503
waveform = reordered_waveform
501
504
502
- # FIXME, check using evb_preprocessing and make ctapipe support 2 gains
505
+
503
506
if zfits_event .num_channels == 2 :
504
507
selected_gain_channel = None
505
508
else :
@@ -529,22 +532,23 @@ def fill_from_cta_r1(self, array_event, zfits_event):
529
532
530
533
if DataLevel .R0 in self .datalevels :
531
534
reordered_raw_waveform = np .full ((n_channels , N_PIXELS , n_samples ), 0 , dtype = np .uint16 )
532
- reordered_raw_waveform [:, pixel_id_map ] = raw_waveform
535
+ reordered_raw_waveform [:, pixel_id_map [ stored_pixels ] ] = raw_waveform
533
536
array_event .r0 .tel [self .tel_id ] = R0CameraContainer (
534
537
waveform = reordered_raw_waveform ,
535
538
)
536
539
537
540
def fill_lst_from_ctar1 (self , zfits_event ):
541
+ pixel_status = _reorder_pixel_status (
542
+ zfits_event .pixel_status ,
543
+ self .pixel_id_map ,
544
+ set_dvr_bits = not self .dvr_applied ,
545
+ )
538
546
evt = LSTEventContainer (
539
- pixel_status = zfits_event . pixel_status . copy () ,
547
+ pixel_status = pixel_status ,
540
548
first_capacitor_id = zfits_event .first_cell_id ,
541
549
calibration_monitoring_id = zfits_event .calibration_monitoring_id ,
542
550
local_clock_counter = zfits_event .module_hires_local_clock_counter ,
543
551
)
544
- # set bits for dvr if not already set
545
- if not self .dvr_applied :
546
- not_broken = get_channel_info (evt .pixel_status ) != 0
547
- evt .pixel_status [not_broken ] |= PixelStatus .DVR_STATUS_0
548
552
549
553
if zfits_event .debug is not None :
550
554
debug = zfits_event .debug
@@ -971,7 +975,7 @@ def tag_flatfield_events(self, array_event):
971
975
'''
972
976
tel_id = self .tel_id
973
977
waveform = array_event .r1 .tel [tel_id ].waveform
974
-
978
+
975
979
if waveform .ndim == 3 :
976
980
image = waveform [HIGH_GAIN ].sum (axis = 1 )
977
981
else :
@@ -981,7 +985,7 @@ def tag_flatfield_events(self, array_event):
981
985
n_in_range = np .count_nonzero (in_range )
982
986
983
987
looks_like_ff = n_in_range >= self .min_flatfield_pixel_fraction * image .size
984
-
988
+
985
989
if looks_like_ff :
986
990
# Tag as FF only events with 2-gains waveforms: both gains are needed for calibration
987
991
if waveform .ndim == 3 :
@@ -1091,7 +1095,7 @@ def fill_r0r1_camera_container(self, zfits_event):
1091
1095
if CTAPIPE_0_20 :
1092
1096
# reorder to nominal pixel order
1093
1097
pixel_status = _reorder_pixel_status (
1094
- zfits_event .pixel_status , pixel_id_map , set_dvr_bits = True
1098
+ zfits_event .pixel_status , pixel_id_map , set_dvr_bits = not self . dvr_applied
1095
1099
)
1096
1100
r1 .pixel_status = pixel_status
1097
1101
r1 .event_time = cta_high_res_to_time (
0 commit comments