Exemplo n.º 1
0
 def test_convergence2surface_brightness(self):
     from lenstronomy.LightModel.Profiles.nie import NIE as NIE_Light
     nie_light = NIE_Light()
     kwargs = {'e1': 0.3, 'e2': -0.05, 's_scale': 0.5}
     x, y = util.make_grid(numPix=10, deltapix=0.1)
     f_xx, f_yy, f_xy = self.nie.hessian(x, y, theta_E=1, **kwargs)
     kappa = 1/2. * (f_xx + f_yy)
     flux = nie_light.function(x, y, amp=1, **kwargs)
     npt.assert_almost_equal(kappa/np.sum(kappa), flux/np.sum(flux), decimal=5)
Exemplo n.º 2
0
class Chameleon(object):
    """
    class of the Chameleon model (See Suyu+2014) an elliptical truncated double isothermal profile

    """
    param_names = ['amp', 'w_c', 'w_t', 'e1', 'e2', 'center_x', 'center_y']
    lower_limit_default = {
        'amp': 0,
        'w_c': 0,
        'w_t': 0,
        'e1': -0.5,
        'e2': -0.5,
        'center_x': -100,
        'center_y': -100
    }
    upper_limit_default = {
        'amp': 100,
        'w_c': 100,
        'w_t': 100,
        'e1': 0.5,
        'e2': 0.5,
        'center_x': 100,
        'center_y': 100
    }

    def __init__(self):
        self.nie = NIE()
        self._chameleonLens = ChameleonLens()

    def function(self, x, y, amp, w_c, w_t, e1, e2, center_x=0, center_y=0):
        """

        :param x: ra-coordinate
        :param y: dec-coordinate
        :param amp: amplitude of first power-law flux
        :param flux_ratio: ratio of amplitudes of first to second power-law profile
        :param gamma1: power-law slope
        :param gamma2: power-law slope
        :param e1: ellipticity parameter
        :param e2: ellipticity parameter
        :param center_x: center
        :param center_y: center
        :return: flux of chameleon profile
        """
        amp_new, w_c, w_t = self._chameleonLens._theta_convert(amp, w_c, w_t)
        phi_G, q = param_util.ellipticity2phi_q(e1, e2)
        s_scale_1 = np.sqrt(4 * w_c**2 / (1. + q)**2)
        s_scale_2 = np.sqrt(4 * w_t**2 / (1. + q)**2)
        flux1 = self.nie.function(x, y, 1, e1, e2, s_scale_1, center_x,
                                  center_y)
        flux2 = self.nie.function(x, y, 1, e1, e2, s_scale_2, center_x,
                                  center_y)
        flux = amp_new / (1. + q) * (flux1 - flux2)
        return flux
Exemplo n.º 3
0
class Chameleon(object):
    """
    class of the Chameleon model (See Dutton+ 2011, Suyu+2014) an elliptical truncated double isothermal profile

    """
    param_names = ['amp', 'w_c', 'w_t', 'e1', 'e2', 'center_x', 'center_y']
    lower_limit_default = {'amp': 0, 'w_c': 0, 'w_t': 0, 'e1': -0.5, 'e2': -0.5, 'center_x': -100, 'center_y': -100}
    upper_limit_default = {'amp': 100, 'w_c': 100, 'w_t': 100, 'e1': 0.5, 'e2': 0.5, 'center_x': 100, 'center_y': 100}

    def __init__(self):
        self.nie = NIE()
        self._chameleonLens = ChameleonLens()

    def function(self, x, y, amp, w_c, w_t, e1, e2, center_x=0, center_y=0):
        """

        :param x: ra-coordinate
        :param y: dec-coordinate
        :param w_c:
        :param w_t:
        :param amp: amplitude of first power-law flux
        :param e1: eccentricity parameter
        :param e2: eccentricity parameter
        :param center_x: center
        :param center_y: center
        :return: flux of chameleon profile
        """
        amp_new, w_c, w_t, s_scale_1, s_scale_2 = self._chameleonLens.param_convert(amp, w_c, w_t, e1, e2)
        flux1 = self.nie.function(x, y, 1, e1, e2, s_scale_1, center_x, center_y)
        flux2 = self.nie.function(x, y, 1, e1, e2, s_scale_2, center_x, center_y)
        flux = amp_new * (flux1 - flux2)
        return flux

    def light_3d(self, r, amp, w_c, w_t, e1, e2, center_x=0, center_y=0):
        """

        :param r: 3d radius
        :param w_c:
        :param w_t:
        :param amp: amplitude of first power-law flux
        :param e1: eccentricity parameter
        :param e2: eccentricity parameter
        :param center_x: center
        :param center_y: center
        :return: 3d flux of chameleon profile at radius r
        """
        amp_new, w_c, w_t, s_scale_1, s_scale_2 = self._chameleonLens.param_convert(amp, w_c, w_t, e1, e2)
        flux1 = self.nie.light_3d(r, 1, e1, e2, s_scale_1, center_x, center_y)
        flux2 = self.nie.light_3d(r, 1, e1, e2, s_scale_2, center_x, center_y)
        flux = amp_new * (flux1 - flux2)
        return flux
