Thanks to Neil for logic level hinting. I can find the starting points of my signal.
- Apply logic level to the signal.
import pandas as pd
from scipy.ndimage import gaussian_filter1d
def logic_level_gaussian(signal_y: pd.Series, size:int=10) -> typ.List[float]:
"""Visualize logic level and apply gaussian filter to smooth the signal."""
logic_level_y = []
for _ in gaussian_filter1d(signal_y, 10):
if total_mean + 0.05 * total_sd < _:
logic_level_y.append(1)
elif _ < total_mean - 0.05 * total_sd:
logic_level_y.append(-1)
else:
logic_level_y.append(0)
plt.plot(logic_level_y)
plt.plot(signal_y)
return logic_level_y
logic_50 = logic_level_gaussian(y, 50)
The logic level result.

Find my down kick
and put them into array
down_kick_time_array = []
for my_time, my_y in zip(x, logic_50):
# Find down kick
if my_y < 0:
down_kick_time_array.append(my_time)

- Cluster them using
cluster()
from here
logic_level_groups = cluster(down_kick_time_array, maxgap=1)
- Now I can identify starting point of firing kick and reflecting kick. They are
for _ in logic_level_groups:
print(f"Starting point of this cluster is: {_[0]}")
Starting point of this cluster is: 1.471
Starting point of this cluster is: 2.651
Starting point of this cluster is: 10.205
Therefore
logic_level_groups[-1][0] - logic_level_groups[0][0]
8.734
The time between firing kick and reflecting kick is 8.734 ms