def test_sigma_s2(self):
        """
        test LOS projected velocity dispersion at 3d ratios (numerical Jeans equation solution vs analytic one)
        """
        light_profile_list = ['HERNQUIST']
        r_eff = 0.5
        Rs = 0.551 * r_eff
        kwargs_light = [{
            'Rs': Rs,
            'amp': 1.
        }]  # effective half light radius (2d projected) in arcsec
        # 0.551 *
        # mass profile
        mass_profile_list = ['SPP']
        theta_E = 1.2
        gamma = 1.95
        kwargs_mass = [{
            'theta_E': theta_E,
            'gamma': gamma
        }]  # Einstein radius (arcsec) and power-law slope

        # anisotropy profile
        anisotropy_type = 'OM'
        r_ani = 0.5
        kwargs_anisotropy = {'r_ani': r_ani}  # anisotropy radius [arcsec]

        kwargs_cosmo = {'d_d': 1000, 'd_s': 1500, 'd_ds': 800}
        kwargs_numerics = {
            'interpol_grid_num': 2000,
            'log_integration': True,
            'max_integrate': 4000,
            'min_integrate': 0.001
        }

        kwargs_model = {
            'mass_profile_list': mass_profile_list,
            'light_profile_list': light_profile_list,
            'anisotropy_model': anisotropy_type
        }
        analytic_kin = AnalyticKinematics(kwargs_cosmo, **kwargs_numerics)
        numeric_kin = NumericKinematics(kwargs_model, kwargs_cosmo,
                                        **kwargs_numerics)
        r_list = np.logspace(-2, 1, 10)
        for r in r_list:
            for R in np.linspace(start=0, stop=r, num=5):
                sigma_s2_analytic, I_R = analytic_kin.sigma_s2(
                    r, R, {
                        'theta_E': theta_E,
                        'gamma': gamma
                    }, {'r_eff': r_eff}, kwargs_anisotropy)
                sigma_s2_full_num = numeric_kin.sigma_s2_r(
                    r, R, kwargs_mass, kwargs_light, kwargs_anisotropy)
                npt.assert_almost_equal(sigma_s2_full_num / sigma_s2_analytic,
                                        1,
                                        decimal=2)
Пример #2
0
    def __init__(self,
                 kwargs_model,
                 kwargs_cosmo,
                 kwargs_numerics=None,
                 analytic_kinematics=False):
        """

        :param kwargs_model: keyword arguments describing the model components
        :param kwargs_cosmo: keyword arguments that define the cosmology in terms of the angular diameter distances involved
        :param kwargs_numerics: numerics keyword arguments
        :param analytic_kinematics: bool, if True uses the analytic kinematic model
        """
        if kwargs_numerics is None:
            kwargs_numerics = {
                'interpol_grid_num':
                200,  # numerical interpolation, should converge -> infinity
                'log_integration': True,
                # log or linear interpolation of surface brightness and mass models
                'max_integrate': 100,
                'min_integrate': 0.001
            }  # lower/upper bound of numerical integrals
        if analytic_kinematics is True:
            anisotropy_model = kwargs_model.get('anisotropy_model')
            if not anisotropy_model == 'OM':
                raise ValueError(
                    'analytic kinematics only available for OsipkovMerritt ("OM") anisotropy model.'
                )
            self.numerics = AnalyticKinematics(kwargs_cosmo=kwargs_cosmo,
                                               **kwargs_numerics)
        else:
            self.numerics = NumericKinematics(kwargs_model=kwargs_model,
                                              kwargs_cosmo=kwargs_cosmo,
                                              **kwargs_numerics)
        self._analytic_kinematics = analytic_kinematics
