Beispiel #1
0
 def test_ellipticity_in_profiles(self):
     lightProfile = ['HERNQUIST_ELLIPSE', 'PJAFFE_ELLIPSE']
     kwargs_profile = [{
         'Rs': 0.16350224766074103,
         'q': 0.4105628122365978,
         'center_x': -0.019983826426838536,
         'center_y': 0.90000011282957304,
         'phi_G': 0.14944144075912402,
         'sigma0': 1.3168943578511678
     }, {
         'Rs': 0.29187068596715743,
         'q': 0.70799587973181288,
         'center_x': 0.020568531548241405,
         'center_y': 0.036038490364800925,
         'Ra': 0.020000382843298824,
         'phi_G': -0.37221683730659516,
         'sigma0': 85.948773973262391
     }]
     kwargs_options = {
         'lens_model_list': ['SPEMD'],
         'lens_model_internal_bool': [True],
         'lens_light_model_internal_bool': [True, True],
         'lens_light_model_list': lightProfile
     }
     lensAnalysis = LensAnalysis(kwargs_options, {})
     r_eff = lensAnalysis.half_light_radius(kwargs_profile)
     kwargs_profile[0]['q'] = 1
     kwargs_profile[1]['q'] = 1
     r_eff_spherical = lensAnalysis.half_light_radius(kwargs_profile)
     npt.assert_almost_equal(r_eff / r_eff_spherical, 1, decimal=2)
Beispiel #2
0
    def test_sersic_vs_hernquist_kinematics(self):
        """
        attention: this test only works for Sersic indices > \approx 2!
        Lower n_sersic will result in different predictions with the Hernquist assumptions
        replacing the correct Light model!
        :return:
        """
        # anisotropy profile
        anisotropy_type = 'OsipkovMerritt'
        r_ani = 2.
        kwargs_anisotropy = {'r_ani': r_ani}  # anisotropy radius [arcsec]

        # aperture as slit
        aperture_type = 'slit'
        length = 3.8
        width = 0.9
        kwargs_aperture = {
            'length': length,
            'width': width,
            'center_ra': 0,
            'center_dec': 0,
            'angle': 0
        }

        psf_fwhm = 0.7  # Gaussian FWHM psf
        kwargs_cosmo = {'D_d': 1000, 'D_s': 1500, 'D_ds': 800}

        # light profile
        light_profile_list = ['SERSIC']
        r_sersic = .3
        n_sersic = 2.8
        kwargs_light = [{
            'I0_sersic': 1.,
            'R_sersic': r_sersic,
            'n_sersic': n_sersic
        }]  # effective half light radius (2d projected) in arcsec

        # mass profile
        mass_profile_list = ['SPP']
        theta_E = 1.2
        gamma = 2.
        kwargs_profile = [{
            'theta_E': theta_E,
            'gamma': gamma
        }]  # Einstein radius (arcsec) and power-law slope

        # Hernquist fit to Sersic profile
        lens_analysis = LensAnalysis(
            {
                'lens_light_model_list': ['SERSIC'],
                'lens_model_list': ['NONE']
            }, {})
        r_eff = lens_analysis.half_light_radius(kwargs_light)
        print(r_eff)
        light_profile_list_hernquist = ['HERNQUIST']
        kwargs_light_hernquist = [{'Rs': r_eff * 0.551, 'sigma0': 1.}]

        # mge of light profile
        lightModel = LightModel(light_profile_list)
        r_array = np.logspace(-3, 2, 100) * r_eff * 2
        print(r_sersic / r_eff, 'r_sersic/r_eff')
        flux_r = lightModel.surface_brightness(r_array, 0, kwargs_light)
        amps, sigmas, norm = mge.mge_1d(r_array, flux_r, N=20)
        light_profile_list_mge = ['MULTI_GAUSSIAN']
        kwargs_light_mge = [{'amp': amps, 'sigma': sigmas}]
        print(amps, sigmas, 'amp', 'sigma')

        galkin = Galkin(mass_profile_list,
                        light_profile_list_hernquist,
                        aperture_type=aperture_type,
                        anisotropy_model=anisotropy_type,
                        fwhm=psf_fwhm,
                        kwargs_cosmo=kwargs_cosmo)
        sigma_v = galkin.vel_disp(kwargs_profile, kwargs_light_hernquist,
                                  kwargs_anisotropy, kwargs_aperture)

        galkin = Galkin(mass_profile_list,
                        light_profile_list_mge,
                        aperture_type=aperture_type,
                        anisotropy_model=anisotropy_type,
                        fwhm=psf_fwhm,
                        kwargs_cosmo=kwargs_cosmo)
        sigma_v2 = galkin.vel_disp(kwargs_profile, kwargs_light_mge,
                                   kwargs_anisotropy, kwargs_aperture)

        print sigma_v, sigma_v2, 'sigma_v Galkin, sigma_v MGEn'
        print(sigma_v / sigma_v2)**2

        npt.assert_almost_equal((sigma_v - sigma_v2) / sigma_v2, 0, decimal=1)