def test_age(): """Test integrated age against analytical age.""" z = numpy.arange(0, 10.0, 0.05) cosmo = {} cosmo['omega_M_0'] = numpy.array([[0.99],[0.01],[0.3]]) cosmo['omega_lambda_0'] = 1. - cosmo['omega_M_0'] cosmo['h'] = 0.7 cd.set_omega_k_0(cosmo) linestyle = ['-', ':', '--'] gyr = 1e9 * cc.yr_s tl = cd.lookback_time(z, **cosmo) age = cd.age(z, **cosmo) age_ana = cd.age_flat(z, **cosmo) pylab.figure(figsize=(6,6)) for i in range(len(linestyle)): pylab.plot(z, (tl/gyr)[i], ls=linestyle[i], color='0.5') pylab.plot(z, (age/gyr)[i], ls=linestyle[i], color='r') pylab.plot(z, (age_ana/gyr)[i], ls=linestyle[i], color='k') pylab.xlabel("redshift z") pylab.ylabel(r"age $t_L/$Gyr") pylab.figure(figsize=(6,6)) for i in range(len(linestyle)): pylab.plot(z, ((age - age_ana)/age_ana)[i], ls=linestyle[i], color='k') # Make sure errors are small: ntest.assert_array_less((numpy.abs((age - age_ana)/age_ana)[i]), 3e-13) pylab.xlabel("redshift z") pylab.ylabel(r"age: (integral - analytical)/analytical")
def lb_time(z, **cosmo): z = np.atleast_1d(z) if cosmo == {}: cosmo_in = { 'omega_M_0': 0.3, 'omega_lambda_0': 0.7, 'omega_k_0': 0.0, 'h': 0.70 } else: cosmo_in = cosmo results = cd.lookback_time(z, **cosmo_in) / 60. / 60. / 24. / 365. / 1.e9 return results
def test_figure6(): """Plot Hogg fig. 6: The dimensionless lookback time t_L/t_H and age t/t_H. The three curves are for the three world models, - Einstein-de Sitter (omega_M, omega_lambda) = (1, 0) [solid] : Low-density (0.05, 0) [dotted] -- High lambda, (0.2, 0.8) [dashed] Hubble distance DH = c / H0 z from 0--5 t/th from 0--1.2 """ z = numpy.arange(0, 5.05, 0.05) cosmo = {} cosmo['omega_M_0'] = numpy.array([[1.0], [0.05], [0.2]]) cosmo['omega_lambda_0'] = numpy.array([[0.0], [0.0], [0.8]]) cosmo['h'] = 0.5 cd.set_omega_k_0(cosmo) linestyle = ['-', ':', '--'] th = 1 / cd.hubble_z(0, **cosmo) tl = cd.lookback_time(z, **cosmo) age = cd.age(z, **cosmo) pylab.figure(figsize=(6, 6)) for i in range(len(linestyle)): pylab.plot(z, (tl / th)[i], ls=linestyle[i]) pylab.plot(z, (age / th)[i], ls=linestyle[i]) pylab.xlim(0, 5) pylab.ylim(0, 1.2) pylab.xlabel("redshift z") pylab.ylabel(r"lookback timne $t_L/t_H$") pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') + " (astro-ph/9905116v4)")
def test_figure6(): """Plot Hogg fig. 6: The dimensionless lookback time t_L/t_H and age t/t_H. The three curves are for the three world models, - Einstein-de Sitter (omega_M, omega_lambda) = (1, 0) [solid] : Low-density (0.05, 0) [dotted] -- High lambda, (0.2, 0.8) [dashed] Hubble distance DH = c / H0 z from 0--5 t/th from 0--1.2 """ z = numpy.arange(0, 5.05, 0.05) cosmo = {} cosmo['omega_M_0'] = numpy.array([[1.0],[0.05],[0.2]]) cosmo['omega_lambda_0'] = numpy.array([[0.0],[0.0],[0.8]]) cosmo['h'] = 0.5 cd.set_omega_k_0(cosmo) linestyle = ['-', ':', '--'] th = 1/ cd.hubble_z(0, **cosmo) tl = cd.lookback_time(z, **cosmo) age = cd.age(z, **cosmo) pylab.figure(figsize=(6,6)) for i in range(len(linestyle)): pylab.plot(z, (tl/th)[i], ls=linestyle[i]) pylab.plot(z, (age/th)[i], ls=linestyle[i]) pylab.xlim(0,5) pylab.ylim(0,1.2) pylab.xlabel("redshift z") pylab.ylabel(r"lookback timne $t_L/t_H$") pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') + " (astro-ph/9905116v4)")
def test_age(): """Test integrated age against analytical age.""" z = numpy.arange(0, 10.0, 0.05) cosmo = {} cosmo['omega_M_0'] = numpy.array([[0.99], [0.01], [0.3]]) cosmo['omega_lambda_0'] = 1. - cosmo['omega_M_0'] cosmo['h'] = 0.7 cd.set_omega_k_0(cosmo) linestyle = ['-', ':', '--'] gyr = 1e9 * cc.yr_s tl = cd.lookback_time(z, **cosmo) age = cd.age(z, **cosmo) age_ana = cd.age_flat(z, **cosmo) pylab.figure(figsize=(6, 6)) for i in range(len(linestyle)): pylab.plot(z, (tl / gyr)[i], ls=linestyle[i], color='0.5') pylab.plot(z, (age / gyr)[i], ls=linestyle[i], color='r') pylab.plot(z, (age_ana / gyr)[i], ls=linestyle[i], color='k') pylab.xlabel("redshift z") pylab.ylabel(r"age $t_L/$Gyr") pylab.figure(figsize=(6, 6)) for i in range(len(linestyle)): pylab.plot(z, ((age - age_ana) / age_ana)[i], ls=linestyle[i], color='k') # Make sure errors are small: ntest.assert_array_less((numpy.abs((age - age_ana) / age_ana)[i]), 3e-13) pylab.xlabel("redshift z") pylab.ylabel(r"age: (integral - analytical)/analytical")
dm = cd.comoving_distance_transverse(z[i], **Cosmology) #See equation 16 of David Hogg's arXiv:astro-ph/9905116v4 da = cd.angular_diameter_distance(z[i], **Cosmology) #See equations 18-19 of David Hogg's arXiv:astro-ph/9905116v4 dl = cd.luminosity_distance(z[i], **Cosmology) #Units are Mpc dVc = cd.diff_comoving_volume(z[i], **Cosmology) #The differential comoving volume element dV_c/dz/dSolidAngle. #Dimensions are volume per unit redshift per unit solid angle. #Units are Mpc**3 Steradians^-1. #See David Hogg's arXiv:astro-ph/9905116v4, equation 28 tl = cd.lookback_time(z[i], **Cosmology) #See equation 30 of David Hogg's arXiv:astro-ph/9905116v4. Units are s. agetl = cd.age(z[i], **Cosmology) #Age at z is lookback time at z'->Infinity minus lookback time at z. tH = 3.09e17 / Cosmology['h'] ez = cd.e_z(z[i], **Cosmology) #The unitless Hubble expansion rate at redshift z. #In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is #equivalent to E(z), defined in his eq. 14. if PlotNumber == 1: val[i] = dm / dh xtitle = "redshift z"
cosmo = { 'omega_M_0': omegaM, 'omega_lambda_0': omegaL, 'omega_k_0': 0., 'h': h } Nz = 1001 z_grid = np.linspace(0., 5., Nz) logt_grid = 0. * z_grid rhoc_grid = 0. * z_grid for i in range(0, Nz): logt_grid[i] = np.log10( distance.lookback_time(z_grid[i], 0., **cosmo) / yr) - 9. rhoc_grid[i] = density.cosmo_densities(**cosmo)[0] * distance.e_z( z_grid[i], **cosmo) * M_Sun / Mpc**3 z_spline = splrep(logt_grid[1:], z_grid[1:]) logt_spline = splrep(z_grid[1:], logt_grid[1:]) rhoc_spline = splrep(z_grid[1:], rhoc_grid[1:]) def z_form_vdisp_func(lvdisp): return splev(0.46 + 0.238 * lvdisp, z_spline) def z_form_mstar_func(lmstar): return splev(0.427 + 0.053 * lmstar, z_spline)
dm = cd.comoving_distance_transverse(z[i],**Cosmology) #See equation 16 of David Hogg's arXiv:astro-ph/9905116v4 da = cd.angular_diameter_distance(z[i],**Cosmology) #See equations 18-19 of David Hogg's arXiv:astro-ph/9905116v4 dl = cd.luminosity_distance(z[i],**Cosmology) #Units are Mpc dVc = cd.diff_comoving_volume(z[i], **Cosmology) #The differential comoving volume element dV_c/dz/dSolidAngle. #Dimensions are volume per unit redshift per unit solid angle. #Units are Mpc**3 Steradians^-1. #See David Hogg's arXiv:astro-ph/9905116v4, equation 28 tl = cd.lookback_time(z[i],**Cosmology) #See equation 30 of David Hogg's arXiv:astro-ph/9905116v4. Units are s. agetl = cd.age(z[i],**Cosmology) #Age at z is lookback time at z'->Infinity minus lookback time at z. tH = 3.09e17/Cosmology['h'] ez = cd.e_z(z[i],**Cosmology) #The unitless Hubble expansion rate at redshift z. #In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is #equivalent to E(z), defined in his eq. 14. if PlotNumber == 1: val[i] = dm/dh xtitle = "redshift z"