Exemplo n.º 4
0
    def test_function(self):
        """

        :return:
        """
        lens = NIE_lens()
        light = NIE_light()

        x = np.linspace(0.1, 10, 10)
        e1, e2 = 0.1, 0
        s = 0.2
        kwargs_light = {'amp': 1., 'e1': e1, 'e2': e2, 's_scale': s}
        kwargs_lens = {'theta_E': 1., 'e1': e1, 'e2': e2, 's_scale': s}
        flux = light.function(x=x, y=1., **kwargs_light)
        f_xx, f_yy, f_xy = lens.hessian(x=x, y=1., **kwargs_lens)
        kappa = 1/2. * (f_xx + f_yy)
        npt.assert_almost_equal(flux/flux[-1], kappa/kappa[-1], decimal=4)
Exemplo n.º 5
0
 def __init__(self, light_model_list, smoothing=0.0000001):
     self.profile_type_list = light_model_list
     self.func_list = []
     for profile_type in light_model_list:
         valid = True
         if profile_type == 'GAUSSIAN':
             from lenstronomy.LightModel.Profiles.gaussian import Gaussian
             self.func_list.append(Gaussian())
         elif profile_type == 'GAUSSIAN_ELLIPSE':
             from lenstronomy.LightModel.Profiles.gaussian import GaussianEllipse
             self.func_list.append(GaussianEllipse())
         elif profile_type == 'MULTI_GAUSSIAN':
             from lenstronomy.LightModel.Profiles.gaussian import MultiGaussian
             self.func_list.append(MultiGaussian())
         elif profile_type == 'MULTI_GAUSSIAN_ELLIPSE':
             from lenstronomy.LightModel.Profiles.gaussian import MultiGaussianEllipse
             self.func_list.append(MultiGaussianEllipse())
         elif profile_type == 'SERSIC':
             from lenstronomy.LightModel.Profiles.sersic import Sersic
             self.func_list.append(Sersic(smoothing=smoothing))
         elif profile_type == 'SERSIC_ELLIPSE':
             from lenstronomy.LightModel.Profiles.sersic import Sersic_elliptic
             self.func_list.append(Sersic_elliptic(smoothing=smoothing))
         elif profile_type == 'CORE_SERSIC':
             from lenstronomy.LightModel.Profiles.sersic import CoreSersic
             self.func_list.append(CoreSersic(smoothing=smoothing))
         elif profile_type == 'SHAPELETS':
             from lenstronomy.LightModel.Profiles.shapelets import ShapeletSet
             self.func_list.append(ShapeletSet())
         elif profile_type == 'HERNQUIST':
             from lenstronomy.LightModel.Profiles.hernquist import Hernquist
             self.func_list.append(Hernquist())
         elif profile_type == 'HERNQUIST_ELLIPSE':
             from lenstronomy.LightModel.Profiles.hernquist import Hernquist_Ellipse
             self.func_list.append(Hernquist_Ellipse())
         elif profile_type == 'PJAFFE':
             from lenstronomy.LightModel.Profiles.p_jaffe import PJaffe
             self.func_list.append(PJaffe())
         elif profile_type == 'PJAFFE_ELLIPSE':
             from lenstronomy.LightModel.Profiles.p_jaffe import PJaffe_Ellipse
             self.func_list.append(PJaffe_Ellipse())
         elif profile_type == 'UNIFORM':
             from lenstronomy.LightModel.Profiles.uniform import Uniform
             self.func_list.append(Uniform())
         elif profile_type == 'POWER_LAW':
             from lenstronomy.LightModel.Profiles.power_law import PowerLaw
             self.func_list.append(PowerLaw())
         elif profile_type == 'NIE':
             from lenstronomy.LightModel.Profiles.nie import NIE
             self.func_list.append(NIE())
         elif profile_type == 'CHAMELEON':
             from lenstronomy.LightModel.Profiles.chameleon import Chameleon
             self.func_list.append(Chameleon())
         elif profile_type == 'DOUBLE_CHAMELEON':
             from lenstronomy.LightModel.Profiles.chameleon import DoubleChameleon
             self.func_list.append(DoubleChameleon())
         else:
             raise ValueError('Warning! No light model of type', profile_type, ' found!')
