helpers.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:inqbus.rainflow 作者: Inqbus 项目源码 文件源码
def get_extrema(data):
    # find extrema by finding indexes where diff changes sign
    data_diff = np.diff(data)
    asign = np.sign(data_diff)
    signchange = ((np.roll(asign, 1) - asign) != 0).astype(int)

    # first and last value is always a local extrema
    signchange[0] = 1

    # last value is missing because the diff-array is 1 value shorter than the
    # input array so we have to add it again
    signchange = np.append(signchange, np.array([1]))

    calc_data = data[np.where(signchange != 0)]

    return calc_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号