Skip to content

Commit

Permalink
implementing reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Toennis committed Nov 12, 2024
1 parent b9d7efb commit 731e650
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/changes/2636.feature.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Update ``CameraCalibrator`` in ``ctapipe.calib.camera.calibrator`` allowing it to correctly calibrate variance images generated with the ``VarianceExtractor``.
- If the VarianceExtractor is used for the ``CameraCalibrator`` the element-wise square of the relative and absolute gain calibration factors are applied to the image;
- If the ``VarianceExtractor`` is used for the ``CameraCalibrator`` the element-wise square of the relative and absolute gain calibration factors are applied to the image;
- For other image extractors the plain factors are still applied.
- The ``VarianceExtractor`` provides no peak time and the calibrator will not try to skip shifting the peak time for extractors like the ``VarianceExtractor`` that similarly do not provide a peak time
4 changes: 2 additions & 2 deletions src/ctapipe/calib/camera/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ def _calibrate_dl1(self, event, tel_id):

# correct non-integer remainder of the shift if given
if (
self.apply_peak_time_shift.tel[tel_id]
dl1.peak_time is not None
and self.apply_peak_time_shift.tel[tel_id]
and remaining_shift is not None
and dl1.peak_time is not None
):
dl1.peak_time -= remaining_shift

Expand Down
5 changes: 3 additions & 2 deletions src/ctapipe/calib/camera/tests/test_calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ def test_dl1_variance_calib(example_subarray):
image_extractor=VarianceExtractor(subarray=example_subarray),
apply_waveform_time_shift=False,
)
n_channels = 2
n_samples = 100

event = ArrayEventContainer()

for tel_type in example_subarray.telescope_types:
tel_id = example_subarray.get_tel_ids_for_type(tel_type)[0]
n_pixels = example_subarray.tel[tel_id].camera.geometry.n_pixels
n_channels = example_subarray.tel[tel_id].camera.readout.n_channels

random = np.random.default_rng(1)
y = random.normal(0, 6, (n_channels, n_pixels, n_samples))
Expand All @@ -170,9 +170,10 @@ def test_dl1_variance_calib(example_subarray):
for tel_type in example_subarray.telescope_types:
tel_id = example_subarray.get_tel_ids_for_type(tel_type)[0]
image = event.dl1.tel[tel_id].image
camera = example_subarray.tel[tel_id].camera
assert image is not None
assert image.shape == (
2,
camera.readout.n_channels,
example_subarray.tel[tel_id].camera.geometry.n_pixels,
)

Expand Down

0 comments on commit 731e650

Please sign in to comment.