From d86b0642b2a87ec210e071d1e29371099d582ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Fr=C3=B6se?= Date: Fri, 27 Oct 2023 14:38:38 +0200 Subject: [PATCH] flatfielding factor instead of absolute & relative --- ctapipe/calib/camera/calibrator.py | 2 +- ctapipe/calib/camera/tests/test_calibrator.py | 6 ++++-- ctapipe/containers.py | 13 ++++--------- docs/changes/2433.bugfix.rst | 3 +++ 4 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 docs/changes/2433.bugfix.rst diff --git a/ctapipe/calib/camera/calibrator.py b/ctapipe/calib/camera/calibrator.py index 0e29f7f228c..061558ba478 100644 --- a/ctapipe/calib/camera/calibrator.py +++ b/ctapipe/calib/camera/calibrator.py @@ -271,7 +271,7 @@ def _calibrate_dl1(self, event, tel_id): dl1.peak_time -= remaining_shift # Calibrate extracted charge - dl1.image *= dl1_calib.relative_factor / dl1_calib.absolute_factor + dl1.image *= dl1_calib.flatfielding_factor # handle invalid pixels if self.invalid_pixel_handler is not None: diff --git a/ctapipe/calib/camera/tests/test_calibrator.py b/ctapipe/calib/camera/tests/test_calibrator.py index b70c6a4aee1..889bbf4ec97 100644 --- a/ctapipe/calib/camera/tests/test_calibrator.py +++ b/ctapipe/calib/camera/tests/test_calibrator.py @@ -173,6 +173,9 @@ def test_dl1_charge_calib(example_subarray): relative = random.normal(1, 0.01, n_pixels) y /= relative[:, np.newaxis] + # Define flatfielding coefficients + flatfielding = relative / absolute + # Define pedestal pedestal = random.uniform(-4, 4, n_pixels) y += pedestal[:, np.newaxis] @@ -191,8 +194,7 @@ def test_dl1_charge_calib(example_subarray): np.testing.assert_allclose(event.dl1.tel[tel_id].image, y.sum(1), rtol=1e-4) event.calibration.tel[tel_id].dl1.pedestal_offset = pedestal - event.calibration.tel[tel_id].dl1.absolute_factor = absolute - event.calibration.tel[tel_id].dl1.relative_factor = relative + event.calibration.tel[tel_id].dl1.flatfielding_factor = flatfielding # Test without timing corrections calibrator(event) diff --git a/ctapipe/containers.py b/ctapipe/containers.py index 3fbb88a762c..5008d90aced 100644 --- a/ctapipe/containers.py +++ b/ctapipe/containers.py @@ -523,16 +523,11 @@ class DL1CameraCalibrationContainer(Container): " This value is subtracted from the waveforms of each pixel before" " the pulse extraction.", ) - absolute_factor = Field( + flatfielding_factor = Field( 1, - "Multiplicative coefficients for the absolute calibration of extracted charge into " - "physical units (e.g. photoelectrons or photons) for each pixel", - ) - relative_factor = Field( - 1, - "Multiplicative Coefficients for the relative correction between pixels to achieve a " - "uniform charge response (post absolute calibration) from a " - "uniform illumination.", + "Multiplicative coefficients for the relative correction between " + "pixels to achieve a uniform charge response " + "(post absolute calibration) from a uniform illumination.", ) time_shift = Field( None, diff --git a/docs/changes/2433.bugfix.rst b/docs/changes/2433.bugfix.rst new file mode 100644 index 00000000000..c4af68daaa7 --- /dev/null +++ b/docs/changes/2433.bugfix.rst @@ -0,0 +1,3 @@ +Change DL1 charge calibration in event to be a single, relative coefficient +per channel / pixel instead of having an absolute factor for conversion to +p.e. and a relative factor for achieving a uniform charge distrubtion.