def index_pix_in_pixels(pix,pixels,sort=False,outside=-1):
    if sort: pixels = np.sort(pixels)
    index = np.searchsorted(pixels,pix)
    if np.isscalar(index):
        if not np.in1d(pix,pixels).any(): index = outside
    else:
        index[~np.in1d(pix,pixels)] = outside
    return index