A gripper test report needs to describe a force pulse that reaches a flat maximum for several samples. One number should tell the reviewer which recorded samples stayed at the maximum. Another should tell the reviewer how far apart the rising and falling edges cross a chosen force level. SciPy can return both measurements from the same signal, using different definitions for the two results.

Find the samples on the flat top

The test trace below has eight equally spaced readings in newtons. Four consecutive samples have a value of 4 N. SciPy returns index 3 for the peak because it uses the earlier of the two middle samples on an even-length flat top. The returned edges, 2 and 5, are both on the plateau. Counting both endpoints gives four samples.

import numpy as np

from scipy.signal import find_peaks

force_n = np.array([0, 1, 4, 4, 4, 4, 1, 0], dtype=float)

peaks, props = find_peaks(

force_n, plateau_size=(None, None),

width=(None, None), rel_height=0.5,

)

assert peaks.tolist() == [3]

assert props["left_edges"].tolist() == [2]

assert props["right_edges"].tolist() == [5]

assert props["plateau_sizes"].tolist() == [4]

assert np.allclose(props["width_heights"], [2.0])

assert np.allclose(props["left_ips"], [4 / 3])

assert np.allclose(props["right_ips"], [17 / 3])

assert np.allclose(props["widths"], [13 / 3])

The open intervals request measurements without filtering peaks by these two properties. In this fixture the prominence is 4 N because the surrounding baseline is zero. At rel_height=0.5 the evaluation level is 4 N minus half that prominence, or 2 N. Linear interpolation places the crossings at sample coordinates 1.333 and 5.667. The measured width is 4.333 sample intervals. These assertions passed with SciPy 1.18.1 and NumPy 2.5.5.

Keep count, time span, and contour in the report

At 1 kHz the centers of the first and last flat samples are 3 ms apart, and the half-prominence crossings are about 4.333 ms apart. The four observed plateau samples establish the span between those recorded centers. An estimate of continuous dwell time requires a separate convention for transitions between readings. If the device samples at uneven times, use the recorded timestamps and document how crossing times are interpolated.

Store the inclusive edges, plateau count, and representative peak index alongside the contour height, relative prominence setting, and interpolated endpoints. A review that asks how long force stayed above a fixed acceptance threshold needs that threshold and its own crossing calculation. An equal-valued plateau can also occur when readings reach the sensor or acquisition range limit. If the maximum is near that limit, check the raw readings and range flags before interpreting the plateau as sustained physical force.

Sources

SciPy find_peaks reference for flat maxima and property requests

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html

SciPy peak_widths reference for prominence-based contours and interpolated crossings

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.peak_widths.html