Example #1
0
def plot_DM(filename):
    """The dimensionless proper motion distance DM/DH. 
    """

    # Set up an array of redshift values.
    dz = 0.1
    z = numpy.arange(0., 10. + 1.1 * dz, dz)

    # Set up a cosmology dictionary, with an array of matter density values.
    cosmo = {}
    dom = 0.01
    om = numpy.atleast_2d(numpy.linspace(0.1, 1.0,
                                         (1. - 0.1) / dom)).transpose()
    cosmo['omega_M_0'] = om
    cosmo['omega_lambda_0'] = 1. - cosmo['omega_M_0']
    cosmo['h'] = 0.701
    cosmo['omega_k_0'] = 0.0

    # Calculate the hubble distance.
    dh = cd.hubble_distance_z(0, **cosmo)
    # Calculate the comoving distance.
    dm = cd.comoving_distance_transverse(z, **cosmo)

    # Make plots.
    plot_dist(z, dz, om, dom, dm, dh, 'proper motion distance', r'D_M',
              filename)
    plot_dist_ony(z, dz, om, dom, dm, dh, 'proper motion distance', r'D_M',
                  filename)
Example #2
0
def plot_DA(filename):
    """The dimensionless angular diameter distance DA/DH. 
    """

    # Set up an array of redshift values.
    dz = 0.1
    z = numpy.arange(0., 10. + dz, dz)

    # Set up a cosmology dictionary, with an array of matter density values.
    cosmo = {}
    dom = 0.01
    om = numpy.atleast_2d(numpy.linspace(0.1, 1.0,
                                         (1. - 0.1) / dom)).transpose()
    cosmo['omega_M_0'] = om
    cosmo['omega_lambda_0'] = 1. - cosmo['omega_M_0']
    cosmo['h'] = 0.701
    cosmo['omega_k_0'] = 0.0

    # Calculate the hubble distance.
    dh = cd.hubble_distance_z(0, **cosmo)
    # Calculate the angular diameter distance.
    da = cd.angular_diameter_distance(z, **cosmo)

    # Make plots.
    plot_dist(z, dz, om, dom, da, dh, 'angular diameter distance', r'D_A',
              filename)
    plot_dist_ony(z, dz, om, dom, da, dh, 'angular diameter distance', r'D_A',
                  filename)
Example #3
0
def plot_DM(filename):
    """
    The dimensionless proper motion distance DM/DH.
    """
    # Set up an array of redshift values.
    dz = 0.1
    z = numpy.arange(0., 10. + 1.1 * dz, dz)

    # Set up a cosmology dictionary, with an array of matter density values.
    cosmo = {}
    dom = 0.01
    om = numpy.atleast_2d(numpy.linspace(0.1, 1.0, (1. - 0.1) / dom)).transpose()
    cosmo['omega_M_0'] = om
    cosmo['omega_lambda_0'] = 1. - cosmo['omega_M_0']
    cosmo['h'] = 0.701
    cosmo['omega_k_0'] = 0.0

    # Calculate the hubble distance.
    dh = cd.hubble_distance_z(0, **cosmo)
    # Calculate the comoving distance.
    dm, dm_err = cd.comoving_distance_transverse(z, **cosmo)

    # Make plots.
    plot_dist(z, dz, om, dom, dm, dh, 'proper motion distance', r'D_M',
              filename)
    plot_dist_ony(z, dz, om, dom, dm, dh, 'proper motion distance', r'D_M',
                  filename)
Example #4
0
def plot_DA(filename):
    """
    The dimensionless angular diameter distance DA/DH.
    """
    # Set up an array of redshift values.
    dz = 0.1
    z = numpy.arange(0., 10. + dz, dz)

    # Set up a cosmology dictionary, with an array of matter density values.
    cosmo = {}
    dom = 0.01
    om = numpy.atleast_2d(numpy.linspace(0.1, 1.0, (1. - 0.1) / dom)).transpose()
    cosmo['omega_M_0'] = om
    cosmo['omega_lambda_0'] = 1. - cosmo['omega_M_0']
    cosmo['h'] = 0.701
    cosmo['omega_k_0'] = 0.0

    # Calculate the hubble distance.
    dh = cd.hubble_distance_z(0, **cosmo)
    # Calculate the angular diameter distance.
    da, da_err1, da_err2 = cd.angular_diameter_distance(z, **cosmo)

    # Make plots.
    plot_dist(z, dz, om, dom, da, dh, 'angular diameter distance', r'D_A',
              filename)
    plot_dist_ony(z, dz, om, dom, da, dh, 'angular diameter distance', r'D_A',
                  filename)