Пример #3
0
    def velocity_dispersion(self,
                            kwargs_lens,
                            r_eff,
                            R_slit,
                            dR_slit,
                            psf_fwhm,
                            aniso_param=1,
                            psf_type='GAUSSIAN',
                            moffat_beta=2.6,
                            num_evaluate=1000,
                            kappa_ext=0):
        """
        computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit and seeing psf_fwhm.
        The assumptions are a Hernquist light profile and the spherical power-law lens model at the first position.

        Further information can be found in the AnalyticKinematics() class.

        :param kwargs_lens: lens model parameters
        :param kwargs_lens_light: deflector light parameters
        :param aniso_param: scaled r_ani with respect to the half light radius
        :param r_eff: half light radius, if not provided, will be computed from the lens light model
        :param R_slit: width of the slit
        :param dR_slit: length of the slit
        :param psf_fwhm: full width at half maximum of the seeing (Gaussian form)
        :param psf_type: string, point spread functino type, current support for 'GAUSSIAN' and 'MOFFAT'
        :param moffat_beta: float, beta parameter of Moffat profile
        :param num_evaluate: number of spectral rendering of the light distribution that end up on the slit
        :param kappa_ext: external convergence not accounted in the lens models
        :return: velocity dispersion in units [km/s]
        """
        gamma = kwargs_lens[0]['gamma']
        theta_E = kwargs_lens[0]['theta_E']
        r_ani = aniso_param * r_eff
        analytic_kinematics = AnalyticKinematics(fwhm=psf_fwhm,
                                                 moffat_beta=moffat_beta,
                                                 psf_type=psf_type,
                                                 **self._kwargs_cosmo)
        sigma = analytic_kinematics.vel_disp(gamma,
                                             theta_E,
                                             r_eff,
                                             r_ani,
                                             R_slit,
                                             dR_slit,
                                             rendering_number=num_evaluate)
        sigma *= np.sqrt(1 - kappa_ext)
        return sigma
Пример #4
0
    def test_galkin_vs_LOS_dispersion(self):
        """
        tests whether the old and new version provide the same answer
        :return:
        """
        # light profile
        light_profile = 'Hernquist'
        r_eff = 0.5
        kwargs_light = {'r_eff': r_eff}  # effective half light radius (2d projected) in arcsec

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

        # anisotropy profile
        anisotropy_type = 'r_ani'
        r_ani = 0.5
        kwargs_anisotropy = {'r_ani': r_ani}  # anisotropy radius [arcsec]

        # aperture as shell
        #aperture_type = 'shell'
        #kwargs_aperture_inner = {'r_in': 0., 'r_out': 0.2, 'center_dec': 0, 'center_ra': 0}

        #kwargs_aperture_outer = {'r_in': 0., 'r_out': 1.5, 'center_dec': 0, 'center_ra': 0}

        # 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.1  # Gaussian FWHM psf
        kwargs_cosmo = {'D_d': 1000, 'D_s': 1500, 'D_ds': 800}

        galkin = GalKinAnalytic(aperture=aperture_type, mass_profile=mass_profile, light_profile=light_profile,
                                anisotropy_type=anisotropy_type, psf_fwhm=psf_fwhm, kwargs_cosmo=kwargs_cosmo)
        sigma_v = galkin.vel_disp(kwargs_profile, kwargs_aperture, kwargs_light, kwargs_anisotropy, num=2000)

        los_disp = AnalyticKinematics(**kwargs_cosmo)
        sigma_v2 = los_disp.vel_disp(gamma, theta_E, r_eff, r_ani=r_ani, R_slit=length, dR_slit=width,
                                     FWHM=psf_fwhm, rendering_number=2000)
        npt.assert_almost_equal((sigma_v-sigma_v2)/sigma_v2, 0, decimal=2)
Пример #5
0
    def test_compare_power_law(self):
        """
        compare power-law profiles analytical vs. numerical
        :return:
        """
        # light profile
        light_profile_list = ['HERNQUIST']
        r_eff = 1.5
        kwargs_light = [{'Rs':  r_eff, 'amp': 1.}]  # effective half light radius (2d projected) in arcsec
        # 0.551 *
        # 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

        # anisotropy profile
        anisotropy_type = 'OsipkovMerritt'
        r_ani = 2.
        kwargs_anisotropy = {'r_ani': r_ani}  # anisotropy radius [arcsec]

        # aperture as slit
        aperture_type = 'slit'
        length = 1.
        width = 0.3
        kwargs_aperture = {'length': length, 'width': width, 'center_ra': 0, 'center_dec': 0, 'angle': 0}

        psf_fwhm = 1.  # Gaussian FWHM psf
        kwargs_cosmo = {'D_d': 1000, 'D_s': 1500, 'D_ds': 800}
        kwargs_numerics = {'sampling_number': 1000, 'interpol_grid_num': 500, 'log_integration': True,
                           'max_integrate': 100}
        galkin = Galkin(mass_profile_list, light_profile_list, aperture_type=aperture_type, anisotropy_model=anisotropy_type, fwhm=psf_fwhm, kwargs_cosmo=kwargs_cosmo, **kwargs_numerics)
        sigma_v = galkin.vel_disp(kwargs_profile, kwargs_light, kwargs_anisotropy, kwargs_aperture)

        kwargs_numerics = {'sampling_number': 1000, 'interpol_grid_num': 500, 'log_integration': False,
                           'max_integrate': 10}
        galkin = Galkin(mass_profile_list, light_profile_list, aperture_type=aperture_type, anisotropy_model=anisotropy_type, fwhm=psf_fwhm, kwargs_cosmo=kwargs_cosmo, **kwargs_numerics)
        sigma_v_lin = galkin.vel_disp(kwargs_profile, kwargs_light, kwargs_anisotropy, kwargs_aperture)

        los_disp = AnalyticKinematics(**kwargs_cosmo)
        sigma_v2 = los_disp.vel_disp(gamma, theta_E, r_eff / 0.551, r_ani=r_ani, R_slit=length, dR_slit=width,
                                     FWHM=psf_fwhm, rendering_number=1000)
        print(sigma_v, sigma_v_lin, sigma_v2, 'sigma_v Galkin (log and linear), sigma_v los dispersion')
        npt.assert_almost_equal(sigma_v2/sigma_v, 1, decimal=2)
