def bias(k, Pk, OmegaM, M, author):
    rhoM = rho_crit * OmegaM

    R = (3.0 * M / (4.0 * pi * rhoM))**(1.0 / 3.0)

    if author == 'SMT01':
        a = 0.707
        b = 0.5
        c = 0.6
        anu = a * (deltac / MFL.sigma(k, Pk, R))**2

        bias = np.sqrt(a) * anu + np.sqrt(a) * b * anu**(1.0 - c)
        bias = bias - anu**c / (anu**c + b * (1.0 - c) * (1.0 - 0.5 * c))
        bias = 1.0 + bias / (np.sqrt(a) * deltac)

    if author == 'Tinker':
        Delta = 200.0
        y = np.log10(Delta)

        A = 1.0 + 0.24 * y * np.exp(-(4.0 / y)**4)
        a = 0.44 * y - 0.88
        B = 0.183
        b = 1.5
        C = 0.019 + 0.107 * y + 0.19 * np.exp(-(4.0 / y)**4)
        c = 2.4

        nu = deltac / MFL.sigma(k, Pk, R)

        bias = 1.0 - A * nu**a / (nu**a + deltac**a) + B * nu**b + C * nu**c

    return bias
Esempio n. 2
0
def bias(k_in, Pk_in, OmegaM, Masses, author, bins=10000):

    rhoM = rho_crit * OmegaM

    # sort the input k-array
    indexes = np.argsort(k_in)
    k_in = k_in[indexes]
    Pk_in = Pk_in[indexes]

    # interpolate the input k-array into bins points
    k = np.logspace(np.log10(k_in[0]), np.log10(k_in[-1]), bins)
    Pk = np.interp(np.log(k), np.log(k_in), Pk_in)

    bias = np.zeros(Masses.shape[0], dtype=np.float64)

    if author == "SMT01":
        a = 0.707
        b = 0.5
        c = 0.6

        for i in range(Masses.shape[0]):
            R = (3.0 * Masses[i] / (4.0 * pi * rhoM))**(1.0 / 3.0)
            anu = a * (deltac / MFL.sigma(k, Pk, R))**2

            bias[i] = np.sqrt(a) * anu + np.sqrt(a) * b * anu**(1.0 - c)
            bias[i] = bias[i] - anu**c / (anu**c + b * (1.0 - c) *
                                          (1.0 - 0.5 * c))
            bias[i] = 1.0 + bias[i] / (np.sqrt(a) * deltac)

    elif author == "Tinker":
        Delta = 200.0
        y = np.log10(Delta)

        A = 1.0 + 0.24 * y * np.exp(-(4.0 / y)**4)
        a = 0.44 * y - 0.88
        B = 0.183
        b = 1.5
        C = 0.019 + 0.107 * y + 0.19 * np.exp(-(4.0 / y)**4)
        c = 2.4

        for i in range(Masses.shape[0]):
            R = (3.0 * Masses[i] / (4.0 * pi * rhoM))**(1.0 / 3.0)
            nu = deltac / MFL.sigma(k, Pk, R)
            bias[i] = 1.0 - A * nu**a / (nu**a +
                                         deltac**a) + B * nu**b + C * nu**c

    return bias
def bias(k_in, Pk_in, OmegaM, Masses, author, bins=10000):

    rhoM = rho_crit*OmegaM

    # sort the input k-array
    indexes = np.argsort(k_in)
    k_in = k_in[indexes];  Pk_in = Pk_in[indexes]
    
    # interpolate the input k-array into bins points
    k  = np.logspace(np.log10(k_in[0]), np.log10(k_in[-1]), bins)
    Pk = np.interp(np.log(k), np.log(k_in), Pk_in)
    
    bias = np.zeros(Masses.shape[0], dtype=np.float64)

    if author=="SMT01":
        a = 0.707;  b = 0.5;  c = 0.6

        for i in xrange(Masses.shape[0]):
            R = (3.0*Masses[i]/(4.0*pi*rhoM))**(1.0/3.0)
            anu = a*(deltac/MFL.sigma(k,Pk,R))**2

            bias[i] = np.sqrt(a)*anu + np.sqrt(a)*b*anu**(1.0-c)
            bias[i] = bias[i] - anu**c/(anu**c + b*(1.0-c)*(1.0-0.5*c))
            bias[i] = 1.0+bias[i]/(np.sqrt(a)*deltac)        
    
    elif author=="Tinker":
        Delta=200.0;  y=np.log10(Delta)

        A=1.0+0.24*y*np.exp(-(4.0/y)**4);          a=0.44*y-0.88
        B=0.183;                                   b=1.5
        C=0.019+0.107*y+0.19*np.exp(-(4.0/y)**4);  c=2.4

        for i in xrange(Masses.shape[0]):
            R = (3.0*Masses[i]/(4.0*pi*rhoM))**(1.0/3.0)
            nu = deltac/MFL.sigma(k,Pk,R)
            bias[i] = 1.0-A*nu**a/(nu**a+deltac**a)+B*nu**b+C*nu**c

    return bias
