def bias_eff(k, Pk, OmegaM, z, M1, M2, author, bins=100): M = np.logspace(np.log10(M1), np.log10(M2), bins + 1) #bins in mass M_middle = 10**(0.5 * (np.log10(M[1:]) + np.log10(M[:-1])) ) #center of the bin deltaM = M[1:] - M[:-1] #size of the bin if author == 'SMT01': dndM = MFL.ST_mass_function(k, Pk, OmegaM, None, None, None, M_middle)[1] if author == 'Tinker': dndM = MFL.Tinker_mass_function(k, Pk, OmegaM, z, None, None, None, M_middle)[1] b = np.empty(bins, dtype=np.float64) for i in range(bins): b[i] = bias(k, Pk, OmegaM, M_middle[i], author) bias_eff = np.sum(dndM * deltaM * b) / np.sum(dndM * deltaM) return bias_eff
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() dndM = np.loadtxt('/home/david/codes/Paco/data2/other neutrinos masses/'+str(nv)+'/thmf_z='+str(z[j])+'.txt') dndMbis = np.loadtxt('/home/david/codes/Paco/data2/other neutrinos masses/'+str(nv)+'/chmf_z='+str(z[j])+'.txt')