def compute_search_volume_in_bins(found, total, ndbins, sim_to_bins_function):
    """
    Calculate search sensitive volume by integrating efficiency in distance bins

    No cosmological corrections are applied: flat space is assumed.
    The first dimension of ndbins must be bins over injected distance.
    sim_to_bins_function must maps an object to a tuple indexing the ndbins.
    """
    eff, err = compute_search_efficiency_in_bins(
                                    found, total, ndbins, sim_to_bins_function)
    dx = ndbins[0].upper() - ndbins[0].lower()
    r = ndbins[0].centres()

    # volume and errors have one fewer dimension than the input NDBins
    vol = bin_utils.BinnedArray(bin_utils.NDBins(ndbins[1:]))
    errors = bin_utils.BinnedArray(bin_utils.NDBins(ndbins[1:]))

    # integrate efficiency to obtain volume
    vol.array = numpy.trapz(eff.array.T * 4. * numpy.pi * r**2, r, dx)

    # propagate errors in eff to errors in V
    errors.array = numpy.sqrt(
        ((4 * numpy.pi * r**2 * err.array.T * dx)**2).sum(axis=-1)
    )

    return vol, errors
def compute_search_volume_in_bins ( found , total , ndbins , sim_to_bins_function ) : eff , err = compute_search_efficiency_in_bins ( found , total , ndbins , sim_to_bins_function ) dx = ndbins [ 0 ] . upper ( ) - ndbins [ 0 ] . lower ( ) r = ndbins [ 0 ] . centres ( ) vol = bin_utils . BinnedArray ( bin_utils . NDBins ( ndbins [ 1 : ] ) ) errors = bin_utils . BinnedArray ( bin_utils . NDBins ( ndbins [ 1 : ] ) ) vol . array = numpy . trapz ( eff . array . T * 4. * numpy . pi * r ** 2 , r , dx ) errors . array = numpy . sqrt ( ( ( 4 * numpy . pi * r ** 2 * err . array . T * dx ) ** 2 ) . sum ( axis = - 1 ) ) return vol , errors
Calculate search sensitive volume by integrating efficiency in distance bins

    No cosmological corrections are applied: flat space is assumed.
    The first dimension of ndbins must be bins over injected distance.
    sim_to_bins_function must maps an object to a tuple indexing the ndbins.