def generalIntOverMassFn(beta, mExponent, extra_integrand, h, whichp = 0): """ beta Computes I (k) (as in Cooray & Hu (2001)), integrating over the halo mass function. mu beta: order of bias coefficient (b_beta in the integrand) mExponent: additional (over the power of m from the logarithmic integration) mass exponent (put mu here) extra_integrand: e.g. halo density profiles h: halo model instance e.g. i11[k] = integralOverMassFn(1,1, g.int(h.fthp[k,:,:]),h) where the two : indices in h.fthp are for mass and concentration parameter; g.int integrates over concentration parameter, so g.int(h.fthp[k,:,:]) is an array for each mass. """ if whichp == 0: whichp == h.p.whichp if whichp == 'gg': integrand = h.b[beta,:]*h.m*hodMoment(mExponent,h)*h.nmz * extra_integrand elif whichp == 'mm': integrand = h.b[beta,:]*h.m*h.m**(mExponent)*h.nmz * extra_integrand ans = utils.simpsonRule(integrand, h.dlogm) return ans
def intOverMassFn(beta, mExponent, karrayunnumed, h, whichp = 0, plot = 0, show = 0,colstr = ''): """ Get an integral of, e.g., halo density profiles over the mass function. More automatic than generalIntOverMassFn. beta Computes I (k) (as in Cooray & Hu (2001)), integrating over the halo mass function. mu beta: order of bias coefficient (b_beta in the integrand) mExponent: additional (over the power of m from the logarithmic integration) mass exponent (put mu here). karrayunnumed: Array of k indices to evaluate Fourier-transformed halo density profile h: halo model instance whichp: for now, 'gg' -> galaxy statistics. 'mm' -> matter stats. Default: h.p.whichp """ if whichp == 0: whichp = h.p.whichp karray = M.array(karrayunnumed) if len(karray) != mExponent: print "Warning! Different number of k indices than mExponent!" g = utils.HGQ(5) # 5-pt Hermite-Gauss quadrature class uM = h.fthp[0,:,:]*0. + 1. g_integrand = h.fthp[0,:,:]*0. + 1. if whichp == 'gg': """ Right now, we've only implemented the Kravtsov-style 'satellite' halo occupation distribution, i.e. the HOD excluding the central galaxy. For example, in Smith, Watts & Sheth 2006, sect. 5.4, the halo integrands simplify in the case of a satellite HOD in eq. 72 (one-halo P_gg) to <Ns(Ns-1)> |u(k)|^2 + 2 <Ns> u(k). This second term includes the contribution of the central galaxy. In general, using SWS's notation, the n-galaxy convolution kernel (e.g. eq. 76) is W^ng(k_0, ..., k_n) = <Ns(Ns-1)...(Ns-n)> u(k_0)...u(k_n) + Sum_i <Ns...(Ns-(n-1))> u(k_0)...u(k_n)/u(k_i). """ hodNsMomentM = M.outer(hodNsMoment(mExponent,h),1.*M.ones(5)) hodNsMomentMminus1 = M.outer(hodNsMoment(mExponent-1,h),1.*M.ones(5)) # Leading term in mExponent; fthp(k)^mExponent for ki in karray: uM *= h.fthp[ki,:,:] g_integrand = hodNsMomentM*uM*1. #mExponent * fthp^(mExponent-1) term for ki in karray: g_integrand += hodNsMomentMminus1 * uM/h.fthp[ki,:,:] extra_integrand = g.int(g_integrand) elif whichp == 'mm': for ki in karray: g_integrand *= h.fthp[ki,:,:] extra_integrand = h.m**(mExponent)* g.int(g_integrand) integrand = h.b[beta,:]*h.m*h.nmz * extra_integrand if plot == 1: M.loglog(h.m[::10],integrand[::10],colstr) #M.semilogx(h.m,integrand) if show == 1: M.show() ans = utils.simpsonRule(integrand[:h.integratetoindex], h.dlogm) if whichp == 'gg': ans /= h.ngalbar**mExponent return ans