Exemplo n.º 6
0
    def test_function(self):
        """

        :return:
        """
        chameleon = Chameleon()
        nie = NIE()

        x = np.linspace(0.1, 10, 10)
        w_c, w_t = 0.5, 1.
        phi_G, q = 0.3, 0.8
        e1, e2 = param_util.phi_q2_ellipticity(phi_G, q)
        kwargs_light = {'amp': 1., 'w_c': .5, 'w_t': 1., 'e1': e1, 'e2': e2}
        amp_new, w_c, w_t, s_scale_1, s_scale_2 = chameleon._chameleonLens.param_convert(
            1, w_c, w_t, e1, e2)
        kwargs_1 = {'amp': amp_new, 's_scale': s_scale_1, 'e1': e1, 'e2': e2}
        kwargs_2 = {'amp': amp_new, 's_scale': s_scale_2, 'e1': e1, 'e2': e2}
        flux = chameleon.function(x=x, y=1., **kwargs_light)
        flux1 = nie.function(x=x, y=1., **kwargs_1)
        flux2 = nie.function(x=x, y=1., **kwargs_2)
        npt.assert_almost_equal(flux, (flux1 - flux2) / (1. + q), decimal=5)
Exemplo n.º 7
0
    def __init__(self, light_model_list, smoothing=0.001):
        """

        :param light_model_list: list of light models
        :param smoothing: smoothing factor for certain models (deprecated)
        """
        self.profile_type_list = light_model_list
        self.func_list = []
        for profile_type in light_model_list:
            if profile_type == 'GAUSSIAN':
                from lenstronomy.LightModel.Profiles.gaussian import Gaussian
                self.func_list.append(Gaussian())
            elif profile_type == 'GAUSSIAN_ELLIPSE':
                from lenstronomy.LightModel.Profiles.gaussian import GaussianEllipse
                self.func_list.append(GaussianEllipse())
            elif profile_type == 'ELLIPSOID':
                from lenstronomy.LightModel.Profiles.ellipsoid import Ellipsoid
                self.func_list.append(Ellipsoid())
            elif profile_type == 'MULTI_GAUSSIAN':
                from lenstronomy.LightModel.Profiles.gaussian import MultiGaussian
                self.func_list.append(MultiGaussian())
            elif profile_type == 'MULTI_GAUSSIAN_ELLIPSE':
                from lenstronomy.LightModel.Profiles.gaussian import MultiGaussianEllipse
                self.func_list.append(MultiGaussianEllipse())
            elif profile_type == 'SERSIC':
                from lenstronomy.LightModel.Profiles.sersic import Sersic
                self.func_list.append(Sersic(smoothing=smoothing))
            elif profile_type == 'SERSIC_ELLIPSE':
                from lenstronomy.LightModel.Profiles.sersic import SersicElliptic
                self.func_list.append(
                    SersicElliptic(smoothing=smoothing,
                                   sersic_major_axis=sersic_major_axis_conf))
            elif profile_type == 'CORE_SERSIC':
                from lenstronomy.LightModel.Profiles.sersic import CoreSersic
                self.func_list.append(CoreSersic(smoothing=smoothing))
            elif profile_type == 'SHAPELETS':
                from lenstronomy.LightModel.Profiles.shapelets import ShapeletSet
                self.func_list.append(ShapeletSet())
            elif profile_type == 'SHAPELETS_POLAR':
                from lenstronomy.LightModel.Profiles.shapelets_polar import ShapeletSetPolar
                self.func_list.append(ShapeletSetPolar(exponential=False))
            elif profile_type == 'SHAPELETS_POLAR_EXP':
                from lenstronomy.LightModel.Profiles.shapelets_polar import ShapeletSetPolar
                self.func_list.append(ShapeletSetPolar(exponential=True))
            elif profile_type == 'HERNQUIST':
                from lenstronomy.LightModel.Profiles.hernquist import Hernquist
                self.func_list.append(Hernquist())
            elif profile_type == 'HERNQUIST_ELLIPSE':
                from lenstronomy.LightModel.Profiles.hernquist import HernquistEllipse
                self.func_list.append(HernquistEllipse())
            elif profile_type == 'PJAFFE':
                from lenstronomy.LightModel.Profiles.p_jaffe import PJaffe
                self.func_list.append(PJaffe())
            elif profile_type == 'PJAFFE_ELLIPSE':
                from lenstronomy.LightModel.Profiles.p_jaffe import PJaffe_Ellipse
                self.func_list.append(PJaffe_Ellipse())
            elif profile_type == 'UNIFORM':
                from lenstronomy.LightModel.Profiles.uniform import Uniform
                self.func_list.append(Uniform())
            elif profile_type == 'POWER_LAW':
                from lenstronomy.LightModel.Profiles.power_law import PowerLaw
                self.func_list.append(PowerLaw())
            elif profile_type == 'NIE':
                from lenstronomy.LightModel.Profiles.nie import NIE
                self.func_list.append(NIE())
            elif profile_type == 'CHAMELEON':
                from lenstronomy.LightModel.Profiles.chameleon import Chameleon
                self.func_list.append(Chameleon())
            elif profile_type == 'DOUBLE_CHAMELEON':
                from lenstronomy.LightModel.Profiles.chameleon import DoubleChameleon
                self.func_list.append(DoubleChameleon())
            elif profile_type == 'TRIPLE_CHAMELEON':
                from lenstronomy.LightModel.Profiles.chameleon import TripleChameleon
                self.func_list.append(TripleChameleon())
            elif profile_type == 'INTERPOL':
                from lenstronomy.LightModel.Profiles.interpolation import Interpol
                self.func_list.append(Interpol())
            elif profile_type == 'SLIT_STARLETS':
                from lenstronomy.LightModel.Profiles.starlets import SLIT_Starlets
                self.func_list.append(
                    SLIT_Starlets(fast_inverse=True, second_gen=False))
            elif profile_type == 'SLIT_STARLETS_GEN2':
                from lenstronomy.LightModel.Profiles.starlets import SLIT_Starlets
                self.func_list.append(SLIT_Starlets(second_gen=True))
            else:
                raise ValueError(
                    'No light model of type %s found! Supported are the following models: %s'
                    % (profile_type, _MODELS_SUPPORTED))
        self._num_func = len(self.func_list)
