def init(chain_index=None): if args.cosmo_prior: Hp = Planck15.H0.to(u.km / u.s / u.Mpc).value * Planck15.efunc( true_params['z_p']) * (1 + 0.01 * randn()) Om = Planck15.Om0 * (1 + 0.01 * randn()) else: Hp = Planck15.H0.to(u.km / u.s / u.Mpc).value * Planck15.efunc( true_params['z_p']) * (1 + 0.1 * randn()) Om = Planck15.Om0 * (1 + 0.1 * randn()) w = -1 + 0.1 * randn() c = cosmo.FlatwCDM(Hp / Planck15.efunc(true_params['z_p']), Om, w) MMax_d_p = (45 + 5 * randn()) * (1 + cosmo.z_at_value( c.luminosity_distance, Planck15.luminosity_distance(true_params['z_p']).to(u.Gpc))) smooth_max = 0.1 + 0.01 * randn() MMax_d_p_2sigma = exp(log(MMax_d_p) + 2 * smooth_max) alpha = 0.7 + 0.1 * randn() beta = 0.1 * randn() gamma = 3 + 0.1 * randn() return { 'H_p': Hp, 'Om': Om, 'w0': w, 'MMax_d_p': MMax_d_p, 'MMax_d_p_2sigma': MMax_d_p_2sigma, 'alpha': alpha, 'beta': beta, 'gamma': gamma, 'xs': randn(nobs, 3) }
def cl_z(self, z=[], l=np.arange(2000) + 1, pk_params=None, cosmo=None, pk_func=None): if not pk_func: pk_func = self.class_pk nz = len(z) nl = len(l) pk, kh = pk_func(z=z, pk_params=pk_params) cls = np.zeros((nz, nl), dtype='float32') * u.Mpc**2 for i in np.arange(nz): DC_i = cosmo.angular_diameter_distance( z[i]).value #because camb k in h/mpc lz = kh * DC_i - 0.5 pk_int = interp1d(lz, pk[i] / DC_i**2, bounds_error=False, fill_value=0) cls[i][:] += pk_int(l) * u.Mpc * (c / (cosmo.efunc(z[i]) * cosmo.H0)) return cls
def sfr2_porciani_madau(z): ''' SFR2 from porciani madau 2001 http://stacks.iop.org/0004-637X/548/i=2/a=522 ''' return exp(3.4 * z) / (exp(3.4 * z) + 22.) * Planck15.efunc(z) / ( (1 + z)**(3 / 2.))
def dL_df(z): """ Comoving differential distance at redshift per frequency. [cMpc]/Hz, from Furlanetto et al. (2006) """ c_kms = c_ms / 1e3 # km/s return c_kms / (cosmo.H0.value * cosmo.efunc(z)) * (z + 1)**2 / f21
from read_db import *#pairs, profile_array, color, plot_profile, profilelist, norms from astropy.cosmology import Planck15 from astropy import constants Ez = Planck15.efunc(zs) Tmw = h.reverse_property_cascade('Tmw_tcut_profile')[0] #Convert T to keV Tmw *= constants.k_B.to('keV K**-1').value rho_e_vol = np.array([rho*units.g/(units.cm**3) for rho in h.reverse_property_cascade('rho_e_vol_profile')[0]]) rho_g_vol = m_p*rho_e_vol*mu_e #g/cm^3 def entropy(T, rho_e): return T/pow(rho_e, 2/3.) Kmw = np.array([entropy(Tmw[elt]*units.keV, rho_g_vol[elt]/(m_p*units.g)) for elt in range(len(Tmw))]) Pmw = np.array([Tmw[elt]*units.keV*rho_g_vol[elt]/(m_p*units.g) for elt in range(len(Tmw))]) def K500_McCarthy08(r500_ind, cummass_profile_ind): #self-similar scaling m500 = cummass_profile_ind[r500_ind] #check that this is in Msun fb = 0.16 return 2561 * pow(m500/1e15, 2./3) * pow(fb/.13, -2./3) #keV cm^2 K500 = np.array([K500_McCarthy08(r500_ind(ind), cummass_profile[ind]) for ind in range(len(cummass_profile))]) T500 = np.array([pow(ne_500[ind], 2./3)*K500[ind] for ind in range(len(K500))]) #keV P500 = ng_500*T500 cs = np.sqrt((T500s/(mu*constants.m_p)).to('kpc**2 yr**-2')) bh = h['BH_central'][0]
def eta_to_kpar_fac(z): return (2 * np.pi * Planck15.H0 * f21 * Planck15.efunc(z) / (cnst.c * (1 + z)**2)).to(1 / un.Mpc).value
def dL_df(z, omega_m=0.266): '''[Mpc]/Hz, from Furlanetto et al. (2006)''' c_kms = 299792.458 #km/s nu21 = 1420e6 return c_kms/(cosmo.H0.value * cosmo.efunc(z)) * (z+1)**2 / nu21
def dkpar_dkperp(z): """ Wedge line """ return (cosmo.H0.to("m/(s Mpc)").value * comoving_distance(z) * cosmo.efunc(z) / (c_ms * (1 + z)))