Skip to content

Commit 13e92f0

Browse files
committed
Support offline dvred R1v1 data
1 parent 657c365 commit 13e92f0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ctapipe_io_lst/__init__.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,18 @@ def fill_from_cta_r1(self, array_event, zfits_event):
485485
)
486486

487487
n_channels = zfits_event.num_channels
488-
n_pixels = zfits_event.num_pixels
489488
n_samples = zfits_event.num_samples
490489

491-
readout_shape = (n_channels, n_pixels, n_samples)
492-
raw_waveform = zfits_event.waveform.reshape(readout_shape)
493-
waveform = raw_waveform.astype(np.float32) / scale - offset
494-
495490
if self.dvr_applied:
496491
stored_pixels = (zfits_event.pixel_status & PixelStatus.DVR_STATUS) > 0
492+
n_pixels = np.count_nonzero(stored_pixels)
497493
else:
498494
stored_pixels = slice(None) # all pixels stored
495+
n_pixels = zfits_event.num_pixels
496+
497+
readout_shape = (n_channels, n_pixels, n_samples)
498+
raw_waveform = zfits_event.waveform.reshape(readout_shape)
499+
waveform = raw_waveform.astype(np.float32) / scale - offset
499500

500501
reordered_waveform = np.full((n_channels, N_PIXELS, n_samples), 0.0, dtype=np.float32)
501502
reordered_waveform[:, pixel_id_map[stored_pixels]] = waveform
@@ -531,7 +532,7 @@ def fill_from_cta_r1(self, array_event, zfits_event):
531532

532533
if DataLevel.R0 in self.datalevels:
533534
reordered_raw_waveform = np.full((n_channels, N_PIXELS, n_samples), 0, dtype=np.uint16)
534-
reordered_raw_waveform[:, pixel_id_map] = raw_waveform
535+
reordered_raw_waveform[:, pixel_id_map[stored_pixels]] = raw_waveform
535536
array_event.r0.tel[self.tel_id] = R0CameraContainer(
536537
waveform=reordered_raw_waveform,
537538
)

0 commit comments

Comments
 (0)