Return the indices of the super-pixels which contain each of the
    sub-pixels (nside_in > nside_out).

    Parameters:
    -----------
    ipix      : index of the input subpixels
    nside_in  : nside of the input subpix
    nside_out : nside of the desired superpixels

    Returns:
    --------
    ipix_out  : superpixels for each subpixel

def d_grade_ipix(ipix, nside_in, nside_out, nest=False):
    """
    Return the indices of the super-pixels which contain each of the
    sub-pixels (nside_in > nside_out).

    Parameters:
    -----------
    ipix      : index of the input subpixels
    nside_in  : nside of the input subpix
    nside_out : nside of the desired superpixels

    Returns:
    --------
    ipix_out  : superpixels for each subpixel
    """

    if nside_in==nside_out: return ipix
    if not (nside_in > nside_out): 
        raise ValueError("nside_out must be less than nside_in")

    return hp.vec2pix(nside_out, *hp.pix2vec(nside_in, ipix, nest), nest=nest)