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

Compute deconvolution parameters in FlashCamExtractor only as needed #2545

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/2545.optimization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compute deconvolution parameters in FlashCamExtractor only as needed.
21 changes: 12 additions & 9 deletions src/ctapipe/image/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_parameters = {}

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_parameters:
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_parameters[tel_id] = deconvolution_parameters(
tel.camera,
self.upsampling.tel[tel_id],
self.window_width.tel[tel_id],
Expand All @@ -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_parameters[tel_id]

@staticmethod
def clip(x, lo=0.0, hi=np.inf):
Expand All @@ -1650,7 +1653,7 @@ def __call__(
leading_edge_timing = self.leading_edge_timing.tel[tel_id]
leading_edge_rel_descend_limit = self.leading_edge_rel_descend_limit.tel[tel_id]

pole_zeros, gains, shifts, pz2ds = self.deconvolution_pars[tel_id]
pole_zeros, gains, shifts, pz2ds = self._get_deconvolution_parameters(tel_id)
pz, gain, shift, pz2d = pole_zeros[0], gains[0], shifts[0], pz2ds[0]

t_waveforms = deconvolve(waveforms, 0.0, upsampling, pz)
Expand Down