Ejemplo n.º 1
0
    def __init__(self, z_lens, z_source, cosmo=None):
        """

        :param z_lens: redshift of lens
        :param z_source: redshift of source
        :param cosmo: astropy.cosmology instance
        """

        self.z_lens = z_lens
        self.z_source = z_source
        self.background = Background(cosmo=cosmo)
        self.nfw_param = NFWParam()
Ejemplo n.º 2
0
    def test_against_colossus(self):
        """
        This test class asks to get the same parameters back as colossus: https://bdiemer.bitbucket.io/colossus/index.html
        """
        cosmo = FlatLambdaCDM(H0=70, Om0=0.285, Ob0=0.05)
        nfw_param = NFWParam(cosmo=cosmo)

        from colossus.cosmology import cosmology as cosmology_colossus
        from colossus.halo.profile_nfw import NFWProfile
        colossus_kwargs = {
            'H0': 70,
            'Om0': 0.285,
            'Ob0': 0.05,
            'ns': 0.96,
            'sigma8': 0.82,
            'persistence': ''
        }
        colossus = cosmology_colossus.setCosmology('custom', colossus_kwargs)

        m200 = 10**8
        c = 17.

        zvals = np.linspace(0.0, 2, 50)
        h = 0.7

        for z in zvals:
            nfw_colossus = NFWProfile(M=m200 * h, z=z, c=c, mdef='200c')
            rhos_colossus, rs_colossus = nfw_colossus.nativeParameters(
                m200 * h, c, z, mdef='200c')
            r200_colossus = rs_colossus * c

            # according to colossus documentation the density is in physical units[M h^2/kpc^3] and distance [kpc/h]
            rs_colossus *= h**-1
            rhos_colossus *= h**2

            r200_lenstronomy = nfw_param.r200_M(m200 * h,
                                                z) / h  # physical radius r200
            rs_lenstronomy = r200_lenstronomy / c
            rhos_lenstronomy = nfw_param.rho0_c(
                c, z) * h**2  # physical density in M_sun/Mpc**3

            # convert Mpc to kpc
            rhos_lenstronomy *= 1000**-3
            rs_lenstronomy *= 1000
            npt.assert_almost_equal(rs_lenstronomy / rs_colossus, 1, decimal=3)
            npt.assert_almost_equal(rhos_lenstronomy / rhos_colossus,
                                    1,
                                    decimal=3)
Ejemplo n.º 3
0
 def setup(self):
     z_L = 0.8
     z_S = 3.0
     from astropy.cosmology import FlatLambdaCDM
     cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
     self.nfwParam = NFWParam()
Ejemplo n.º 4
0
    def setup(self):

        cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
        self.nfwParam = NFWParam(cosmo=cosmo)
        self.z = 0.5  # needed fixed redshift for the inversion function