Skip to content

Commit

Permalink
Merge pull request #63 from cta-observatory/fix_pixel_status_shape
Browse files Browse the repository at this point in the history
Fix shape of pixel_status fields
  • Loading branch information
maxnoe authored Feb 17, 2021
2 parents 9d7e017 + 0056c8a commit e394450
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ engines:
pyflakes:
disable:
- F999

6 changes: 3 additions & 3 deletions ctapipe_io_lst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from ctapipe.io import EventSource
from ctapipe.io.datalevels import DataLevel
from ctapipe.core.traits import Int, Bool, List, Float, Enum
from ctapipe.core.traits import Int, Bool, Float, Enum
from ctapipe.containers import PixelStatusContainer, EventType

from .containers import LSTArrayEventContainer, LSTServiceContainer
Expand All @@ -37,7 +37,7 @@
TIB_DTYPE,
)
from .constants import (
HIGH_GAIN, N_PIXELS, N_MODULES, N_SAMPLES
HIGH_GAIN, N_PIXELS, N_SAMPLES
)

__all__ = ['LSTEventSource', '__version__']
Expand Down Expand Up @@ -669,7 +669,7 @@ def fill_mon_container(self, array_event, zfits_event):
reordered_pixel_status[expected_pixels_id] = zfits_event.pixel_status

channel_info = get_channel_info(reordered_pixel_status)
status_container.hardware_failing_pixels = channel_info == 0
status_container.hardware_failing_pixels[:] = channel_info == 0


class MultiFiles:
Expand Down
6 changes: 3 additions & 3 deletions ctapipe_io_lst/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)

from ctapipe.calib.camera.gainselection import ThresholdGainSelector
from ctapipe.containers import MonitoringContainer, ArrayEventContainer, EventType
from ctapipe.containers import MonitoringContainer, ArrayEventContainer
from ctapipe.io import HDF5TableReader


Expand Down Expand Up @@ -207,7 +207,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] = np.nan

def update_first_capacitors(self, event: ArrayEventContainer):
for tel_id in event.r0.tel:
Expand Down Expand Up @@ -239,7 +239,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] = np.nan

waveform = waveform.astype(np.float32)
n_gains, n_pixels, n_samples = waveform.shape
Expand Down
3 changes: 0 additions & 3 deletions ctapipe_io_lst/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import numpy as np


N_GAINS = 2
N_MODULES = 265
N_PIXELS_MODULE = 7
Expand Down
2 changes: 1 addition & 1 deletion ctapipe_io_lst/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from astropy import units as u
from numpy import nan
from ctapipe.core import Container, Field, Map
from ctapipe.containers import ArrayEventContainer, MonitoringContainer
from ctapipe.containers import ArrayEventContainer


__all__ = [
Expand Down
1 change: 0 additions & 1 deletion ctapipe_io_lst/tests/test_event_time.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from ctapipe_io_lst import event_time
import os
from pathlib import Path
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion ctapipe_io_lst/tests/test_lsteventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_loop_over_events():
n_samples = event.lst.tel[telid].svc.num_samples
waveform_shape = (n_gains, n_pixels, n_samples)
assert event.r0.tel[telid].waveform.shape == waveform_shape
assert event.mon.tel[telid].pixel_status.hardware_failing_pixels.shape == (n_gains, n_pixels)

# make sure max_events works
assert (i + 1) == n_events
Expand Down Expand Up @@ -86,7 +87,7 @@ def test_missing_modules():
fill = np.iinfo(np.uint16).max
for event in source:
# one module missing, so 7 pixels
assert np.count_nonzero(event.mon.tel[1].pixel_status.hardware_failing_pixels) == N_PIXELS_MODULE
assert np.count_nonzero(event.mon.tel[1].pixel_status.hardware_failing_pixels) == N_PIXELS_MODULE * N_GAINS
assert np.count_nonzero(event.r0.tel[1].waveform == fill) == N_PIXELS_MODULE * N_SAMPLES * N_GAINS

# 514 is one of the missing pixels
Expand Down

0 comments on commit e394450

Please sign in to comment.