From e3d95fd6f7fe097d516e8c9d84c7ded5d78b7aec Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Wed, 24 Apr 2024 18:03:51 +0200 Subject: [PATCH] Compute deconvolution parameters in FlashCamExtractor only as needed --- src/ctapipe/image/extractor.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ctapipe/image/extractor.py b/src/ctapipe/image/extractor.py index 1d4cfd5881d..5edd9e8e240 100644 --- a/src/ctapipe/image/extractor.py +++ b/src/ctapipe/image/extractor.py @@ -1616,14 +1616,18 @@ def __init__(self, subarray, **kwargs): tel_id: telescope.camera.readout.sampling_rate.to_value("GHz") for tel_id, telescope in subarray.tel.items() } + self._deconvolution_pars = {} - def time_profile_pdf_gen(std_dev: float): - if std_dev == 0: - return None - return scipy.stats.norm(0.0, std_dev).pdf + def _get_deconvolution_parameters(self, tel_id): + if tel_id not in self._deconvolution_pars: + tel = self.subarray.tel[tel_id] - self.deconvolution_pars = { - tel_id: deconvolution_parameters( + def time_profile_pdf_gen(std_dev: float): + if std_dev == 0: + return None + return scipy.stats.norm(0.0, std_dev).pdf + + self._deconvolution_pars[tel_id] = deconvolution_parameters( tel.camera, self.upsampling.tel[tel_id], self.window_width.tel[tel_id], @@ -1632,8 +1636,7 @@ def time_profile_pdf_gen(std_dev: float): self.leading_edge_rel_descend_limit.tel[tel_id], time_profile_pdf_gen(self.effective_time_profile_std.tel[tel_id]), ) - for tel_id, tel in subarray.tel.items() - } + return self._deconvolution_pars[tel_id] @staticmethod def clip(x, lo=0.0, hi=np.inf):