예제 #1
0
    def refreshHOD(self,c):
        """
        Do this if you change a HOD parameter
        """
        self.k_mmin = massfn.msun2chimp(self.p.k_mmin_msun,c)
        self.k_m1 = self.k_mmin * self.p.k_m1overmmin
        self.mcut = massfn.msunh2chimp(self.p.mcut_msunh,c)
        self.m11 = massfn.msunh2chimp(self.p.m11_msunh,c)
        self.m13 = massfn.msunh2chimp(self.p.m13_msunh,c)
        self.logsqrtfact = M.log(M.sqrt(self.m13/self.m11))

        self.ngalbar = generalIntOverMassFn(0,1, 1.,self,whichp = 'gg')
예제 #2
0
    def run(self,c): # c is a camb object
        self.z = c.cp.transfer_redshift[0]
        self.dlog10m = 1./self.p.massdivsperdex
        self.dlogm = self.dlog10m * M.log(10.)
        if self.p.lomass == 0.:
            self.p.lomass = (4.*M.pi/3.)*c.cp.omega_cdm*(2.*M.pi/c.k[-1])**3
        self.m_pad = self.p.lomass*\
                M.exp(M.arange(-self.dlogm,M.log(self.p.himass/self.p.lomass)+self.dlogm*2, self.dlogm))
        self.m = self.m_pad[1:-2]
        if self.p.integrateto == 0.:
            self.integratetoindex = len(self.m)
        else:
            self.integratetoindex = N.where(self.m < self.p.integrateto)[0][-1]

        ps = pt.PowerSpectrum(c.cp)
        if self.p.delta == 0.:
            self.delta = ps.deltac(self.z)
        else:
            self.delta = self.p.delta
        print 'delta = ',self.delta
        self.deltaz0 = ps.deltac(0.) #the ~1.67 factor, without redshift correction
        sigma_pad = M.sqrt(pt.sigma2fromPk(c,massfn.chimpRadius(self.m_pad))) * ps.d1(0.)/ps.d1(self.z)

        # calculate sigma with ps normalized to z=0
        self.nu_pad = self.delta/sigma_pad
        self.sigma = sigma_pad[1:-2]
        self.nu = self.nu_pad[1:-2]
        self.b = getHaloBiasCoef(self)
        massfn.getMassFunction(self,c) # sets h.nmz

        bint0 = generalIntOverMassFn(0,1,1.,self,whichp='mm')
        bint1 = generalIntOverMassFn(1,1,1.,self,whichp='mm')
        bint2 = generalIntOverMassFn(2,1,1.,self,whichp='mm')
        #test 1st,2nd-order bias.  bint0,1 should be ~1, bint2 should be ~0
        if (M.fabs(M.log(bint0)) > 0.01) + (M.fabs(M.log(bint1)) > 0.01) + (M.fabs(bint2) > 0.01):
            print 'Warning! (bint0,1,2) = ',bint0,bint1,bint2
            print 'Should be about (1,1,0).  If worried, increase range of mass integration,'
            print 'mass bins per dex, or extrapolate c.pk (which affects sigma(m))'
        self.mstar = mStar(self.m,self.nu)
        self.logcbar = getLogcbar(self)
        #self.k = c.k[self.p.startki::self.p.strideki]

        self.k = self.p.k*1.
        
        if self.p.use_sea_2h: #Use nonlinear power spectrum for 2h term
            # not recently tested
            cp_cnl = copy.copy(c.cp)
            cp_cnl['do_nonlinear'] = 1
            cnl = pt.Camb(cambParam = cp_cnl)
            cnl.run()
            self.pk = M.exp(utils.splineIntLinExt(M.log(cnl.pk),M.log(cnl.k),M.log(self.k)))

        else: #Use linear power spectrum for 2h term
            self.pk = c.pkInterp(self.k)

        if self.p.dofthp == 1:
            self.fthp = deltah(self)

        # Convert Kravtsov HOD quantities to internal units (chimps, etc.)
        self.k_mmin = massfn.msun2chimp(self.p.k_mmin_msun,c)
        self.k_m1 = self.k_mmin * self.p.k_m1overmmin
        # for the non-Kravtsov HOD, for some reason, we use units of msun/h
        self.mcut = massfn.msunh2chimp(self.p.mcut_msunh,c)
        self.m11 = massfn.msunh2chimp(self.p.m11_msunh,c)
        self.m13 = massfn.msunh2chimp(self.p.m13_msunh,c)
        self.logsqrtfact = M.log(M.sqrt(self.m13/self.m11))

        self.ngalbar = generalIntOverMassFn(0,1, 1.,self,whichp='gg')