reldist_nearest.py 文件源码

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

项目:Thrifty 作者: swkrueger 项目源码 文件源码
def reldist_linpol(tx_soa, beacon_soa):
    # Interpolate between two nearest beacon samples
    beacon_rx0, beacon_rx1 = beacon_soa[:, 0], beacon_soa[:, 1]
    tx_rx0, tx_rx1 = tx_soa[:, 0], tx_soa[:, 1]

    high_idx = np.searchsorted(beacon_rx0, tx_rx0)
    low_idx = high_idx - 1
    length = len(beacon_soa[:, 0])
    if high_idx[-1] >= length:
        high_idx[-1] = length - 1
    if low_idx[0] < 0:
        high_idx[0] = 0

    weight = ((tx_rx0 - beacon_rx0[low_idx]) /
              (beacon_rx0[high_idx] - beacon_rx0[low_idx]))
    weight[np.isinf(weight)] = 1  # remove nan
    # Reldist in samples
    reldist = (tx_rx1 - (beacon_rx1[low_idx] * (1-weight) +
                         beacon_rx1[high_idx] * weight))  # / 2.0
    return reldist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号