예제 #1
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_mess(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     m = nfw.mass(1.32)
     assert_almost_equal(m.value / 1e14, 7.656709240756399)
예제 #2
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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])
예제 #3
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_sigma(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     s = nfw.sigma(1.12)
     assert_almost_equal(s.value / 1e13, 8.418908648577666)
예제 #4
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_density(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     rho = nfw.density(1.23)
     assert_almost_equal(rho.value / 1e13, 2.628686177054833)
예제 #5
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_mean_density(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     rho = nfw.mean_density(1.23)
     assert_almost_equal(rho.value / 1e13, 9.256897197704966)
예제 #6
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_mass_Delta(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     m500 = nfw.mass_Delta(500)
     assert_almost_equal(m500.value / 1e14, 7.221140, 6)
예제 #7
0
 def _mdelta_to_mdelta_via_m200(self, m_in, func, overdensity_in,
                                overdensity_out, z):
     m200 = mass_concentration.mdelta_to_m200(m_in, func, overdensity_in,
                                              (z, self._cosmo))
     nfw = NFW(m200, func(m200, z, self._cosmo), z)
     m_out = nfw.mass_Delta(overdensity_out)
     return m_out
예제 #8
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_mean_crit_consistency(self):
     m200b = 1e15
     c = 5
     z = 0.3
     nfw = NFW(m200b, c, z, overdensity_type="mean")
     m200c = nfw.mass_Delta(200, overdensity_type="critical").value
     assert_almost_equal(m200c / 1e15, 2.062054316492159)
예제 #9
0
파일: test_nfw.py 프로젝트: nhmc/NFW
 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))
예제 #10
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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)
예제 #11
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_delta_sigma(self):
     m200 = 1e15
     c = 5.0
     z = 0.3
     nfw = NFW(m200, c, z)
     ds = nfw.delta_sigma([0.1, 1.12])
     ref_arr = np.array([5.28752650, 1.38772723])
     assert_array_almost_equal(ds.value / 1e14, ref_arr)
예제 #12
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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)
예제 #13
0
 def test_m200_to_mdelta(self):
     m_in = u.Quantity(4e14, u.solMass)
     z = 0.45
     func = mass_concentration.duffy_concentration
     mdelta = mass_concentration.m200_to_mdelta(m_in, func, 500,
                                                (z, self._cosmo))
     nfw = NFW(m_in, func(m_in, z, self._cosmo), z)
     m500 = nfw.mass_Delta(500)
     assert_quantity_allclose(mdelta, m500)
예제 #14
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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)
예제 #15
0
    def test_mdelta_to_mdelta(self):
        func = mass_concentration.duffy_concentration
        # Consistency
        z = 0.3
        m_in = u.Quantity(5e14, u.solMass)
        mdelta = mass_concentration.mdelta_to_mdelta(5e14, func, 500, 200,
                                                     (z, self._cosmo))
        c = func(mdelta, z, self._cosmo)
        nfw = NFW(mdelta, c, z)
        m_out = nfw.mass_Delta(500)
        assert_quantity_allclose(m_in, m_out)

        mdelta1 = mass_concentration.mdelta_to_mdelta(m_in, func, 200, 500,
                                                      (z, self._cosmo))
        nfw = NFW(m_in, func(m_in, z, self._cosmo), z)
        mdelta2 = nfw.mass_Delta(500)
        assert_quantity_allclose(mdelta1, mdelta2)
        # common cases:
        m_in = u.Quantity(1e14, u.solMass)
        z = 0
        mdelta1 = mass_concentration.mdelta_to_mdelta(m_in, func, 2500, 500,
                                                      (z, self._cosmo))
        mdelta2 = self._mdelta_to_mdelta_via_m200(m_in, func, 2500, 500, z)
        assert_quantity_allclose(mdelta1, mdelta2)

        # Test some extreme cases
        # first almost equal input and output overdensities
        m_in = u.Quantity(1e14, u.solMass)
        z = 1
        m200 = mass_concentration.mdelta_to_mdelta(m_in, func, 199, 200,
                                                   (z, self._cosmo))
        m_out = mass_concentration.mdelta_to_mdelta(m200, func, 200, 199,
                                                    (z, self._cosmo))
        assert_quantity_allclose(m_in, m_out)

        # identical input/output overdensity
        mdelta = mass_concentration.mdelta_to_mdelta(1e14, func, 200, 200,
                                                     (1, self._cosmo))
        assert_equal(mdelta.value, 1e14)

        # Large overdensity_in, small overdensity_out
        m_in = 1e15
        z = 0
        mdelta1 = mass_concentration.mdelta_to_mdelta(m_in, func, 2500, 50,
                                                      (z, self._cosmo))
        mdelta2 = self._mdelta_to_mdelta_via_m200(m_in, func, 2500, 50, z)
        assert_quantity_allclose(mdelta1, mdelta2)

        # Small overdensity_in, large overdensity_out, small halo mass
        m_in = 1e9
        z = 1
        mdelta1 = mass_concentration.mdelta_to_mdelta(m_in, func, 50, 2500,
                                                      (z, self._cosmo))
        mdelta2 = self._mdelta_to_mdelta_via_m200(m_in, func, 50, 2500, z)
        assert_quantity_allclose(mdelta1, mdelta2)
