Beispiel #1
0
    def test_cosmo_consistency(self):
        save_cosmo = astropy.cosmology.default_cosmology.get()
        m200 = 5e14
        c = 3.5
        z = 0.15
        # Halo 1 with variable cosmology
        nfw1 = NFW(m200, c, z)
        # Halo 2 with cosmology fixed to the current one
        nfw2 = NFW(m200, c, z, cosmology=save_cosmo)
        # Halo 3 with cosmology fixed to WMAP9
        wmap9 = astropy.cosmology.WMAP9
        nfw3 = NFW(m200, c, z, cosmology=wmap9)

        assert_almost_equal(
            nfw1.radius_Delta(200).value,
            nfw2.radius_Delta(200).value,
            err_msg="Disagreement after init with same cosmology",
        )
        astropy.cosmology.default_cosmology.set(wmap9)
        try:
            assert_almost_equal(
                nfw1.radius_Delta(200).value,
                nfw3.radius_Delta(200).value,
                err_msg="Disagreement after changing cosmology",
            )
        except:
            astropy.cosmology.default_cosmology.set(save_cosmo)
            raise
        astropy.cosmology.default_cosmology.set(save_cosmo)
Beispiel #2
0
 def test_mass_unit_consistency(self):
     m200 = 5e14
     c = 3
     z = 0.4
     nfw1 = NFW(m200, c, z)
     nfw2 = NFW(m200 * u.solMass, c, z)
     assert_almost_equal(nfw1.radius_Delta(200), nfw2.radius_Delta(200))
Beispiel #3
0
 def test_mass_unit_consistency(self):
     m200 = 5e14
     c = 3
     z = 0.4
     nfw1 = NFW(m200, c, z)
     nfw2 = NFW(m200 * u.solMass, c, z)
     r1 = nfw1.radius_Delta(200)
     r2 = nfw2.radius_Delta(200)
     r1 = u.Quantity(r1, r2.unit)
     assert_almost_equal(r1.value, r2.value)
Beispiel #4
0
 def test_radius_Delta(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     r200 = nfw.radius_Delta(200)
     assert_almost_equal(r200.value, 1.8624221298548365)
     r500 = nfw.radius_Delta(500)
     assert_almost_equal(r500.value, 1.231119031798481)
     r2500 = nfw.radius_Delta(2500)
     assert_almost_equal(r2500.value, 0.5520242539181)
Beispiel #5
0
 def test_concentration(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     c500 = nfw.radius_Delta(500) / nfw.r_s
     assert_almost_equal(c500, [3.3051557218506047])
Beispiel #6
0
 def test_radius_mass_consistency(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     r200 = nfw.radius_Delta(200)
     nfw2 = NFW(r200, c, z, size_type="radius")
     assert_almost_equal(nfw2.mass_Delta(200).value / 1e14, m200 / 1e14)
Beispiel #7
0
 def test_mass_consistency(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     m500 = nfw.mass_Delta(500)
     c500 = nfw.radius_Delta(500) / nfw.r_s
     nfw2 = NFW(m500, c500, z, overdensity=500)
     assert_almost_equal(nfw2.mass_Delta(200).value / 1e14, m200 / 1e14)
Beispiel #8
0
 def test_var_cosmo_obj(self):
     wmap9 = astropy.cosmology.WMAP9
     save_cosmo = astropy.cosmology.default_cosmology.get()
     m200 = 5e14
     c = 3.5
     z = 0.15
     nfw = NFW(m200, c, z)
     assert nfw.cosmology is save_cosmo
     astropy.cosmology.default_cosmology.set(wmap9)
     try:
         assert nfw.cosmology is wmap9
     except:
         astropy.cosmology.default_cosmology.set(save_cosmo)
         raise
     # Ensure that accessing the cosmology property also updates
     # the other properties.
     assert_almost_equal(nfw.radius_Delta(325).value, 1.2525923457595705)
     astropy.cosmology.default_cosmology.set(save_cosmo)
Beispiel #9
0
 def test_mass_init_bckg(self):
     m200 = 1e15
     c = 5
     z = 0.2
     nfw = NFW(m200, c, z, overdensity_type="mean")
     assert_almost_equal(nfw.radius_Delta(200).value, 3.708806727880765)