Esempio n. 4
0
    def sigmaM(self):
        '''
        Mass variance at targed redshift, computed using pylians
        '''
        kh, P = self.Pm_for_HMF

        #mass vector for pylians
        Mvec = (ulogspace(self.Mmin.to(self.Msunh), self.Mmax.to(self.Msunh),
                          256)).to(self.Msunh)

        #pylians get sigma(R). Get R
        rho_crit = 2.77536627e11 * (self.Msunh * self.Mpch**-3).to(
            self.Msunh * self.Mpch**-3)  #h^2 Msun/Mpc^3
        rhoM = rho_crit * self.camb_pars.omegam
        R = (3.0 * Mvec / (4.0 * np.pi * rhoM))**(1.0 / 3.0)

        #Get sigma(M) from pylians
        sigma_vec = np.zeros(len(R))

        for ir in range(0, len(R)):
            sigma_vec[ir] = MFL.sigma(kh, P, R[ir].value)

        Mh = (self.M.to(self.Msunh)).value
        return log_interp1d(Mvec.value, sigma_vec)(Mh)
import argparse
import numpy as np
import mass_function_library as MFL

parser = argparse.ArgumentParser()
parser.add_argument("Pk_file", help="computes sigma_8 value from file")
args = parser.parse_args()

# read input file
k, Pk = np.loadtxt(args.Pk_file, unpack=True)

# compute value of sigma_8
s8 = MFL.sigma(k, Pk, 8.0)
print 'Value of sigma_8 = %.5e' % s8
import numpy as np
import sys, os
import units_library as UL
import mass_function_library as MFL

parser = argparse.ArgumentParser()
parser.add_argument("Pk_file", help="computes sigma_8 value from file")
parser.add_argument("Omega_cb", type=float, help="value of Omega_cb")
parser.add_argument("--Mmin", default=1e9, type=float, help="Mmin in Msun/h")
parser.add_argument("--Mmax", default=1e15, type=float, help="Mmax in Msun/h")
parser.add_argument("--bins", default=60, type=int, help="number of bins")
args = parser.parse_args()

# find values of rho_crit, delta_c, Mmin, Mmax and bins
rho_crit = (UL.units()).rho_crit  #h^2 Msun/Mpc^3
delta_c, Omega_cb = 1.686, args.Omega_cb
Mmin, Mmax, bins = args.Mmin, args.Mmax, args.bins
print 'Computing values of nu = delta_c/sigma(M)'
print 'for halos between Mmin = %.3e and Mmax = %.3e\n' % (args.Mmin,
                                                           args.Mmax)

# read input file, compute Mass and R arrays
k, Pk = np.loadtxt(args.Pk_file, unpack=True)
Mass = np.logspace(np.log10(Mmin), np.log10(Mmax), bins)
R = (3.0 * Mass / (4.0 * np.pi * rho_crit * Omega_cb))**(1.0 / 3.0)

print 'Mass [Msun/h]   nu = delta_c/sigma'
for i in xrange(bins):
    sigma = MFL.sigma(k, Pk, R[i])
    print '  %.3e         %.3f' % (Mass[i], delta_c / sigma)
Esempio n. 7
0
import argparse
import numpy as np
import sys,os
import units_library as UL
import mass_function_library as MFL

parser = argparse.ArgumentParser()
parser.add_argument("Pk_file", help="computes sigma_8 value from file")
parser.add_argument("Omega_cb", type=float, help="value of Omega_cb")
parser.add_argument("--Mmin", default=1e9,  type=float, help="Mmin in Msun/h")
parser.add_argument("--Mmax", default=1e15, type=float, help="Mmax in Msun/h")
parser.add_argument("--bins", default=60,   type=int, help="number of bins")
args = parser.parse_args()

# find values of rho_crit, delta_c, Mmin, Mmax and bins
rho_crit = (UL.units()).rho_crit #h^2 Msun/Mpc^3
delta_c, Omega_cb = 1.686, args.Omega_cb
Mmin, Mmax, bins = args.Mmin, args.Mmax, args.bins
print 'Computing values of nu = delta_c/sigma(M)'
print 'for halos between Mmin = %.3e and Mmax = %.3e\n'%(args.Mmin,args.Mmax)

# read input file, compute Mass and R arrays
k,Pk = np.loadtxt(args.Pk_file,unpack=True)
Mass = np.logspace(np.log10(Mmin), np.log10(Mmax), bins)
R    = (3.0*Mass/(4.0*np.pi*rho_crit*Omega_cb))**(1.0/3.0)

print 'Mass [Msun/h]   nu = delta_c/sigma'
for i in xrange(bins):
    sigma = MFL.sigma(k,Pk,R[i])
    print '  %.3e         %.3f'%(Mass[i],delta_c/sigma)