def Hz_cosmo(z):
	cosmo = {'omega_M_0' : 0.24, 'omega_lambda_0' : 0.76, 'h' : 0.73}
	cosmo = cd.set_omega_k_0(cosmo)
	'''___________Hz___________________________'''
	H_z = cd.hubble_distance_z(z, **cosmo)
	#print z,  H_z
	#print 0,  cd.hubble_distance_z(0, **cosmo)
	return H_z
Example #6
0
def testCosmo():
	'''

	'''

	import cosmolopy.distance as cosmology

	### Constants
	z = 2.4

	### Magneville:
	# omegaM = 0.267804
	# omegaL = 0.73
	# omegaK = 0.002117
	# h      = 0.71

	### Fiduciel BAOFIT
	# omegaM = 0.27
	# omegaL = 0.73
	# omegaK = 0
	# h      = 0.7
	# rd = 149.7

	
	cosmoCMV = {'omega_M_0':0.267804, 'omega_lambda_0':0.73, 'omega_k_0':0.002117, 'h':0.71}
	cosmoFID = {'omega_M_0':0.27, 'omega_lambda_0':0.73, 'omega_k_0':0, 'h':0.70}
	
	DAZ_CMV = cosmology.angular_diameter_distance(z,**cosmoCMV)
	HZ_CMV  = cosmology.hubble_distance_z(z,**cosmoCMV) #cosmology.hubble_z(z,**cosmoCMV)*3.085677581e22/1.e3

	DAZ_FID = cosmology.angular_diameter_distance(z,**cosmoFID)
	HZ_FID  = cosmology.hubble_distance_z(z,**cosmoFID) #cosmology.hubble_z(z,**cosmoFID)*3.085677581e22/1.e3

	print DAZ_CMV, DAZ_FID
	print HZ_CMV, HZ_FID

	print DAZ_FID/DAZ_CMV
	print HZ_FID/HZ_CMV

	return
def err_Dv(z):
	'''___________DA__________________________'''
	cosmo = {'omega_M_0' : 0.24, 'omega_lambda_0' : 0.76, 'h' : 0.73}
	cosmo = cd.set_omega_k_0(cosmo)
	d_a = cd.angular_diameter_distance(z, **cosmo)
	'''___________Hz___________________________'''
	H_z = cd.hubble_distance_z(z, **cosmo)
	'''________________The error on Dv___________________'''
	part1 = ( dasigma/ d_a ) **2 
	part2 = (Hsigma/ H_z)**2
	part3 = 0.0 #(cov_DaH/ (d_a* H_z))
	sigma_Dv = sqrt(Dv(Z)**2 * (part1 + part2 + part3 ))
	return  sigma_Dv
Example #8
0
def getMeanMag(z, dz=1e-4):
    #return 0.1311
    cosmo = {'omega_M_0': 0.3086, 'omega_lambda_0': 0.6914, 'h': 0.6777}
    cosmo = dist.set_omega_k_0(cosmo)
    distanceEB = 0
    distanceFB = 0
    for i in np.arange(0., z, dz):
        dist_hz = dist.hubble_distance_z(i, **cosmo)

        distanceEB += dz * dist_hz / (1 + i)**2

        distanceFB += dz * dist_hz

    distanceFB /= 1. + z

    return (distanceEB / distanceFB)**2 - 1.