예제 #16
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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)
def predict_ds(rp,
               mass=1e13,
               c=6,
               rho_mean=52700242579.0,
               DELTA_HALO=200,
               h=0.7):
    nfw = NFW(mass, c, rho_mean, DELTA_HALO)
    ds = nfw.DelSig(rp / h)
    # [Msun/Mpc^2] to [h Msun/pc^2]
    ds = ds / 1e12 / h
    return (ds)
예제 #18
0
파일: test_nfw.py 프로젝트: nhmc/NFW
 def test_projected_mass(self):
     m200 = 1e15
     c = 3
     z = 0.3
     nfw = NFW(m200, c, z)
     r = np.linspace(0.2, 3, 20) * u.Mpc
     m_proj = nfw.projected_mass(r) / 1e14
     # Comparison array was computed by numerical integration
     m_comp = np.array([1.16749071e+14, 2.43823901e+14, 3.73873287e+14,
                        5.00159715e+14, 6.20505986e+14, 7.34386597e+14,
                        8.41921446e+14, 9.43479009e+14, 1.03950855e+15,
                        1.13046724e+15, 1.21678913e+15, 1.29887325e+15,
                        1.37708069e+15, 1.45173558e+15, 1.52312796e+15,
                        1.59151704e+15, 1.65713471e+15, 1.72018864e+15,
                        1.78086525e+15, 1.83933223e+15]) / 1e14
     assert_array_almost_equal(m_proj.value, m_comp)
예제 #19
0
 def test_mdelta_to_m200(self):
     m_in = u.Quantity(2e14, u.solMass)
     z = 0.2
     func = mass_concentration.duffy_concentration
     delta_in = 450
     # consistency with mdelta_to_mdelta
     md1 = mass_concentration.mdelta_to_m200(m_in, func, delta_in,
                                             (z, self._cosmo))
     md2 = mass_concentration.mdelta_to_mdelta(m_in, func,
                                               delta_in, 200,
                                               (z, self._cosmo))
     assert_quantity_allclose(md1, md2)
     # consistency with mass_Delta in NFW
     nfw = NFW(md1, func(md1, z, self._cosmo), z)
     m_out = nfw.mass_Delta(450)
     assert_quantity_allclose(m_in, m_out)
예제 #20
0
파일: test_nfw.py 프로젝트: jesford/NFW
    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)
예제 #21
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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)
예제 #22
0
파일: test_nfw.py 프로젝트: nhmc/NFW
 def test_radius_unit_consistency(self):
     r200 = 1.5
     c = 4
     z = 0.2
     nfw1 = NFW(r200, c, z, size_type='radius')
     nfw2 = NFW(r200 * u.Mpc, c, z, size_type='radius')
     nfw3 = NFW(r200*1000 * u.kiloparsec, c, z, size_type='radius')
     assert_almost_equal(nfw1.mass_Delta(200), nfw2.mass_Delta(200))
     assert_almost_equal(nfw1.mass_Delta(200), nfw3.mass_Delta(200))
