Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete tel attribute from MonitoringCameraContainer in NSBImageCleaner #2602

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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