Skip to content

Commit

Permalink
Merge pull request #100 from cta-observatory/fill_zeros
Browse files Browse the repository at this point in the history
Fill 0 instead of nan for missing pixels
  • Loading branch information
maxnoe authored Apr 22, 2021
2 parents 2b1ebd8 + 68b607a commit 2aecb39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ctapipe_io_lst/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def apply_drs4_corrections(self, event: ArrayEventContainer):
waveform -= self.offset.tel[tel_id]

mon = event.mon.tel[tel_id]
waveform[mon.pixel_status.hardware_failing_pixels] = np.nan
waveform[mon.pixel_status.hardware_failing_pixels] = 0.0

def update_first_capacitors(self, event: ArrayEventContainer):
for tel_id in event.r0.tel:
Expand Down Expand Up @@ -243,7 +243,7 @@ def calibrate(self, event: ArrayEventContainer):
waveform *= calibration.dc_to_pe[:, :, np.newaxis]

mon = event.mon.tel[tel_id]
waveform[mon.pixel_status.hardware_failing_pixels] = np.nan
waveform[mon.pixel_status.hardware_failing_pixels] = 0.0

waveform = waveform.astype(np.float32)
n_gains, n_pixels, n_samples = waveform.shape
Expand Down
15 changes: 13 additions & 2 deletions ctapipe_io_lst/tests/test_calib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ctapipe_io_lst.constants import HIGH_GAIN
import os
from pathlib import Path
from traitlets.config import Config
Expand Down Expand Up @@ -182,8 +183,18 @@ def test_missing_module():
for event in source:
waveform = event.r1.tel[1].waveform
assert waveform is not None
assert np.count_nonzero(np.isnan(waveform)) == N_PIXELS_MODULE * (N_SAMPLES - 4)
assert np.all(np.isnan(waveform[514]))


failing_pixels = event.mon.tel[1].pixel_status.hardware_failing_pixels

# one module failed, in each gain channel
assert np.count_nonzero(failing_pixels) == 2 * N_PIXELS_MODULE

# there might be zeros in other pixels than just the broken ones
assert np.count_nonzero(waveform == 0) >= N_PIXELS_MODULE * (N_SAMPLES - 4)

# waveforms in failing pixels must be all 0
assert np.all(waveform[failing_pixels[HIGH_GAIN]] == 0)

def test_no_gain_selection():
from ctapipe_io_lst import LSTEventSource
Expand Down

0 comments on commit 2aecb39

Please sign in to comment.