コード例 #1
0
        print 'file does not exists!!!'

else:
    M_min = 1e10  #Msun/h
    M_max = 1e16  #Msun/h
    bins = 50

    z = 0.0
    f_Pk_DM = './CAMB_TABLES/ics_matterpow_0.dat'
    f_transfer = './CAMB_TABLES/ics_transfer_0.dat'

    do_CDM = False  #whether use the matter or only CDM power spectrum
    Omega_CDM = 0.2685  #set the values for do_CDM = True or do_CDM = False
    Omega_B = 0.0490  #set the values for do_CDM = True or do_CDM = False

    f_out = 'Crocce_MF_z=0.dat'
##############################################################################
OmegaM = Omega_CDM + Omega_B
M = np.logspace(np.log10(M_min), np.log10(M_max), bins + 1)

if do_CDM: [k, Pk] = BL.CDM_Pk(f_Pk_DM, f_transfer, Omega_CDM, Omega_B)
else: [k, Pk] = BL.DM_Pk(f_Pk_DM)

#dndM = MFL.ST_mass_function(k,Pk,OmegaM,None,None,None,M)[1]
#dndM = MFL.Tinker_mass_function(k,Pk,OmegaM,None,None,None,M)[1]
dndM = MFL.Crocce_mass_function(k, Pk, OmegaM, z, None, None, None, M)[1]
#dndM = MFL.Jenkins_mass_function(k,Pk,OmegaM,None,None,None,M)[1]
#dndM = MFL.Warren_mass_function(k,Pk,OmegaM,None,None,None,M)[1]

np.savetxt(f_out, np.transpose([M, dndM]))
Masses=head.massarr*1e10 #Msun/h
Omega_m=head.omega_m
Omega_l=head.omega_l
redshift=head.redshift
Hubble=100.0*np.sqrt(Omega_m*(1.0+redshift)**3+Omega_l)  #h*km/s/Mpc
h=head.hubble

#compute the value of Omega_b
Omega_cdm=Nall[1]*Masses[1]/BoxSize**3/rho_crit
Omega_b=Omega_m-Omega_cdm
print 'Omega_cdm =',Omega_cdm; print 'Omega_b   =',Omega_b
print 'Omega_m   =',Omega_m,'\n'
"""

#read the CAMB power spectrum file
[k, Pk] = BL.DM_Pk(f_Pk)

#select the masses of the dark matter halos over which the quantities will be
#computed (bias, mass function and cross_section)
M = np.logspace(np.log10(Mmin), np.log10(Mmax), bins)

#compute the halo mass function or read it from a file
if compute_MF:
    dndM = MFL.ST_mass_function(k, Pk, Omega_m, None, None, None, M)[1]
    np.savetxt(f_MF, np.transpose([M, dndM]))
else:
    M_MF, MF = np.loadtxt(f_MF, unpack=True)
    if Mmin < np.min(M_MF):  #check that the file explores the minimum mass
        print 'compute the mass function for smaller masses'
        sys.exit()
    if Mmax > np.max(M_MF):  #check that the file explores the maximum mass