如何使用 as_strided 检测触发信号的上升沿?

时间:2021-02-04 22:11:44

标签: python-3.x numpy

我处理来自我的测量系统的数据,并将下面显示的数据用作我的触发信号,以进行进一步的数据处理。请找到 numpy 格式的数据文件 here。目前我使用此代码来检测触发器的上升沿:

def find_rising_flanks(data: np.ndarray) -> np.ndarray:
    mask = (data >= MAX_SENSOR_READOUT)
    # count the number of times the value is below thresh in the window
    below_thresh = np.sum([mask[i:len(mask) - WINDOW_SIZE + i] for i in range(WINDOW_SIZE)], axis=0)
    idx_mask = below_thresh == WINDOW_SIZE
    rising_flanks = np.where(idx_mask[1:] & (~idx_mask[:-1]))[0] + WINDOW_SIZE + 1
    return rising_flanks

但是,使用此代码可以在第一个块中找到侧翼(图中的 0 到 600 之间),而我真的想要第一个 上升 侧翼在~1600。明显的区别是,在几个“正常数字”之前有几个没有 -infinf 的样本,然后是几个 inf 样本。所以我猜我需要搜索一个带有“not -inf and not inf”的窗口,然后搜索一个充满“inf”的窗口。

Someone 建议 as_strided 可能是更大窗口的更好解决方案。这将如何运作?

trigger signal

0 个答案:

没有答案