Skip to content

Commit

Permalink
Merge pull request #2602 from cta-observatory/fix_nsb_image_cleaner
Browse files Browse the repository at this point in the history
Delete tel attribute from MonitoringCameraContainer in NSBImageCleaner
  • Loading branch information
maxnoe authored Jul 31, 2024
2 parents f9108ac + 2381338 commit 5d6116c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changes/2602.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix ``NSBImageCleaner`` that tries to reach the tel attribute
from a MonitoringCameraContainer which results in an AttributeError
when using the ``ImageProcessor``.
2 changes: 1 addition & 1 deletion src/ctapipe/image/cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def __call__(
"""
pedestal_std = None
if monitoring is not None:
pedestal_std = monitoring.tel[tel_id].pedestal.charge_std
pedestal_std = monitoring.pedestal.charge_std

return nsb_image_cleaning(
self.subarray.tel[tel_id].camera.geometry,
Expand Down
8 changes: 7 additions & 1 deletion src/ctapipe/image/tests/test_image_cleaner_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
from traitlets.config import Config

from ctapipe.containers import MonitoringCameraContainer
from ctapipe.image import ImageCleaner
from ctapipe.instrument import SubarrayDescription

Expand Down Expand Up @@ -41,6 +42,11 @@ def test_image_cleaner(method, prod5_mst_nectarcam, reference_location):
reference_location=reference_location,
)

monitoring = MonitoringCameraContainer()
monitoring.pedestal.charge_std = np.ones(
prod5_mst_nectarcam.camera.geometry.n_pixels
)

clean = ImageCleaner.from_name(method, config=config, subarray=subarray)

image = np.zeros_like(
Expand All @@ -51,7 +57,7 @@ def test_image_cleaner(method, prod5_mst_nectarcam, reference_location):
image[31:40] = 8.0
times = np.linspace(-5, 10, image.shape[0])

mask = clean(tel_id=1, image=image, arrival_times=times)
mask = clean(tel_id=1, image=image, arrival_times=times, monitoring=monitoring)

# we're not testing the algorithm here, just that it does something (for the
# algorithm tests, see test_cleaning.py
Expand Down

0 comments on commit 5d6116c

Please sign in to comment.