CuPy adaptation IDW

11 views
Skip to first unread message

Josh von Nonn

unread,
Jul 22, 2022, 6:03:49 PM7/22/22
to CuPy User Group
Does anyone have any thoughts on how to adapt this Numpy & Scipy code? Any help would be awesome, thanks!

def idw(data):
 
    valid = np.argwhere(~np.isnan(data))
    tree = spatial.cKDTree(valid)
   
    nans = np.argwhere(np.isnan(data))    
    for row in nans:
        d, idx = tree.query(row, k=12)
        d = np.power(d, -2)
        v = data[valid[idx, 0], valid[idx, 1]]
        data[row[0], row[1]] = np.inner(v, d)/np.sum(d)
       
    return data
Reply all
Reply to author
Forward
0 new messages