From b9d7efb5d9473a2c13ba8d27166a82ef52b0d609 Mon Sep 17 00:00:00 2001 From: Christoph Toennis Date: Fri, 8 Nov 2024 18:26:46 +0100 Subject: [PATCH] refactoring VarianceExtractor check --- src/ctapipe/calib/camera/calibrator.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ctapipe/calib/camera/calibrator.py b/src/ctapipe/calib/camera/calibrator.py index d0c7674a4ad..8b4f0c8bc15 100644 --- a/src/ctapipe/calib/camera/calibrator.py +++ b/src/ctapipe/calib/camera/calibrator.py @@ -296,21 +296,17 @@ def _calibrate_dl1(self, event, tel_id): and dl1_calib.absolute_factor is not None ): if selected_gain_channel is None: - if isinstance(extractor, VarianceExtractor): - dl1.image *= np.square( - dl1_calib.relative_factor / dl1_calib.absolute_factor - ) - else: - dl1.image *= dl1_calib.relative_factor / dl1_calib.absolute_factor + calibration = dl1_calib.relative_factor / dl1_calib.absolute_factor else: - corr = ( + calibration = ( dl1_calib.relative_factor[selected_gain_channel, pixel_index] / dl1_calib.absolute_factor[selected_gain_channel, pixel_index] ) - if isinstance(extractor, VarianceExtractor): - dl1.image *= np.square(corr) - else: - dl1.image *= corr + + if isinstance(extractor, VarianceExtractor): + calibration = calibration**2 + + dl1.image *= calibration # handle invalid pixels if self.invalid_pixel_handler is not None: