#~ #compute tinker stuff limM = [4.2e11,1e12,3e12,1e13, 5e15] loglim = [ 11.623, 12., 12.477, 13., 15.698] cname = 'Pk_cc_z='+str(z[j])+'00.txt' camb = np.loadtxt(cname) kcamb = camb[:,0] Pcamb = camb[:,1] massf = np. loadtxt('/home/david/codes/Paco/data2/0.15eV/hmf_z='+str(z[j])+'.txt') m_middle = massf[:,10] dm = massf[:,11] #### get tinker and crocce hmf bt=np.empty(len(m_middle),dtype=np.float64) for i in range(len(m_middle)): bt[i]=bias(kcamb,Pcamb,Omega_m,m_middle[i],'Tinker') dndM=MFL.Tinker_mass_function(kcamb,Pcamb,Omega_m,z[j],limM[0],limM[4],len(m_middle),Masses=m_middle)[1] with open('/home/david/codes/Paco/data2/other neutrinos masses/'+str(nv)+'/thmf_z='+str(z[j])+'.txt', 'w+') as fid_file: #~ with open('/home/david/codes/Paco/data2/other neutrinos masses/'+"%.3" % nv+'/thmf_z='+str(z[j])+'.txt', 'w+') as fid_file: for m in xrange(0, len(m_middle)): fid_file.write('%.8g\n' % (dndM[m])) fid_file.close() dndMbis=MFL.Crocce_mass_function(kcamb,Pcamb,Omega_m,z[j],limM[0],limM[4],len(m_middle),Masses=m_middle)[1] with open('/home/david/codes/Paco/data2/other neutrinos masses/'+str(nv)+'/chmf_z='+str(z[j])+'.txt', 'w+') as fid_file: #~ with open('/home/david/codes/Paco/data2/other neutrinos masses/'+"%.2" % nv+'/chmf_z='+str(z[j])+'.txt', 'w+') as fid_file: for m in xrange(0, len(m_middle)): fid_file.write('%.8g\n' % (dndMbis[m])) fid_file.close()
else: [k,Pk] = BL.DM_Pk(f_Pk_DM) #compute/read the halo mass function if not(os.path.exists(f_MF)): dndM = MFL.ST_mass_function(k,Pk,OmegaM,None,None,None,M)[1] np.savetxt(f_MF,np.transpose([M,dndM])) else: M_MF,dndM = np.loadtxt(f_MF,unpack=True) if np.any(M_MF!=M): print 'error!!\nbins in mass function are different'; sys.exit() #compute/read the halo bias if not(os.path.exists(f_bias)): b = np.empty(bins+1,dtype=np.float64) for i,mass in enumerate(M): b[i] = BL.bias(k,Pk,OmegaM,mass,'SMT01') np.savetxt(f_bias,np.transpose([M,b])) else: M_b,b = np.loadtxt(f_bias,unpack=True) if np.any(M_b!=M): print 'error!!\nbins in halo bias are different'; sys.exit() #compute the M_HI function M_HI = M_HI_model(M,z,h) #compute the bias of the HI numerator = integral1(M,dndM,b,M_HI) denominator = integral2(M,dndM,M_HI) if fix_Omega_HI: # Omega_HI = f3/rho_crit*\int_0^infty n(M)M_HI(M)dM
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 print 'compute the mass function for larger masses'; sys.exit() dndM=10**(np.interp(np.log10(M),np.log10(M_MF),np.log10(MF))); del M_MF,MF #compute the halo bias or read it from a file if compute_bias: bias=np.zeros(bins,dtype=np.float64) for i in xrange(bins): bias[i]=BL.bias(k,Pk,Omega_m,M[i],author='SMT01') #'ST01' 'Tinker' print 'M = %1.3e Msun/h ---> bias = %1.3f'%(M[i],bias[i]) np.savetxt(f_bias,np.transpose([M,bias])) else: M_b,b=np.loadtxt(f_bias,unpack=True) if Mmin<np.min(M_b): #check that the file explores the minimum mass print 'compute the bias for smaller masses'; sys.exit() if Mmax>np.max(M_b): #check that the file explores the maximum mass print 'compute the bias for larger masses'; sys.exit() bias=10**(np.interp(np.log10(M),np.log10(M_b),np.log10(b))); del M_b,b #compute the DLA cross section as a function of the dark matter halo mass cross_section=np.zeros(bins,dtype=np.float64) f=open(f_out_cross_section,'w') for i in xrange(bins): cross_section[i]=cross_section_model(M[i],redshift,model)
#compute/read the halo mass function if not (os.path.exists(f_MF)): dndM = MFL.ST_mass_function(k, Pk, OmegaM, None, None, None, M)[1] np.savetxt(f_MF, np.transpose([M, dndM])) else: M_MF, dndM = np.loadtxt(f_MF, unpack=True) if np.any(M_MF != M): print 'error!!\nbins in mass function are different' sys.exit() #compute/read the halo bias if not (os.path.exists(f_bias)): b = np.empty(bins + 1, dtype=np.float64) for i, mass in enumerate(M): b[i] = BL.bias(k, Pk, OmegaM, mass, 'SMT01') np.savetxt(f_bias, np.transpose([M, b])) else: M_b, b = np.loadtxt(f_bias, unpack=True) if np.any(M_b != M): print 'error!!\nbins in halo bias are different' sys.exit() #compute the M_HI function M_HI = M_HI_model(M, z, h) #compute the bias of the HI numerator = integral1(M, dndM, b, M_HI) denominator = integral2(M, dndM, M_HI) if fix_Omega_HI:
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 print 'compute the mass function for larger masses' sys.exit() dndM = 10**(np.interp(np.log10(M), np.log10(M_MF), np.log10(MF))) del M_MF, MF #compute the halo bias or read it from a file if compute_bias: bias = np.zeros(bins, dtype=np.float64) for i in xrange(bins): bias[i] = BL.bias(k, Pk, Omega_m, M[i], author='SMT01') #'ST01' 'Tinker' print '%e %f' % (M[i], bias[i]) np.savetxt(f_bias, np.transpose([M, bias])) else: M_b, b = np.loadtxt(f_bias, unpack=True) if Mmin < np.min(M_b): #check that the file explores the minimum mass print 'compute the bias for smaller masses' sys.exit() if Mmax > np.max(M_b): #check that the file explores the maximum mass print 'compute the bias for larger masses' sys.exit() bias = 10**(np.interp(np.log10(M), np.log10(M_b), np.log10(b))) del M_b, b #compute the DLA cross section as a function of the dark matter halo mass cross_section = np.zeros(bins, dtype=np.float64)
#M1,sigma_DLAs = np.loadtxt('DLAs_sigma_mean_z=%d.txt'%z, unpack=True) # interpolate HMF and DLAs cross-sections MF = np.interp(M,M_mean,MF,left=0,right=0) sigma_DLAs = np.interp(M,M_mean,sigma_DLAs,left=0,right=0) indexes = np.where((MF>0.0) & (sigma_DLAs>0.0))[0] MF = MF[indexes] sigma_DLAs = sigma_DLAs[indexes] M = M[indexes] Mmin = np.min(M) Mmax = np.max(M) # compute halo bias 'SMT01' b = BL.bias(k, Pk, Omega_m, M, 'SMT01', 10000) np.savetxt('bias_z=%d.txt'%z, np.transpose([M,b])) #sigma_DLAs = np.zeros(bins+1, dtype=np.float64) #if z==2: M0 = 10.22955643 #value of 10^20 #if z==3: M0 = 9.89018152 #value of 10^20 #for i in xrange(bins+1): # sigma_DLAs[i] = sigma_DLAs_func(M[i], M0, N_HI=10**20.0) # integral value, its limits and precision parameters eps = 1e-14 h1 = 1e-15 hmin = 0.0
bins_k = 10000 #number of bins to use in the input Pk # For neutrinos use Omega_{CDM+B} instead of Omega_m Omega_m = 0.3175 Mmin = 1e10 #Msun/h Mmax = 1e16 #Msun/h bins_MF = 300 #number of bins in the HMF author = 'SMT01' #'SMT01', 'Tinker' f_out = 'bias_SMT_z=0.txt' ################################################################################## # read input Pk k, Pk = np.loadtxt(f_in, unpack=True) # define the array with the masses where to evaluate the halo bias Masses = np.logspace(np.log10(Mmin), np.log10(Mmax), bins_MF) # compute halo bias b = BL.bias(k, Pk, Omega_m, Masses, author, bins_k) # save results to file np.savetxt(f_out, np.transpose([Masses, b])) # This computes the effective bias for halos in the range # [min(Masses), max(Masses)] z = 0.0 b_eff = BL.bias_eff(k, Pk, Omega_m, Masses, z, author)
limM[4], len(m_middle4), Masses=m_middle4)[1] hmf2 = MFL.Crocce_mass_function(kcamb2, Pcamb2, Omega_m, z[j], limM[3], limM[4], len(m_middle4), Masses=m_middle4)[1] bt1 = np.empty(len(m_middle4), dtype=np.float64) bt2 = np.empty(len(m_middle4), dtype=np.float64) for i in range(len(m_middle4)): bt1[i] = bias(kcamb1, Pcamb1, Omega_m, m_middle4[i], 'Tinker') bt2[i] = bias(kcamb2, Pcamb2, Omega_m, m_middle4[i], 'Tinker') Bias_eff_t1 = np.sum(hmf1 * dm4 * bt1) / np.sum(dm4 * hmf1) Bias_eff_t2 = np.sum(hmf2 * dm4 * bt2) / np.sum(dm4 * hmf2) #------------------------------------------------------------- ### massive case # neutrino parameters hierarchy = 'degenerate' #'degenerate', 'normal', 'inverted' Mnun = 0.15 #eV Nnun = 3 #number of massive neutrinos Neffn = 3.046 # cosmological parameters hn = 0.6711
bt4 = np.empty(len(m_middle4), dtype=np.float64) #~ bst1=np.empty(len(m_middle1),dtype=np.float64) #~ bst2=np.empty(len(m_middle2),dtype=np.float64) #~ bst3=np.empty(len(m_middle3),dtype=np.float64) #~ bst4=np.empty(len(m_middle4),dtype=np.float64) #~ bsmt1=np.empty(len(m_middle1),dtype=np.float64) #~ bsmt2=np.empty(len(m_middle2),dtype=np.float64) #~ bsmt3=np.empty(len(m_middle3),dtype=np.float64) #~ bsmt4=np.empty(len(m_middle4),dtype=np.float64) bm1 = np.empty(len(m_middle1), dtype=np.float64) bm2 = np.empty(len(m_middle2), dtype=np.float64) bm3 = np.empty(len(m_middle3), dtype=np.float64) bm4 = np.empty(len(m_middle4), dtype=np.float64) for i in range(len(m_middle1)): bt1[i] = bias(kcamb, Pcamb, Omega_m, m_middle1[i], 'Tinker') bt2[i] = bias(kcamb, Pcamb, Omega_m, m_middle2[i], 'Tinker') bt3[i] = bias(kcamb, Pcamb, Omega_m, m_middle3[i], 'Tinker') bt4[i] = bias(kcamb, Pcamb, Omega_m, m_middle4[i], 'Tinker') #~ #------------------------------------------- #~ bst1[i]=bias(kcamb,Pcamb,Omega_m,m_middle1[i],'Crocce') #~ bst2[i]=bias(kcamb,Pcamb,Omega_m,m_middle2[i],'Crocce') #~ bst3[i]=bias(kcamb,Pcamb,Omega_m,m_middle3[i],'Crocce') #~ bst4[i]=bias(kcamb,Pcamb,Omega_m,m_middle4[i],'Crocce') #~ #------------------------------------------ #~ bsmt1[i]=bias(kcamb,Pcamb,Omega_m,m_middle1[i],'SMT01') #~ bsmt2[i]=bias(kcamb,Pcamb,Omega_m,m_middle2[i],'SMT01') #~ bsmt3[i]=bias(kcamb,Pcamb,Omega_m,m_middle3[i],'SMT01') #~ bsmt4[i]=bias(kcamb,Pcamb,Omega_m,m_middle4[i],'SMT01') #----------------------------------------- bm1[i] = bias(kcamb, Pcamb, Omega_m, m_middle1[i], 'Mice')