Пример #6
0
    def __init__(self, z_lens, z_source, kwargs_model, cosmo=None):
        """

        :param z_lens: redshift of lens
        :param z_source: redshift of source
        :param kwargs_model: model keyword arguments
        :param cosmo: astropy.cosmology instance
        """
        self.z_d = z_lens
        self.z_s = z_source
        self.lensCosmo = LensCosmo(z_lens, z_source, cosmo=cosmo)
        self.lens_analysis = LensAnalysis(kwargs_model)
        self._lensModelExt = LensModelExtensions(self.lens_analysis.LensModel)
        self.kwargs_options = kwargs_model
        kwargs_cosmo = {
            'D_d': self.lensCosmo.D_d,
            'D_s': self.lensCosmo.D_s,
            'D_ds': self.lensCosmo.D_ds
        }
        self.analytic_kinematics = AnalyticKinematics(**kwargs_cosmo)
 def test_sigma_s2(self):
     kwargs_aperture = {
         'center_ra': 0,
         'width': 1,
         'length': 1,
         'angle': 0,
         'center_dec': 0,
         'aperture_type': 'slit'
     }
     kwargs_cosmo = {'d_d': 1000, 'd_s': 1500, 'd_ds': 800}
     kwargs_psf = {'psf_type': 'GAUSSIAN', 'fwhm': 1}
     kin = AnalyticKinematics(kwargs_cosmo)
     kwargs_light = {'r_eff': 1}
     sigma_s2 = kin.sigma_s2(r=1,
                             R=0.1,
                             kwargs_mass={
                                 'theta_E': 1,
                                 'gamma': 2
                             },
                             kwargs_light=kwargs_light,
                             kwargs_anisotropy={'r_ani': 1})
     assert 'a' in kwargs_light
