Skip to content

Commit

Permalink
refactoring VarianceExtractor check
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Toennis committed Nov 8, 2024
1 parent c7a8126 commit b9d7efb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/ctapipe/calib/camera/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b9d7efb

Please sign in to comment.