Skip to content

Commit

Permalink
Fix possible out of bounds error in FlashCamExtractor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Apr 24, 2024
1 parent 5f7cf63 commit aa6db8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ctapipe/image/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,15 +1528,15 @@ def adaptive_centroid(waveforms, peak_index, rel_descend_limit, centroids):
sum_ += waveforms[j]
jsum += j * waveforms[j]
j -= 1
if waveforms[j] > peak_amplitude:
if j > 0 and waveforms[j] > peak_amplitude:
descend_limit = rel_descend_limit * peak_amplitude

j = peak_index + 1
while j < n_samples and waveforms[j] > descend_limit:
sum_ += waveforms[j]
jsum += j * waveforms[j]
j += 1
if waveforms[j] > peak_amplitude:
if j < n_samples and waveforms[j] > peak_amplitude:
descend_limit = rel_descend_limit * peak_amplitude

if sum_ != 0.0:
Expand Down

0 comments on commit aa6db8e

Please sign in to comment.