Пример #8
0
    def velocity_dispersion_analytical(self,
                                       theta_E,
                                       gamma,
                                       r_eff,
                                       kwargs_aperture,
                                       kwargs_psf,
                                       r_ani,
                                       num_evaluate=1000,
                                       kappa_ext=0):
        """
        computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit and seeing psf_fwhm.
        The assumptions are a Hernquist light profile and the spherical power-law lens model at the first position and
        an 'OsipkovMerritt' stellar anisotropy distribution.

        Further information can be found in the AnalyticKinematics() class.

        :param theta_E: Einstein radius
        :param gamma: power-low slope of the mass profile (=2 corresponds to isothermal)
        :param r_ani: anisotropy radius in units of angles
        :param r_eff: projected half-light radius
        :param kwargs_aperture: aperture parameters (see Galkin module)
        :param num_evaluate: number of spectral rendering of the light distribution that end up on the slit
        :param kappa_ext: external convergence not accounted in the lens models
        :return: velocity dispersion in units [km/s]
        """

        analytic_kinematics = AnalyticKinematics(
            kwargs_psf=kwargs_psf,
            kwargs_aperture=kwargs_aperture,
            **self._kwargs_cosmo)
        sigma = analytic_kinematics.vel_disp(gamma,
                                             theta_E,
                                             r_eff,
                                             r_ani,
                                             rendering_number=num_evaluate)
        sigma *= np.sqrt(1 - kappa_ext)
        return sigma
    def test_sigma_r2(self):
        """
        tests the solution of the Jeans equation for sigma**2(r), where r is the 3d radius.
        Test is compared to analytic OM solution with power-law and Hernquist light profile

        :return:
        """
        light_profile_list = ['HERNQUIST']
        r_eff = 0.5
        Rs = 0.551 * r_eff
        kwargs_light = [{
            'Rs': Rs,
            'amp': 1.
        }]  # effective half light radius (2d projected) in arcsec
        # 0.551 *
        # mass profile
        mass_profile_list = ['SPP']
        theta_E = 1.2
        gamma = 1.95
        kwargs_mass = [{
            'theta_E': theta_E,
            'gamma': gamma
        }]  # Einstein radius (arcsec) and power-law slope

        # anisotropy profile
        anisotropy_type = 'OM'
        r_ani = 0.5
        kwargs_anisotropy = {'r_ani': r_ani}  # anisotropy radius [arcsec]

        kwargs_cosmo = {'d_d': 1000, 'd_s': 1500, 'd_ds': 800}
        kwargs_numerics = {
            'interpol_grid_num': 2000,
            'log_integration': True,
            'max_integrate': 4000,
            'min_integrate': 0.001
        }

        kwargs_model = {
            'mass_profile_list': mass_profile_list,
            'light_profile_list': light_profile_list,
            'anisotropy_model': anisotropy_type
        }
        analytic_kin = AnalyticKinematics(kwargs_cosmo, **kwargs_numerics)
        numeric_kin = NumericKinematics(kwargs_model, kwargs_cosmo,
                                        **kwargs_numerics)
        rho0_r0_gamma = analytic_kin._rho0_r0_gamma(theta_E, gamma)
        r_array = np.logspace(-2.9, 2.9, 100)
        sigma_r_analytic_array = []
        sigma_r_num_array = []
        for r in r_array:
            sigma_r2_analytic = analytic_kin._sigma_r2(
                r=r,
                a=Rs,
                gamma=gamma,
                r_ani=r_ani,
                rho0_r0_gamma=rho0_r0_gamma)
            sigma_r2_num = numeric_kin.sigma_r2(r, kwargs_mass, kwargs_light,
                                                kwargs_anisotropy)
            sigma_r_analytic = np.sqrt(sigma_r2_analytic) / 1000
            sigma_r_num = np.sqrt(sigma_r2_num) / 1000
            sigma_r_num_array.append(sigma_r_num)
            sigma_r_analytic_array.append(sigma_r_analytic)

        npt.assert_almost_equal(sigma_r_num_array,
                                sigma_r_analytic_array,
                                decimal=-2)
        npt.assert_almost_equal(np.array(sigma_r_num_array) /
                                np.array(sigma_r_analytic_array),
                                1,
                                decimal=-2)
        print(np.array(sigma_r_num_array) / np.array(sigma_r_analytic_array))
