From a7fab337d79e3a15d47dec2a822a855987843feb Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Tue, 29 Aug 2023 15:38:56 +0000 Subject: [PATCH 1/4] correct calibration data to be used in muon analysis --- lstchain/reco/r0_to_dl1.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lstchain/reco/r0_to_dl1.py b/lstchain/reco/r0_to_dl1.py index a9b49aa0eb..2414bac6d1 100644 --- a/lstchain/reco/r0_to_dl1.py +++ b/lstchain/reco/r0_to_dl1.py @@ -661,7 +661,8 @@ def r0_to_dl1( # Muon ring analysis, for real data only (MC is done starting from DL1 files) if not is_simu: - bad_pixels = event.mon.tel[telescope_id].calibration.unusable_pixels[0] + bad_pixels = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration.unusable_pixels[0] + # Set to 0 unreliable pixels: image = dl1_tel.image*(~bad_pixels) @@ -670,8 +671,9 @@ def r0_to_dl1( # re-calibrate r1 to obtain new dl1, using a more adequate pulse integrator for muon rings numsamples = event.r1.tel[telescope_id].waveform.shape[1] # not necessarily the same as in r0! - bad_pixels_hg = event.mon.tel[telescope_id].calibration.unusable_pixels[0] - bad_pixels_lg = event.mon.tel[telescope_id].calibration.unusable_pixels[1] + bad_pixels_hg = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration.unusable_pixels[0] + bad_pixels_lg = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration.unusable_pixels[1] + # Now set to 0 all samples in unreliable pixels. Important for global peak # integrator in case of crazy pixels! TBD: can this be done in a simpler # way? From 70868992cde50a160c7a14be12a8e45df5d5ea0f Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Tue, 29 Aug 2023 15:39:24 +0000 Subject: [PATCH 2/4] correct type of unusable_pixels array --- lstchain/calib/camera/calibration_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lstchain/calib/camera/calibration_calculator.py b/lstchain/calib/camera/calibration_calculator.py index febd736663..39d47a43c3 100644 --- a/lstchain/calib/camera/calibration_calculator.py +++ b/lstchain/calib/camera/calibration_calculator.py @@ -1,7 +1,6 @@ """ Component for the estimation of the calibration coefficients events """ - import numpy as np import h5py from ctapipe.core import Component, traits @@ -223,7 +222,7 @@ def calculate_calibration_coefficients(self, event): npe_deviation > self.npe_median_cut_outliers[1] * tot_std[:,np.newaxis])) # calibration unusable pixels are an OR of all masks - calib_data.unusable_pixels = np.logical_or(unusable_pixels, npe_outliers) + calib_data.unusable_pixels = np.logical_or(unusable_pixels, npe_outliers).filled(True) # give to the unusable pixels the median camera value for the dc_to_pe and pedestal # (these are the starting data for the Cat-B calibration) @@ -269,6 +268,7 @@ def process_interleaved(self, event): if new_ff: self.calculate_calibration_coefficients(event) + return new_ped, new_ff def output_interleaved_results(self, event): From 6492bc3710be573e3fa9e786f5d6f5683495b98a Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Wed, 30 Aug 2023 10:51:02 +0000 Subject: [PATCH 3/4] make shorter name --- lstchain/reco/r0_to_dl1.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lstchain/reco/r0_to_dl1.py b/lstchain/reco/r0_to_dl1.py index 2414bac6d1..5c3e94d915 100644 --- a/lstchain/reco/r0_to_dl1.py +++ b/lstchain/reco/r0_to_dl1.py @@ -376,6 +376,7 @@ def r0_to_dl1( ) if not is_simu: + calibration_mon = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration # Pulse extractor for muon ring analysis. Same parameters (window_width and _shift) as the one for showers, but # using GlobalPeakWindowSum, since the signal for the rings is expected to be very isochronous @@ -661,7 +662,7 @@ def r0_to_dl1( # Muon ring analysis, for real data only (MC is done starting from DL1 files) if not is_simu: - bad_pixels = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration.unusable_pixels[0] + bad_pixels = calibration_mon.unusable_pixels[0] # Set to 0 unreliable pixels: image = dl1_tel.image*(~bad_pixels) @@ -671,8 +672,8 @@ def r0_to_dl1( # re-calibrate r1 to obtain new dl1, using a more adequate pulse integrator for muon rings numsamples = event.r1.tel[telescope_id].waveform.shape[1] # not necessarily the same as in r0! - bad_pixels_hg = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration.unusable_pixels[0] - bad_pixels_lg = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration.unusable_pixels[1] + bad_pixels_hg = calibration_mon.unusable_pixels[0] + bad_pixels_lg = calibration_mon.unusable_pixels[1] # Now set to 0 all samples in unreliable pixels. Important for global peak # integrator in case of crazy pixels! TBD: can this be done in a simpler From 7ce6604febef06a00460fde575747bb33c52898e Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Wed, 30 Aug 2023 12:17:26 +0000 Subject: [PATCH 4/4] move definition where telescope_id is defined --- lstchain/reco/r0_to_dl1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lstchain/reco/r0_to_dl1.py b/lstchain/reco/r0_to_dl1.py index 5c3e94d915..059358b73e 100644 --- a/lstchain/reco/r0_to_dl1.py +++ b/lstchain/reco/r0_to_dl1.py @@ -376,7 +376,6 @@ def r0_to_dl1( ) if not is_simu: - calibration_mon = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration # Pulse extractor for muon ring analysis. Same parameters (window_width and _shift) as the one for showers, but # using GlobalPeakWindowSum, since the signal for the rings is expected to be very isochronous @@ -613,6 +612,9 @@ def r0_to_dl1( ) if not is_simu: + + calibration_mon = source.r0_r1_calibrator.mon_data.tel[telescope_id].calibration + dl1_container.ucts_time = 0 # convert Time to unix timestamp in (UTC) to keep compatibility # with older lstchain