为了账号安全,请及时绑定邮箱和手机立即绑定

时间序列 - 识别方波型信号的方法

时间序列 - 识别方波型信号的方法

蛊毒传说 2023-12-26 17:07:10
我正在尝试寻找一种方法来过滤掉具有如下所示模式的信号。该模式可以描述为具有方波,通常在多个时间段内具有恒定的波动值+-1、+-2 或+-0。信号通常会瞬间下降到 5-100 标准差,然后在很短的时间内保持恒定速率,然后再次回升。这些类型的信号可以具有单个或多个不同长度的方波,但信号中始终呈现方波。我需要找到一种方法,可以帮助我从大约 3000 个信号中聚类出或过滤掉这些信号。我尝试了以下方法并得到了非常复杂的结果:使用 TSLearn 和 DTW python 包对数字方差相关特征进行单变量时间序列聚类(混合结果)使用 K-Means、KNN 等进行多元聚类(通常可以为单个信号分配多个聚类。规则是一个信号对应一个桶,而不是多个桶)在数组中查找子序列的条件逻辑,希望找到方波(我对此无能为力,因为良好信号的一半长度可以等于信号重要部分的长度的一半;方波)核分布估计(我有其他信号与该信号具有相同的分布,因此我无法根据系数的排名/聚类过滤掉这些信号)您能否推荐其他方法来帮助我从一组其他信号中识别此类信号?如果您的方法是傅里叶变换,您能否提供一个示例,说明我如何使用它从一组其他信号中过滤掉该信号?
查看完整描述

1 回答

?
ITMISS

TA贡献1871条经验 获得超8个赞

这将做到这一点:


def first_der(df):

  y = df.NREVS.values

  x = df.cum_int.values


  dy=np.diff(y,1)

  dx=np.diff(x,1)

  yfirst=dy/dx

  return yfirst


def zero_runs(yfirst):

    # Create an array that is 1 where a is 0, and pad each end with an extra 0.

    iszero = np.concatenate(([0], np.equal(a, 0).view(np.int8), [0]))

    absdiff = np.abs(np.diff(iszero))

    # Runs start and end where absdiff is 1.

    ranges = np.where(absdiff == 1)[0].reshape(-1,2)

    return yind

  

def square_finder(yfirst, yind, df):


  xmax = yind.shape[0]  #max value in first position where y_first can be indexed

  ymax = yind.shape[1] #max value in second position


  thresh = 4

  for i in range(0,xmax):

    if yind[i][1] < len(yfirst):

      if ((yfirst[yind[i][1]] > 5) | (yfirst[yind[i][1]] < -5)):

        #if ((yfirst[yind[i-1][1]+1] > 3) | (yfirst[yind[i-1][1]+1] < -3)):

        zeros = yind[i][1] - yind[i-1][1] - 2

        if zeros >= thresh:

          df['category'] = 'square'

        else:

          pass

      else:

        pass

    else:

      pass

  return df


查看完整回答
反对 回复 2023-12-26
  • 1 回答
  • 0 关注
  • 60 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信