Skip to content

Commit

Permalink
Merge pull request #1151 from cta-observatory/fix_unusable_pixels
Browse files Browse the repository at this point in the history
Fix unusable pixels usage in muon analysis
  • Loading branch information
rlopezcoto authored Aug 31, 2023
2 parents 47a5b40 + 7ce6604 commit 9197200
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lstchain/calib/camera/calibration_calculator.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -273,6 +272,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):
Expand Down
11 changes: 8 additions & 3 deletions lstchain/reco/r0_to_dl1.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,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
Expand Down Expand Up @@ -661,7 +664,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 = calibration_mon.unusable_pixels[0]

# Set to 0 unreliable pixels:
image = dl1_tel.image*(~bad_pixels)

Expand All @@ -670,8 +674,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 = 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
# way?
Expand Down

0 comments on commit 9197200

Please sign in to comment.