Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimate cleaning threshold with CatB pedestals if availables #1143

Merged
merged 10 commits into from
Nov 30, 2023
1 change: 1 addition & 0 deletions lstchain/calib/camera/pixel_threshold_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def get_threshold_from_dl1_file(dl1_path, sigma_clean):
# return pedestal interleaved threshold from data run for high gain
return threshold_clean_pe[pedestal_id, HIGH_GAIN, :]


def get_unusable_pixels(dl1_path, pedestal_id):
with tables.open_file(dl1_path) as f:
calibration_id = f.root.dl1.event.telescope.monitoring.pedestal.col('calibration_id')
Expand Down
3 changes: 3 additions & 0 deletions lstchain/io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
dl1_params_tel_mon_ped_key = "/dl1/event/telescope/monitoring/pedestal"
dl1_params_tel_mon_cal_key = "/dl1/event/telescope/monitoring/calibration"
dl1_params_tel_mon_flat_key = "/dl1/event/telescope/monitoring/flatfield"
dl1_params_mon_tel_catB_ped_key = "/dl1/monitoring/telescope/CatB/pedestal"
dl1_params_mon_tel_catB_cal_key = "/dl1/monitoring/telescope/CatB/calibration"
dl1_params_mon_tel_catB_flat_key = "/dl1/monitoring/telescope/CatB/flatfield"
FrancaCassol marked this conversation as resolved.
Show resolved Hide resolved
dl1_params_lstcam_key = "/dl1/event/telescope/parameters/LST_LSTCam"
dl1_images_lstcam_key = "/dl1/event/telescope/image/LST_LSTCam"
dl2_params_lstcam_key = "/dl2/event/telescope/parameters/LST_LSTCam"
Expand Down
20 changes: 17 additions & 3 deletions lstchain/scripts/lstchain_dl1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
dl1_params_lstcam_key,
global_metadata,
write_metadata,
dl1_params_mon_tel_catB_ped_key,
FrancaCassol marked this conversation as resolved.
Show resolved Hide resolved
dl1_params_mon_tel_catB_flat_key,
dl1_params_mon_tel_catB_cal_key
)
from lstchain.io.lstcontainers import DL1ParametersContainer
from lstchain.reco.disp import disp
Expand Down Expand Up @@ -126,7 +129,10 @@ def main():

catB_calib_time = np.array(catB_calib["time_min"])
catB_dc_to_pe = np.array(catB_calib["dc_to_pe"])

catB_pedestal_per_sample = np.array(catB_calib["pedestal_per_sample"])
catB_pedestal_mean = np.array(catB_pedestal["charge_mean"])
catB_pedestal_std= np.array(catB_pedestal["charge_std"])

catB_time_correction = np.array(catB_calib["time_correction"])
catB_unusable_pixels = np.array(catB_calib["unusable_pixels"])
Expand Down Expand Up @@ -325,6 +331,14 @@ def main():
image_table['image'][ii] = image
image_table['peak_time'][ii] = peak_time

# use CatB pedestals to estimate the picture threshold
if args.pedestal_cleaning:
ped_charge_mean_pe = catB_pedestal_mean[calib_idx][selected_gain, pixel_index]
ped_charge_std_pe = catB_pedestal_std[calib_idx][selected_gain, pixel_index]
aaguasca marked this conversation as resolved.
Show resolved Hide resolved
threshold_clean_pe = ped_charge_mean_pe + sigma * ped_charge_std_pe
threshold_clean_pe[unusable_pixels] = pic_th
FrancaCassol marked this conversation as resolved.
Show resolved Hide resolved
picture_th = np.clip(pedestal_thresh, pic_th, None)
aaguasca marked this conversation as resolved.
Show resolved Hide resolved

if increase_nsb:
# Add noise in pixels, to adjust MC to data noise levels.
# TO BE DONE: in case of "pedestal cleaning" (not used now
Expand Down Expand Up @@ -431,9 +445,9 @@ def main():

# write a cat-B calibrations in DL1b
if catB_calib:
write_table(catB_calib, outfile, "/dl1/event/telescope/monitoring/catB/calibration")
write_table(catB_pedestal, outfile, "/dl1/event/telescope/monitoring/catB/pedestal")
write_table(catB_flatfield, outfile, "/dl1/event/telescope/monitoring/catB/flatfield")
write_table(catB_calib, outfile, dl1_params_mon_tel_catB_cal_key)
FrancaCassol marked this conversation as resolved.
Show resolved Hide resolved
write_table(catB_pedestal, outfile, dl1_params_mon_tel_catB_ped_key)
write_table(catB_flatfield, outfile,dl1_params_mon_tel_catB_flat_key)

write_metadata(metadata, args.output_file)

Expand Down