Beispiel #1
0
    def test_multi_gaussian_decomposition_ellipse(self):
        Rs = 1.
        kwargs_light = [{'Rs': Rs, 'amp': 1., 'center_x': 0, 'center_y': 0}]
        kwargs_options = {'light_model_list': ['HERNQUIST']}
        lightModel = LightModel(**kwargs_options)
        profile = LightProfileAnalysis(light_model=lightModel)

        kwargs_mge = profile.multi_gaussian_decomposition_ellipse(
            kwargs_light,
            grid_spacing=0.01,
            grid_num=100,
            model_bool_list=None,
            n_comp=20,
            center_x=None,
            center_y=None)
        mge = MultiGaussianEllipse()
        r_array = np.logspace(start=-2, stop=0.5, num=10)
        flux = mge.function(r_array, 0, **kwargs_mge)
        flux_true = lightModel.surface_brightness(r_array, 0, kwargs_light)
        npt.assert_almost_equal(flux / flux_true, 1, decimal=2)

        # elliptic

        Rs = 1.
        kwargs_light = [{
            'Rs': Rs,
            'amp': 1.,
            'e1': 0.1,
            'e2': 0,
            'center_x': 0,
            'center_y': 0
        }]
        kwargs_options = {'light_model_list': ['HERNQUIST_ELLIPSE']}
        lightModel = LightModel(**kwargs_options)
        profile = LightProfileAnalysis(light_model=lightModel)

        kwargs_mge = profile.multi_gaussian_decomposition_ellipse(
            kwargs_light,
            grid_spacing=0.1,
            grid_num=400,
            model_bool_list=None,
            n_comp=20,
            center_x=None,
            center_y=None)

        print(kwargs_mge['e1'])
        mge = MultiGaussianEllipse()
        r_array = np.logspace(start=-2, stop=0.5, num=10)
        flux = mge.function(r_array, 0, **kwargs_mge)
        flux_true = lightModel.surface_brightness(r_array, 0, kwargs_light)

        npt.assert_almost_equal(flux / flux_true, 1, decimal=1)
 def test_mge_lens_light_elliptical(self):
     e1, e2 = 0.3, 0.
     kwargs_profile = [{
         'amp': 1.,
         'sigma': 2,
         'center_x': 0.,
         'center_y': 0,
         'e1': e1,
         'e2': e2
     }]
     kwargs_options = {'lens_light_model_list': ['GAUSSIAN_ELLIPSE']}
     lensAnalysis = LensAnalysis(kwargs_options)
     amplitudes, sigma, center_x, center_y = lensAnalysis.multi_gaussian_lens_light(
         kwargs_profile, n_comp=20, e1=e1, e2=e2, deltaPix=0.05, numPix=400)
     mge = MultiGaussianEllipse()
     flux = mge.function(1.,
                         1,
                         amp=amplitudes,
                         sigma=sigma,
                         center_x=center_x,
                         center_y=center_y,
                         e1=e1,
                         e2=e2)
     flux_true = lensAnalysis.LensLightModel.surface_brightness(
         1., 1., kwargs_profile)
     npt.assert_almost_equal(flux / flux_true, 1, decimal=1)