Exemplo n.º 8
0
 def __init__(self):
     self.nie = NIE()
     self._chameleonLens = ChameleonLens()
Exemplo n.º 9
0
    def __init__(self,
                 light_model_list,
                 deflection_scaling_list=None,
                 source_redshift_list=None,
                 smoothing=0.0000001):
        """

        :param light_model_list: list of light models
        :param deflection_scaling_list: list of floats, rescales the original reduced deflection angles from the lens model
        to enable different models to be placed at different optical (redshift) distances. None means they are all
        :param source_redshift_list: list of redshifts of the model components
        :param smoothing: smoothing factor for certain models (deprecated)
        """
        self.profile_type_list = light_model_list
        self.deflection_scaling_list = deflection_scaling_list
        self.redshift_list = source_redshift_list
        self.func_list = []
        for profile_type in light_model_list:
            if profile_type == 'GAUSSIAN':
                from lenstronomy.LightModel.Profiles.gaussian import Gaussian
                self.func_list.append(Gaussian())
            elif profile_type == 'GAUSSIAN_ELLIPSE':
                from lenstronomy.LightModel.Profiles.gaussian import GaussianEllipse
                self.func_list.append(GaussianEllipse())
            elif profile_type == 'MULTI_GAUSSIAN':
                from lenstronomy.LightModel.Profiles.gaussian import MultiGaussian
                self.func_list.append(MultiGaussian())
            elif profile_type == 'MULTI_GAUSSIAN_ELLIPSE':
                from lenstronomy.LightModel.Profiles.gaussian import MultiGaussianEllipse
                self.func_list.append(MultiGaussianEllipse())
            elif profile_type == 'SERSIC':
                from lenstronomy.LightModel.Profiles.sersic import Sersic
                self.func_list.append(Sersic(smoothing=smoothing))
            elif profile_type == 'SERSIC_ELLIPSE':
                from lenstronomy.LightModel.Profiles.sersic import SersicElliptic
                self.func_list.append(SersicElliptic(smoothing=smoothing))
            elif profile_type == 'CORE_SERSIC':
                from lenstronomy.LightModel.Profiles.sersic import CoreSersic
                self.func_list.append(CoreSersic(smoothing=smoothing))
            elif profile_type == 'SHAPELETS':
                from lenstronomy.LightModel.Profiles.shapelets import ShapeletSet
                self.func_list.append(ShapeletSet())
            elif profile_type == 'HERNQUIST':
                from lenstronomy.LightModel.Profiles.hernquist import Hernquist
                self.func_list.append(Hernquist())
            elif profile_type == 'HERNQUIST_ELLIPSE':
                from lenstronomy.LightModel.Profiles.hernquist import HernquistEllipse
                self.func_list.append(HernquistEllipse())
            elif profile_type == 'PJAFFE':
                from lenstronomy.LightModel.Profiles.p_jaffe import PJaffe
                self.func_list.append(PJaffe())
            elif profile_type == 'PJAFFE_ELLIPSE':
                from lenstronomy.LightModel.Profiles.p_jaffe import PJaffe_Ellipse
                self.func_list.append(PJaffe_Ellipse())
            elif profile_type == 'UNIFORM':
                from lenstronomy.LightModel.Profiles.uniform import Uniform
                self.func_list.append(Uniform())
            elif profile_type == 'POWER_LAW':
                from lenstronomy.LightModel.Profiles.power_law import PowerLaw
                self.func_list.append(PowerLaw())
            elif profile_type == 'NIE':
                from lenstronomy.LightModel.Profiles.nie import NIE
                self.func_list.append(NIE())
            elif profile_type == 'CHAMELEON':
                from lenstronomy.LightModel.Profiles.chameleon import Chameleon
                self.func_list.append(Chameleon())
            elif profile_type == 'DOUBLE_CHAMELEON':
                from lenstronomy.LightModel.Profiles.chameleon import DoubleChameleon
                self.func_list.append(DoubleChameleon())
            elif profile_type == 'INTERPOL':
                from lenstronomy.LightModel.Profiles.interpolation import Interpol
                self.func_list.append(Interpol())
            else:
                raise ValueError('Warning! No light model of type',
                                 profile_type, ' found!')