Пример #10
0
class LensProp(object):
    """
    this class contains routines to compute time delays, magnification ratios, line of sight velocity dispersions etc
    for a given lens model
    """
    def __init__(self, z_lens, z_source, kwargs_model, cosmo=None):
        """

        :param z_lens: redshift of lens
        :param z_source: redshift of source
        :param kwargs_model: model keyword arguments
        :param cosmo: astropy.cosmology instance
        """
        self.z_d = z_lens
        self.z_s = z_source
        self.lensCosmo = LensCosmo(z_lens, z_source, cosmo=cosmo)
        self.lens_analysis = LensAnalysis(kwargs_model)
        self._lensModelExt = LensModelExtensions(self.lens_analysis.LensModel)
        self.kwargs_options = kwargs_model
        kwargs_cosmo = {
            'D_d': self.lensCosmo.D_d,
            'D_s': self.lensCosmo.D_s,
            'D_ds': self.lensCosmo.D_ds
        }
        self.analytic_kinematics = AnalyticKinematics(**kwargs_cosmo)

    def time_delays(self, kwargs_lens, kwargs_ps, kappa_ext=0):
        """
        predicts the time delays of the image positions

        :param kwargs_lens: lens model parameters
        :param kwargs_ps: point source parameters
        :param kappa_ext: external convergence (optional)
        :return: time delays at image positions for the fixed cosmology
        """
        fermat_pot = self.lens_analysis.fermat_potential(
            kwargs_lens, kwargs_ps)
        time_delay = self.lensCosmo.time_delay_units(fermat_pot, kappa_ext)
        return time_delay

    def velocity_dispersion(self,
                            kwargs_lens,
                            kwargs_lens_light,
                            lens_light_model_bool_list=None,
                            aniso_param=1,
                            r_eff=None,
                            R_slit=0.81,
                            dR_slit=0.1,
                            psf_fwhm=0.7,
                            num_evaluate=1000):
        """
        computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit and seeing psf_fwhm.
        The assumptions are a Hernquist light profile and the spherical power-law lens model at the first position.

        Further information can be found in the AnalyticKinematics() class.

        :param kwargs_lens: lens model parameters
        :param kwargs_lens_light: deflector light parameters
        :param aniso_param: scaled r_ani with respect to the half light radius
        :param r_eff: half light radius, if not provided, will be computed from the lens light model
        :param R_slit: width of the slit
        :param dR_slit: length of the slit
        :param psf_fwhm: full width at half maximum of the seeing condition
        :param num_evaluate: number of spectral rendering of the light distribution that end up on the slit
        :return: velocity dispersion in units [km/s]
        """
        gamma = kwargs_lens[0]['gamma']
        if 'center_x' in kwargs_lens_light[0]:
            center_x, center_y = kwargs_lens_light[0][
                'center_x'], kwargs_lens_light[0]['center_y']
        else:
            center_x, center_y = 0, 0
        if r_eff is None:
            r_eff = self.lens_analysis.half_light_radius_lens(
                kwargs_lens_light,
                center_x=center_x,
                center_y=center_y,
                model_bool_list=lens_light_model_bool_list)
        theta_E = kwargs_lens[0]['theta_E']
        r_ani = aniso_param * r_eff
        sigma2 = self.analytic_kinematics.vel_disp(
            gamma,
            theta_E,
            r_eff,
            r_ani,
            R_slit,
            dR_slit,
            FWHM=psf_fwhm,
            rendering_number=num_evaluate)
        return sigma2

    def velocity_dispersion_numerical(self,
                                      kwargs_lens,
                                      kwargs_lens_light,
                                      kwargs_anisotropy,
                                      kwargs_aperture,
                                      psf_fwhm,
                                      aperture_type,
                                      anisotropy_model,
                                      r_eff=None,
                                      kwargs_numerics={},
                                      MGE_light=False,
                                      MGE_mass=False,
                                      lens_model_kinematics_bool=None,
                                      light_model_kinematics_bool=None,
                                      Hernquist_approx=False):
        """
        Computes the LOS velocity dispersion of the deflector galaxy with arbitrary combinations of light and mass models.
        For a detailed description, visit the description of the Galkin() class.
        Additionaly to executing the Galkin routine, it has an optional Multi-Gaussian-Expansion decomposition of lens
        and light models that do not have a three-dimensional distribution built in, such as Sersic profiles etc.

        The center of all the lens and lens light models that are part of the kinematic estimate must be centered on the
        same point.

        :param kwargs_lens: lens model parameters
        :param kwargs_lens_light: lens light parameters
        :param kwargs_anisotropy: anisotropy parameters (see Galkin module)
        :param kwargs_aperture: aperture parameters (see Galkin module)
        :param psf_fwhm: full width at half maximum of the seeing (Gaussian form)
        :param aperture_type: type of aperture (see Galkin module
        :param anisotropy_model: stellar anisotropy model (see Galkin module)
        :param r_eff: a rough estimate of the half light radius of the lens light in case of computing the MGE of the
         light profile
        :param kwargs_numerics: keyword arguments that contain numerical options (see Galkin module)
        :param MGE_light: bool, if true performs the MGE for the light distribution
        :param MGE_mass: bool, if true performs the MGE for the mass distribution
        :param lens_model_kinematics_bool: bool list of length of the lens model. Only takes a subset of all the models
            as part of the kinematics computation (can be used to ignore substructure, shear etc that do not describe the
            main deflector potential
        :param light_model_kinematics_bool: bool list of length of the light model. Only takes a subset of all the models
            as part of the kinematics computation (can be used to ignore light components that do not describe the main
            deflector
        :return: LOS velocity dispersion [km/s]
        """

        kwargs_cosmo = {
            'D_d': self.lensCosmo.D_d,
            'D_s': self.lensCosmo.D_s,
            'D_ds': self.lensCosmo.D_ds
        }
        mass_profile_list = []
        kwargs_profile = []
        if lens_model_kinematics_bool is None:
            lens_model_kinematics_bool = [True] * len(kwargs_lens)
        for i, lens_model in enumerate(self.kwargs_options['lens_model_list']):
            if lens_model_kinematics_bool[i] is True:
                mass_profile_list.append(lens_model)
                if lens_model in ['INTERPOL', 'INTERPOL_SCLAED']:
                    center_x, center_y = self._lensModelExt.lens_center(
                        kwargs_lens, k=i)
                    kwargs_lens_i = copy.deepcopy(kwargs_lens[i])
                    kwargs_lens_i['grid_interp_x'] -= center_x
                    kwargs_lens_i['grid_interp_y'] -= center_y
                else:
                    kwargs_lens_i = {
                        k: v
                        for k, v in kwargs_lens[i].items()
                        if not k in ['center_x', 'center_y']
                    }
                kwargs_profile.append(kwargs_lens_i)

        if MGE_mass is True:
            lensModel = LensModel(lens_model_list=mass_profile_list)
            massModel = LensModelExtensions(lensModel)
            theta_E = massModel.effective_einstein_radius(kwargs_profile)
            r_array = np.logspace(-4, 2, 200) * theta_E
            mass_r = lensModel.kappa(r_array, np.zeros_like(r_array),
                                     kwargs_profile)
            amps, sigmas, norm = mge.mge_1d(r_array, mass_r, N=20)
            mass_profile_list = ['MULTI_GAUSSIAN_KAPPA']
            kwargs_profile = [{'amp': amps, 'sigma': sigmas}]

        light_profile_list = []
        kwargs_light = []
        if light_model_kinematics_bool is None:
            light_model_kinematics_bool = [True] * len(kwargs_lens_light)
        for i, light_model in enumerate(
                self.kwargs_options['lens_light_model_list']):
            if light_model_kinematics_bool[i]:
                light_profile_list.append(light_model)
                kwargs_lens_light_i = {
                    k: v
                    for k, v in kwargs_lens_light[i].items()
                    if not k in ['center_x', 'center_y']
                }
                if 'q' in kwargs_lens_light_i:
                    kwargs_lens_light_i['q'] = 1
                kwargs_light.append(kwargs_lens_light_i)
        if r_eff is None:
            lensAnalysis = LensAnalysis(
                {'lens_light_model_list': light_profile_list})
            r_eff = lensAnalysis.half_light_radius_lens(
                kwargs_light, model_bool_list=light_model_kinematics_bool)
        if Hernquist_approx is True:
            light_profile_list = ['HERNQUIST']
            kwargs_light = [{'Rs': r_eff, 'amp': 1.}]
        else:
            if MGE_light is True:
                lightModel = LightModel(light_profile_list)
                r_array = np.logspace(-3, 2, 200) * r_eff * 2
                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 = ['MULTI_GAUSSIAN']
                kwargs_light = [{'amp': amps, 'sigma': sigmas}]

        galkin = Galkin(mass_profile_list,
                        light_profile_list,
                        aperture_type=aperture_type,
                        anisotropy_model=anisotropy_model,
                        fwhm=psf_fwhm,
                        kwargs_cosmo=kwargs_cosmo,
                        **kwargs_numerics)
        sigma2 = galkin.vel_disp(kwargs_profile, kwargs_light,
                                 kwargs_anisotropy, kwargs_aperture)
        return sigma2

    def angular_diameter_relations(self, sigma_v_model, sigma_v, kappa_ext,
                                   D_dt_model):
        """

        :return:
        """
        sigma_v2_model = sigma_v_model**2
        Ds_Dds = sigma_v**2 / (1 - kappa_ext) / (
            sigma_v2_model * self.lensCosmo.D_ds / self.lensCosmo.D_s)
        D_d = D_dt_model / (1 + self.lensCosmo.z_lens) / Ds_Dds / (1 -
                                                                   kappa_ext)
        return D_d, Ds_Dds

    def angular_distances(self, sigma_v_measured, time_delay_measured,
                          kappa_ext, sigma_v_modeled, fermat_pot):
        """

        :param sigma_v_measured: velocity dispersion measured [km/s]
        :param time_delay_measured: time delay measured [d]
        :param kappa_ext: external convergence estimated []
        :param sigma_v_modeled: lens model velocity dispersion with default cosmology and without external convergence [km/s]
        :param fermat_pot: fermat potential of lens model, modulo MSD of kappa_ext [arcsec^2]
        :return: D_d and D_d*D_s/D_ds, units in Mpc physical
        """

        Ds_Dds = (sigma_v_measured / float(sigma_v_modeled))**2 / (
            self.lensCosmo.D_ds / self.lensCosmo.D_s) / (1. - kappa_ext)
        DdDs_Dds = 1. / (1 + self.lensCosmo.z_lens) / (1. - kappa_ext) * (
            const.c * time_delay_measured *
            const.day_s) / (fermat_pot * const.arcsec**2) / const.Mpc
        return Ds_Dds, DdDs_Dds