Skip to content

Commit

Permalink
Add max_time which is the time when hit reaches its maximum (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
dachengx authored Oct 17, 2024
1 parent f9dd6c3 commit 292b865
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions strax/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def record_dtype(samples_per_record=DEFAULT_RECORD_LENGTH):
(("Internal (temporary) index of fragment in which hit was found", "record_i"), np.int32),
(("ADC threshold applied in order to find hits", "threshold"), np.float32),
(("Maximum amplitude above baseline [ADC counts]", "height"), np.float32),
(("Time when hit reach maximum amplitude [ns]", "max_time"), np.int64),
]


Expand Down
7 changes: 6 additions & 1 deletion strax/processing/pulse_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def _find_hits(records, min_amplitude, min_height_over_noise, _result_buffer=Non
# Start of a hit
in_interval = True
hit_start = i
if x > height:
max_time = r["time"] + i * r["dt"]
height = max(x, height)

if in_interval:
Expand All @@ -258,7 +260,9 @@ def _find_hits(records, min_amplitude, min_height_over_noise, _result_buffer=Non
in_interval = False
else:
area += x
height = max(height, x)
if x > height:
max_time = r["time"] + i * r["dt"]
height = max(x, height)

if i == n_samples - 1:
# Hit ends at the *end* of this sample
Expand Down Expand Up @@ -289,6 +293,7 @@ def _find_hits(records, min_amplitude, min_height_over_noise, _result_buffer=Non
area += res["length"] * baseline_fpart
res["area"] = area
res["height"] = height + baseline_fpart
res["max_time"] = max_time
area = height = 0

# Yield buffer to caller if needed
Expand Down

0 comments on commit 292b865

Please sign in to comment.