예제 #23
0
    def integrate_mass_func_kappa_y(self, m, z):
        '''
        Eq. 3.1 of Ma & Van Waerbeke. Here I took mass of the halo (i.e. m)
        as Mvir 
        and find Rvir and concentration accordingly. I need to ask Salman 
        about this assumption  
        '''
        mass_function = self.mass_func(m)
        self.nfw = NFW(z, m, NM=False, print_mode=False)
        self.kappa_l = convergence.kappa_l(self.w_k, self.cosmo, self.nfw,
                                           self.ell).k_l
        self.y_l = convergence.sz_l(self.cosmo, self.nfw, self.ell).beta_y_l(m)

        #print mass_function, kappa_l.k_l(m), y_l.beta_y_l(m)
        return mass_function * self.kappa_l * self.y_l
예제 #24
0
파일: test_nfw.py 프로젝트: jesford/NFW
 def test_radius_unit_consistency(self):
     r200 = 1.5
     c = 4
     z = 0.2
     nfw1 = NFW(r200, c, z, size_type="radius")
     nfw2 = NFW(r200 * u.Mpc, c, z, size_type="radius")
     nfw3 = NFW(r200 * 1000 * u.kiloparsec, c, z, size_type="radius")
     m200_1 = nfw1.mass_Delta(200)
     m200_2 = nfw2.mass_Delta(200)
     m200_3 = nfw3.mass_Delta(200)
     m200_1 = u.Quantity(m200_1, m200_3.unit)
     m200_2 = u.Quantity(m200_2, m200_3.unit)
     assert_almost_equal(m200_1.value, m200_2.value)
     assert_almost_equal(m200_1.value, m200_3.value)
예제 #25
0
            self.battaglia_integral,
            0,
            2,
            args=(M200, R200),
            epsabs=config.default_precision['epsabs'],
            epsrel=config.default_precision['epsrel'])[0]
        return y_l


if __name__ == '__main__':
    cosmo_dict = config.default_cosmo_dict
    lens_redshift = 0.05
    ell = 100
    mass = 1e15
    cosmo = cosmology_vinu.SingleEpoch(lens_redshift, cosmo_dict=cosmo_dict)
    nfw = NFW(lens_redshift, mass, NM=False, print_mode=False)

    y = sz_l(cosmo, nfw, ell)
    print 'Beta '
    print y.beta_y_l(mass)
    print 'UP '
    print y.up_y_l(mass)
    if 0:
        r = np.arange(1e-3, 8, 0.01)
        yr = 1e3 * y.beta_pressure_profile(r)
        pl.plot(r, yr * r * r, label='Beta')
        yr = 1e3 * y.universal_pressure_profile(r)
        pl.plot(r, yr * r * r, label='UP')
        pl.legend(loc=0)
        pl.xlabel('R (Mpc/h)')
        pl.ylabel(r'$P_e r^2 [eV cm^{-3} Mpc^2 h^{-2}]$')
예제 #26
0
from nfw import NFW
import cosmology
from scipy.interpolate import interp1d

from astropy.io import ascii

## Everything done in cgs units
Gc = 6.67e-8
kB = 1.38e-16
kpc = 3.086e21
Msun = 2.e33
yr = 3.16e7
mp = 1.67e-24

cosm = cosmology.cosmology(h=.7, Om=.3, Ol=.7)
nfw = NFW(1.e6, 25, None, cosm)
#nfw = NFW(5.e5,20,None,cosm)

tau_star = 3e6 * yr
Tion = 3.e4
Tvir = nfw.Tvir
cion = np.sqrt(kB * Tion / (0.59 * mp))
cvir = np.sqrt(kB * Tvir / (1.23 * mp))

Shu = ascii.read('Shu_data.tab')
alpha_eps = interp1d(Shu['eps'], Shu['alpha0'], kind='quadratic')
xsh_eps = interp1d(Shu['eps'], Shu['xs'], kind='quadratic')


def ydot(y, x):
    a, v = y
예제 #27
0
파일: test_nfw.py 프로젝트: jesford/NFW
 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)