def FKPWeightFromNbar(P0, nbar):
    """ Create FKPWeight from nbar, the number density of objects per redshift.

        Parameters
        ----------
        P0 : float
            the FKP normalization, when P0 == 0, returns 1.0, ignoring size / shape of nbar.

        nbar : array_like
            the number density of objects per redshift

        Returns
        -------
        FKPWeight : the FKPWeight, can be assigned to a catalog as a column
        to be consumed :class:`ConvolvedFFTPower`

    """
    if P0 != 0:
        return 1.0 / (1.0 + P0 * nbar)
    return 1.0