Example #9
0
def test_figure2():
    """Plot Hogg fig. 2: The dimensionless angular diameter distance DA/DH.

    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
    DA / DH from 0--0.5

    """

    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)
    da = cd.angular_diameter_distance(z, **cosmo)

    # Also test the pathway with non-zero z0
    da2 = cd.angular_diameter_distance(z, z0=1e-8, **cosmo)

    pylab.figure(figsize=(6, 6))
    for i in range(len(linestyle)):
        pylab.plot(z, (da / dh)[i], ls=linestyle[i])
        pylab.plot(z, (da2 / dh)[i], ls=linestyle[i])
    pylab.xlim(0, 5)
    pylab.ylim(0, 0.5)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"angular diameter distance $D_A/D_H$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') +
                " (astro-ph/9905116v4)")
def test_figure2():
    """Plot Hogg fig. 2: The dimensionless angular diameter distance DA/DH.

    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
    DA / DH from 0--0.5

    """

    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)
    da = cd.angular_diameter_distance(z, **cosmo)

    # Also test the pathway with non-zero z0
    da2 = cd.angular_diameter_distance(z, z0=1e-8, **cosmo)

    pylab.figure(figsize=(6,6))
    for i in range(len(linestyle)):
        pylab.plot(z, (da/dh)[i], ls=linestyle[i])
        pylab.plot(z, (da2/dh)[i], ls=linestyle[i])
    pylab.xlim(0,5)
    pylab.ylim(0,0.5)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"angular diameter distance $D_A/D_H$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') + 
                " (astro-ph/9905116v4)")
Example #11
0
def test_figure5():
    """Plot Hogg fig. 5: The dimensionless comoving volume element (1/DH)^3(dVC/dz).

    The three curves are for the three world models, (omega_M, omega_lambda) =
    (1, 0), solid; (0.05, 0), dotted; and (0.2, 0.8), dashed.

    """
    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)

    dVc = cd.diff_comoving_volume(z, **cosmo)
    dVc_normed = dVc / (dh**3.)

    Vc = cd.comoving_volume(z, **cosmo)
    dz = z[1:] - z[:-1]
    dVc_numerical = (Vc[:, 1:] - Vc[:, :-1]) / dz / (4. * numpy.pi)
    dVc_numerical_normed = dVc_numerical / (dh**3.)

    pylab.figure(figsize=(6, 6))
    for i in range(len(linestyle)):
        pylab.plot(z, dVc_normed[i], ls=linestyle[i], lw=2.)
        pylab.plot(z[:-1],
                   dVc_numerical_normed[i],
                   ls=linestyle[i],
                   c='k',
                   alpha=0.1)
    pylab.xlim(0, 5)
    pylab.ylim(0, 1.1)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"comoving volume element $[1/D_H^3]$ $dV_c/dz/d\Omega$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') +
                " (astro-ph/9905116v4)")
Example #12
0
def test_figure3():
    """Plot Hogg fig. 3: The dimensionless luminosity distance DL/DH

    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
    DL / DH from 0--16

    """

    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)
    dl = cd.luminosity_distance(z, **cosmo)

    pylab.figure(figsize=(6, 6))
    for i in range(len(linestyle)):
        pylab.plot(z, (dl / dh)[i], ls=linestyle[i])
    pylab.xlim(0, 5)
    pylab.ylim(0, 16)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"luminosity distance $D_L/D_H$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') +
                " (astro-ph/9905116v4)")
def test_figure3():
    """Plot Hogg fig. 3: The dimensionless luminosity distance DL/DH

    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
    DL / DH from 0--16

    """

    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)
    dl = cd.luminosity_distance(z, **cosmo)

    pylab.figure(figsize=(6,6))
    for i in range(len(linestyle)):
        pylab.plot(z, (dl/dh)[i], ls=linestyle[i])
    pylab.xlim(0,5)
    pylab.ylim(0,16)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"luminosity distance $D_L/D_H$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') + 
                " (astro-ph/9905116v4)")
def test_figure5():
    """Plot Hogg fig. 5: The dimensionless comoving volume element (1/DH)^3(dVC/dz).

    The three curves are for the three world models, (omega_M, omega_lambda) =
    (1, 0), solid; (0.05, 0), dotted; and (0.2, 0.8), dashed.

    """
    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)

    dVc = cd.diff_comoving_volume(z, **cosmo)
    dVc_normed = dVc/(dh**3.)

    Vc = cd.comoving_volume(z, **cosmo)
    dz = z[1:] - z[:-1]
    dVc_numerical = (Vc[:,1:] - Vc[:,:-1])/dz/(4. * numpy.pi)
    dVc_numerical_normed = dVc_numerical/(dh**3.)

    pylab.figure(figsize=(6,6))
    for i in range(len(linestyle)):
        pylab.plot(z, dVc_normed[i], ls=linestyle[i], lw=2.)
        pylab.plot(z[:-1], dVc_numerical_normed[i], ls=linestyle[i], 
                   c='k', alpha=0.1)
    pylab.xlim(0,5)
    pylab.ylim(0,1.1)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"comoving volume element $[1/D_H^3]$ $dV_c/dz/d\Omega$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') + 
                " (astro-ph/9905116v4)")
Example #15
0
def test_figure1():
    """Plot Hogg fig. 1: The dimensionless proper motion distance DM/DH. 

    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; and high lambda, (0.2, 0.8), dashed.

    Hubble distance DH = c / H0

    z from 0--5
    DM / DH from 0--3

    """

    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)
    dm = cd.comoving_distance_transverse(z, **cosmo)

    pylab.figure(figsize=(6, 6))
    for i in range(len(linestyle)):
        pylab.plot(z, (dm / dh)[i], ls=linestyle[i])
        #pylab.plot(z, (dm_err/dh)[i], ls=linestyle[i])
    pylab.xlim(0, 5)
    pylab.ylim(0, 3)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"proper motion distance $D_M/D_H$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') +
                " (astro-ph/9905116v4)")
def test_figure1():
    """Plot Hogg fig. 1: The dimensionless proper motion distance DM/DH. 

    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; and high lambda, (0.2, 0.8), dashed.

    Hubble distance DH = c / H0

    z from 0--5
    DM / DH from 0--3

    """

    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 = ['-', ':', '--']

    dh = cd.hubble_distance_z(0, **cosmo)
    dm = cd.comoving_distance_transverse(z, **cosmo)

    pylab.figure(figsize=(6,6))    
    for i in range(len(linestyle)):
        pylab.plot(z, (dm/dh)[i], ls=linestyle[i])
        #pylab.plot(z, (dm_err/dh)[i], ls=linestyle[i])
    pylab.xlim(0,5)
    pylab.ylim(0,3)
    pylab.xlabel("redshift z")
    pylab.ylabel(r"proper motion distance $D_M/D_H$")
    pylab.title("compare to " + inspect.stack()[0][3].replace('test_', '') + 
                " (astro-ph/9905116v4)")
def H(z):
	cosmo = {'omega_M_0' : 0.24, 'omega_lambda_0' : 1. - 0.24-0.0418, 'h' : 0.73}
	return  cd.hubble_distance_z(z, **cosmo) 
PlotNumber = 8


N=200



z=numpy.arange(0.001,5,1./N)


val = numpy.zeros(len(z))

for i in xrange(len(z)):
    #Hubble Distance
    dh = cd.hubble_distance_z(z[i],**Cosmology)*cd.e_z(z[i],**Cosmology)
    #In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is equivalent to D_H / E(z) = c / (H_0 E(z)) [see his eq. 14], which
        #appears in the definitions of many other distance measures.
    
    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.
Example #19
0
    'omega_lambda_0': 1 - 0.2,
    'omega_k_0': 0.0,
    'h': 0.71
}

PlotNumber = 8

N = 200

z = numpy.arange(0.001, 5, 1. / N)

val = numpy.zeros(len(z))

for i in xrange(len(z)):
    #Hubble Distance
    dh = cd.hubble_distance_z(z[i], **Cosmology) * cd.e_z(z[i], **Cosmology)
    #In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is equivalent to D_H / E(z) = c / (H_0 E(z)) [see his eq. 14], which
    #appears in the definitions of many other distance measures.

    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.
def H(z):
	return  cd.hubble_distance_z(z, **cosmo)