예제 #1
0
    def setup(self):
        self.light_model_list = ['GAUSSIAN', 'MULTI_GAUSSIAN', 'SERSIC', 'SERSIC_ELLIPSE',
                                 'CORE_SERSIC', 'SHAPELETS', 'HERNQUIST',
                                 'HERNQUIST_ELLIPSE', 'PJAFFE', 'PJAFFE_ELLIPSE', 'UNIFORM',
                                 'SHAPELETS', 'SHAPELETS_POLAR_EXP'
                                 ]
        self.kwargs = [
            {'amp': 1., 'sigma_x': 1, 'sigma_y': 1., 'center_x': 0, 'center_y': 0},  # 'GAUSSIAN'
            {'amp': [1., 2], 'sigma': [1, 3], 'center_x': 0, 'center_y': 0},  # 'MULTI_GAUSSIAN'
            {'amp': 1, 'R_sersic': 0.5, 'n_sersic': 1, 'center_x': 0, 'center_y': 0},  # 'SERSIC'
            {'amp': 1, 'R_sersic': 0.5, 'n_sersic': 1, 'e1': 0.1, 'e2': 0.1, 'center_x': 0, 'center_y': 0},  # 'SERSIC_ELLIPSE'
            {'amp': 1, 'R_sersic': 0.5, 'Re': 0.1, 'gamma': 2., 'n_sersic': 1, 'e1': 0.1, 'e2': 0.1, 'center_x': 0, 'center_y': 0},
            # 'CORE_SERSIC'
            {'amp': [1, 1, 1], 'beta': 0.5, 'n_max': 1, 'center_x': 0, 'center_y': 0},  # 'SHAPELETS'
            {'amp': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0},  # 'HERNQUIST'
            {'amp': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0, 'e1': 0.1, 'e2': 0.1},  # 'HERNQUIST_ELLIPSE'
            {'amp': 1, 'Ra': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0},  # 'PJAFFE'
            {'amp': 1, 'Ra': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0, 'e1': 0.1, 'e2': 0.1},  # 'PJAFFE_ELLIPSE'
            {'amp': 1},  # 'UNIFORM'
            {'amp': [1], 'beta': 1, 'n_max': 0, 'center_x': 0, 'center_y': 0},  # 'SHAPELETS'
            {'amp': [1], 'beta': 1, 'n_max': 0, 'center_x': 0, 'center_y': 0},  # 'SHAPELETS_POLAR_EXP'


        ]
        self.kwargs_sigma = [
            {'amp_sigma': 1., 'sigma_x_sigma': 1, 'sigma_y_sigma': 1., 'center_x_sigma': 0, 'center_y_sigma': 0},
            # 'GAUSSIAN'
            {'amp_sigma': [1., 1.], 'sigma_sigma': [1, 1], 'center_x_sigma': 0, 'center_y_sigma': 0},
            # 'MULTI_GAUSSIAN'
            {'amp_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1, 'center_y_sigma': 1},  # 'SERSIC'
            {'amp_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
             'center_y_sigma': 1, 'e1_sigma': 0.1, 'e2_sigma': 0.1},  # 'SERSIC_ELLIPSE'
            {'amp_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
             'center_y_sigma': 1, 'e1_sigma': 0.1, 'e2_sigma': 0.1, 'Re_sigma': 0.01, 'gamma_sigma': 0.1},  # 'CORE_SERSIC'
            {'amp_sigma': [1, 1, 1], 'beta_sigma': 0.1, 'n_max_sigma': 1, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'SHAPELETS'
            {'amp_sigma': 1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'HERNQUIST'
            {'amp_sigma': 1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0, 'e1_sigma': 0.1, 'e2_sigma': 0.1},  # 'HERNQUIST_ELLIPSE'
            {'amp_sigma': 1, 'Ra_sigma': 0.1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'PJAFFE'
            {'amp_sigma': 1, 'Ra_sigma': 0.1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0, 'e1_sigma': 0.1, 'e2_sigma': 0.1},  # 'PJAFFE'
            {'amp_sigma': 0.1},  # 'UNIFORM'

        ]
        self.kwargs_fixed = [{}, {'sigma': [1, 3]}, {}, {}, {}, {'n_max': 1}, {}, {}, {}, {}, {}, {'n_max': 0}, {'n_max': 0}
                             ]
        self.kwargs_fixed_linear = [{}, {'sigma': [1, 3]}, {}, {}, {}, {'n_max': 1}, {}, {}, {}, {}, {}, {}, {}]
        self.kwargs_mean = []
        for i in range(len(self.light_model_list)):
            kwargs_mean_k = self.kwargs[i].copy()
            #kwargs_mean_k.update(self.kwargs_sigma[i])
            self.kwargs_mean.append(kwargs_mean_k)
        self.param = LightParam(light_model_list=self.light_model_list,
                               kwargs_fixed=self.kwargs_fixed, type='source_light', linear_solver=False)
        self.param_linear = LightParam(light_model_list=self.light_model_list,
                                kwargs_fixed=self.kwargs_fixed_linear, type='source_light', linear_solver=True)
        self.param_fixed = LightParam(light_model_list=self.light_model_list,
                                kwargs_fixed=self.kwargs, type='source_light', linear_solver=False)
예제 #2
0
 def test_raise(self):
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['WRONG'], kwargs_fixed=[{}])
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['MULTI_GAUSSIAN'], kwargs_fixed=[{}])
         lighModel.setParams(kwargs_list=[{'amp': 1, 'sigma': 1}])
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['SHAPELETS'], kwargs_fixed=[{}], linear_solver=False)
         lighModel.num_param()
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['SHAPELETS'], kwargs_fixed=[{}], linear_solver=False)
         lighModel.getParams(args=[], i=0)
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['MULTI_GAUSSIAN'], kwargs_fixed=[{}], linear_solver=False)
         lighModel.getParams(args=[1, 1, 1, 1], i=0)
예제 #3
0
 def test_raise(self):
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['WRONG'],
                                kwargs_fixed=[{}])
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['MULTI_GAUSSIAN'],
                                kwargs_fixed=[{}])
         lighModel.setParams(kwargs_list=[{'amp': 1, 'sigma': 1}])
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['SHAPELETS'],
                                kwargs_fixed=[{}],
                                linear_solver=False)
         lighModel.num_param()
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['SHAPELETS'],
                                kwargs_fixed=[{}],
                                linear_solver=False)
         lighModel.getParams(args=[], i=0)
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['MULTI_GAUSSIAN'],
                                kwargs_fixed=[{}],
                                linear_solver=False)
         lighModel.getParams(args=[1, 1, 1, 1], i=0)
     with self.assertRaises(ValueError):
         lighModel = LightParam(light_model_list=['SLIT_STARLETS'],
                                kwargs_fixed=[{}],
                                linear_solver=False)
         lighModel.getParams(args=[1], i=0)
     with self.assertRaises(ValueError):
         # no fixed params provided
         lighModel = LightParam(light_model_list=['SLIT_STARLETS'],
                                kwargs_fixed=[{}],
                                linear_solver=False)
         lighModel.setParams(kwargs_list=[{'amp': np.ones((3 * 20**2))}])
     with self.assertRaises(ValueError):
         # missing fixed params
         lighModel = LightParam(light_model_list=['SLIT_STARLETS'],
                                kwargs_fixed=[{
                                    'n_scales': 3
                                }],
                                linear_solver=False)
         lighModel.setParams(kwargs_list=[{'amp': np.ones((3 * 20**2))}])
     with self.assertRaises(ValueError):
         # missing fixed params
         lighModel = LightParam(light_model_list=['SLIT_STARLETS'],
                                kwargs_fixed=[{
                                    'n_scales': 3
                                }],
                                linear_solver=False)
         lighModel.num_param()
예제 #4
0
    def test_num_param_linear(self):

        kwargs_fixed = [{}, {'sigma': [1, 3]}, {}, {}, {}, {'n_max': 1}, {}, {},
                             {}, {}, {}, {'n_max': 0}, {'n_max': 0}]
        param = LightParam(light_model_list=self.light_model_list,
                                kwargs_fixed=kwargs_fixed, type='source_light', linear_solver=True)

        num = param.num_param_linear()
        assert num == 16
예제 #5
0
    def test_num_param_linear(self):

        kwargs_fixed = [
            {},
            {
                'sigma': [1, 3]
            },
            {},
            {},
            {},
            {
                'n_max': 1
            },
            {},
            {},
            {},
            {},
            {},
            {
                'n_max': 0
            },
            {
                'n_max': 0
            },
            {
                'n_scales': 3,
                'n_pixels': 20**2,
                'scale': 0.05,
                'center_x': 0,
                'center_y': 0
            },
        ]
        param = LightParam(light_model_list=self.light_model_list,
                           kwargs_fixed=kwargs_fixed,
                           type='source_light',
                           linear_solver=True)

        num = param.num_param_linear()
        assert num == (16 + 1200)
예제 #6
0
    def __init__(self,
                 kwargs_model,
                 kwargs_constraints,
                 kwargs_fixed_lens=None,
                 kwargs_fixed_source=None,
                 kwargs_fixed_lens_light=None,
                 kwargs_fixed_ps=None,
                 kwargs_fixed_cosmo=None,
                 kwargs_lower_lens=None,
                 kwargs_lower_source=None,
                 kwargs_lower_lens_light=None,
                 kwargs_lower_ps=None,
                 kwargs_lower_cosmo=None,
                 kwargs_upper_lens=None,
                 kwargs_upper_source=None,
                 kwargs_upper_lens_light=None,
                 kwargs_upper_ps=None,
                 kwargs_upper_cosmo=None,
                 kwargs_lens_init=None,
                 linear_solver=True,
                 fix_lens_solver=False):
        """

        :return:
        """

        self._lens_model_list = kwargs_model.get('lens_model_list', [])
        self._source_light_model_list = kwargs_model.get(
            'source_light_model_list', [])
        self._lens_light_model_list = kwargs_model.get('lens_light_model_list',
                                                       [])
        self._point_source_model_list = kwargs_model.get(
            'point_source_model_list', [])
        self.lensModel = LensModel(
            lens_model_list=self._lens_model_list,
            z_source=kwargs_model.get('z_source', None),
            redshift_list=kwargs_model.get('redshift_list', None),
            multi_plane=kwargs_model.get('multi_plane', False))

        if kwargs_fixed_lens is None:
            kwargs_fixed_lens = [{} for i in range(len(self._lens_model_list))]
        if kwargs_fixed_source is None:
            kwargs_fixed_source = [
                {} for i in range(len(self._source_light_model_list))
            ]
        if kwargs_fixed_lens_light is None:
            kwargs_fixed_lens_light = [
                {} for i in range(len(self._lens_light_model_list))
            ]
        if kwargs_fixed_ps is None:
            kwargs_fixed_ps = [
                {} for i in range(len(self._point_source_model_list))
            ]
        if kwargs_fixed_cosmo is None:
            kwargs_fixed_cosmo = {}

        self._joint_lens_with_lens = kwargs_constraints.get(
            'joint_lens_with_lens', [])
        self._joint_lens_light_with_lens_light = kwargs_constraints.get(
            'joint_lens_light_with_lens_light', [])
        self._joint_source_with_source = kwargs_constraints.get(
            'joint_source_with_source', [])

        self._joint_lens_with_light = kwargs_constraints.get(
            'joint_lens_with_light', [])
        self._joint_source_with_point_source = copy.deepcopy(
            kwargs_constraints.get('joint_source_with_point_source', []))
        for param_list in self._joint_source_with_point_source:
            param_list.append(['center_x', 'center_y'])
        self._joint_lens_light_with_point_source = copy.deepcopy(
            kwargs_constraints.get('joint_lens_light_with_point_source', []))
        for param_list in self._joint_lens_light_with_point_source:
            param_list.append(['center_x', 'center_y'])
        self._fix_foreground_shear = kwargs_constraints.get(
            'fix_foreground_shear', False)
        self._fix_gamma = kwargs_constraints.get('fix_gamma', False)
        self._mass_scaling = kwargs_constraints.get('mass_scaling', False)
        self._mass_scaling_list = kwargs_constraints.get(
            'mass_scaling_list', [False] * len(self._lens_model_list))
        if self._mass_scaling is True:
            self._num_scale_factor = np.max(self._mass_scaling_list) + 1
        else:
            self._num_scale_factor = 0
        num_point_source_list = kwargs_constraints.get(
            'num_point_source_list', [1] * len(self._point_source_model_list))

        # Attention: if joint coordinates with other source profiles, only indicate one as bool
        self._image_plane_source_list = kwargs_constraints.get(
            'image_plane_source_list',
            [False] * len(self._source_light_model_list))

        try:
            self._num_images = num_point_source_list[0]
        except:
            self._num_images = 0
        if fix_lens_solver is True:
            self._solver = False
        else:
            self._solver = kwargs_constraints.get('solver', False)
        if self._solver is True:
            self._solver_type = kwargs_constraints.get('solver_type',
                                                       'PROFILE')
            self._solver_module = Solver(solver_type=self._solver_type,
                                         lensModel=self.lensModel,
                                         num_images=self._num_images)
        else:
            self._solver_type = 'NONE'
        # fix parameters joint within the same model types
        kwargs_fixed_lens_updated = self._add_fixed_lens(
            kwargs_fixed_lens, kwargs_lens_init)
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_lens)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(
            kwargs_fixed_lens_light, self._joint_lens_light_with_lens_light)
        kwargs_fixed_source_updated = self._fix_joint_param(
            kwargs_fixed_source, self._joint_source_with_source)
        kwargs_fixed_ps_updated = copy.deepcopy(kwargs_fixed_ps)
        # fix parameters joint with other model types
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_light)
        kwargs_fixed_source_updated = self._fix_joint_param(
            kwargs_fixed_source_updated, self._joint_source_with_point_source)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(
            kwargs_fixed_lens_light_updated,
            self._joint_lens_light_with_point_source)
        self.lensParams = LensParam(self._lens_model_list,
                                    kwargs_fixed_lens_updated,
                                    num_images=self._num_images,
                                    solver_type=self._solver_type,
                                    kwargs_lower=kwargs_lower_lens,
                                    kwargs_upper=kwargs_upper_lens)
        self.lensLightParams = LightParam(self._lens_light_model_list,
                                          kwargs_fixed_lens_light_updated,
                                          type='lens_light',
                                          linear_solver=linear_solver,
                                          kwargs_lower=kwargs_lower_lens_light,
                                          kwargs_upper=kwargs_upper_lens_light)
        self.souceParams = LightParam(self._source_light_model_list,
                                      kwargs_fixed_source_updated,
                                      type='source_light',
                                      linear_solver=linear_solver,
                                      kwargs_lower=kwargs_lower_source,
                                      kwargs_upper=kwargs_upper_source)
        self.pointSourceParams = PointSourceParam(
            self._point_source_model_list,
            kwargs_fixed_ps_updated,
            num_point_source_list=num_point_source_list,
            linear_solver=linear_solver,
            kwargs_lower=kwargs_lower_ps,
            kwargs_upper=kwargs_upper_ps)
        self.cosmoParams = CosmoParam(kwargs_model.get('cosmo_type', None),
                                      mass_scaling=self._mass_scaling,
                                      kwargs_fixed=kwargs_fixed_cosmo,
                                      num_scale_factor=self._num_scale_factor,
                                      kwargs_lower=kwargs_lower_cosmo,
                                      kwargs_upper=kwargs_upper_cosmo)

        self._lens_light_param_name_list = self.lensLightParams.param_name_list
예제 #7
0
    def __init__(self,
                 kwargs_model,
                 kwargs_constraints,
                 kwargs_fixed_lens,
                 kwargs_fixed_source,
                 kwargs_fixed_lens_light,
                 kwargs_fixed_ps,
                 kwargs_lens_init=None,
                 linear_solver=True):
        """

        :return:
        """
        n = len(kwargs_fixed_source)
        num_point_source_list = kwargs_constraints.get('num_point_source_list',
                                                       [0] * n)
        self._image_plane_source_list = kwargs_constraints.get(
            'image_plane_source_list', [False] * n)
        self._fix_to_point_source_list = kwargs_constraints.get(
            'fix_to_point_source_list', [False] * n)
        self._joint_center_source = kwargs_constraints.get(
            'joint_center_source_light', False)
        self._joint_center_lens_light = kwargs_constraints.get(
            'joint_center_lens_light', False)

        self._lens_model_list = kwargs_model.get('lens_model_list', ['NONE'])
        self.lensModel = LensModel(
            lens_model_list=self._lens_model_list,
            z_source=kwargs_model.get('z_source', None),
            redshift_list=kwargs_model.get('redshift_list', None),
            multi_plane=kwargs_model.get('multi_plane', False))
        try:
            self._num_images = num_point_source_list[0]
        except:
            self._num_images = 0
        self._solver = kwargs_constraints.get('solver', False)

        if self._solver:
            self._solver_type = kwargs_constraints.get('solver_type',
                                                       'PROFILE')
            self._solver_module = Solver(solver_type=self._solver_type,
                                         lensModel=self.lensModel,
                                         num_images=self._num_images)
        else:
            self._solver_type = 'NONE'

        kwargs_fixed_lens = self._add_fixed_lens(kwargs_fixed_lens,
                                                 kwargs_lens_init)
        kwargs_fixed_source = self._add_fixed_source(kwargs_fixed_source)
        kwargs_fixed_lens_light = self._add_fixed_lens_light(
            kwargs_fixed_lens_light)
        kwargs_fixed_ps = kwargs_fixed_ps

        self.lensParams = LensParam(self._lens_model_list,
                                    kwargs_fixed_lens,
                                    num_images=self._num_images,
                                    solver_type=self._solver_type)
        source_light_model_list = kwargs_model.get('source_light_model_list',
                                                   ['NONE'])
        self.souceParams = LightParam(source_light_model_list,
                                      kwargs_fixed_source,
                                      type='source_light',
                                      linear_solver=linear_solver)
        lens_light_model_list = kwargs_model.get('lens_light_model_list',
                                                 ['NONE'])
        self.lensLightParams = LightParam(lens_light_model_list,
                                          kwargs_fixed_lens_light,
                                          type='lens_light',
                                          linear_solver=linear_solver)
        point_source_model_list = kwargs_model.get('point_source_model_list',
                                                   ['NONE'])
        self.pointSourceParams = PointSourceParam(
            point_source_model_list,
            kwargs_fixed_ps,
            num_point_source_list=num_point_source_list,
            linear_solver=linear_solver)
예제 #8
0
    def __init__(self,
                 kwargs_model,
                 kwargs_fixed_lens=None,
                 kwargs_fixed_source=None,
                 kwargs_fixed_lens_light=None,
                 kwargs_fixed_ps=None,
                 kwargs_fixed_special=None,
                 kwargs_fixed_extinction=None,
                 kwargs_lower_lens=None,
                 kwargs_lower_source=None,
                 kwargs_lower_lens_light=None,
                 kwargs_lower_ps=None,
                 kwargs_lower_special=None,
                 kwargs_lower_extinction=None,
                 kwargs_upper_lens=None,
                 kwargs_upper_source=None,
                 kwargs_upper_lens_light=None,
                 kwargs_upper_ps=None,
                 kwargs_upper_special=None,
                 kwargs_upper_extinction=None,
                 kwargs_lens_init=None,
                 linear_solver=True,
                 joint_lens_with_lens=[],
                 joint_lens_light_with_lens_light=[],
                 joint_source_with_source=[],
                 joint_lens_with_light=[],
                 joint_source_with_point_source=[],
                 joint_lens_light_with_point_source=[],
                 joint_extinction_with_lens_light=[],
                 joint_lens_with_source_light=[],
                 mass_scaling_list=None,
                 point_source_offset=False,
                 num_point_source_list=None,
                 image_plane_source_list=None,
                 solver_type='NONE',
                 Ddt_sampling=None,
                 source_size=False,
                 num_tau0=0,
                 lens_redshift_sampling_indexes=None,
                 source_redshift_sampling_indexes=None,
                 source_grid_offset=False,
                 num_shapelet_lens=0,
                 log_sampling_lens=[]):
        """

        :param kwargs_model: keyword arguments to describe all model components used in class_creator.create_class_instances()
        :param kwargs_fixed_lens: fixed parameters for lens model (keyword argument list)
        :param kwargs_fixed_source: fixed parameters for source model (keyword argument list)
        :param kwargs_fixed_lens_light: fixed parameters for lens light model (keyword argument list)
        :param kwargs_fixed_ps: fixed parameters for point source model (keyword argument list)
        :param kwargs_fixed_special: fixed parameters for special model parameters (keyword arguments)
        :param kwargs_fixed_extinction: fixed parameters for extinction model parameters (keyword argument list)
        :param kwargs_lower_lens: lower limits for parameters of lens model (keyword argument list)
        :param kwargs_lower_source: lower limits for parameters of source model (keyword argument list)
        :param kwargs_lower_lens_light: lower limits for parameters of lens light model (keyword argument list)
        :param kwargs_lower_ps: lower limits for parameters of point source model (keyword argument list)
        :param kwargs_lower_special: lower limits for parameters of special model parameters (keyword arguments)
        :param kwargs_lower_extinction: lower limits for parameters of extinction model (keyword argument list)
        :param kwargs_upper_lens: upper limits for parameters of lens model (keyword argument list)
        :param kwargs_upper_source: upper limits for parameters of source model (keyword argument list)
        :param kwargs_upper_lens_light: upper limits for parameters of lens light model (keyword argument list)
        :param kwargs_upper_ps: upper limits for parameters of point source model (keyword argument list)
        :param kwargs_upper_special: upper limits for parameters of special model parameters (keyword arguments)
        :param kwargs_upper_extinction: upper limits for parameters of extinction model (keyword argument list)
        :param kwargs_lens_init: initial guess of lens model keyword arguments (only relevant as the starting point of
         the non-linear solver)
        :param linear_solver: bool, if True fixes the linear amplitude parameters 'amp' (avoid sampling) such that they
         get overwritten by the linear solver solution.
        :param joint_lens_with_lens: list [[i_lens, k_lens, ['param_name1', 'param_name2', ...]], [...], ...],
         joint parameter between two lens models
        :param joint_lens_light_with_lens_light: list [[i_lens_light, k_lens_light, ['param_name1', 'param_name2', ...]], [...], ...],
         joint parameter between two lens light models, the second adopts the value of the first
        :param joint_source_with_source: [[i_source, k_source, ['param_name1', 'param_name2', ...]], [...], ...],
         joint parameter between two source surface brightness models, the second adopts the value of the first
        :param joint_lens_with_light: list [[i_light, k_lens, ['param_name1', 'param_name2', ...]], [...], ...],
         joint parameter between lens model and lens light model
        :param joint_source_with_point_source: list [[i_point_source, k_source], [...], ...],
         joint position parameter between lens model and source light model
        :param joint_lens_light_with_point_source: list [[i_point_source, k_lens_light], [...], ...],
         joint position parameter between lens model and lens light model
        :param joint_extinction_with_lens_light: list [[i_lens_light, k_extinction, ['param_name1', 'param_name2', ...]], [...], ...],
         joint parameters between the lens surface brightness and the optical depth models
        :param joint_lens_with_source_light: [[i_source, k_lens, ['param_name1', 'param_name2', ...]], [...], ...],
         joint parameter between lens model and source light model. Samples light model parameter only.
        :param mass_scaling_list: boolean list of length of lens model list (optional) models with identical integers
         will be scaled with the same additional scaling factor. First integer starts with 1 (not 0)
        :param point_source_offset: bool, if True, adds relative offsets ot the modeled image positions relative to the
         time-delay and lens equation solver
        :param num_point_source_list: list of number of point sources per point source model class
        :param image_plane_source_list: optional, list of booleans for the source_light components.
         If a component is set =True it will parameterized the positions in the image plane and ray-trace the
         parameters back to the source position on the fly during the fitting.
        :param solver_type: string, option for specific solver type
         see detailed instruction of the Solver4Point and Solver2Point classes
        :param Ddt_sampling: bool, if True, samples the time-delay distance D_dt (in units of Mpc)
        :param source_size: bool, if True, samples a source size parameters to be evaluated in the flux ratio likelihood
        :param num_tau0: integer, number of different optical depth re-normalization factors
        :param lens_redshift_sampling_indexes: list of integers corresponding to the lens model components whose redshifts
         are a free parameter (only has an effect in multi-plane lensing) with same indexes indicating joint redshift,
         in ascending numbering e.g. [-1, 0, 0, 1, 0, 2], -1 indicating not sampled fixed indexes
        :param source_redshift_sampling_indexes: list of integers corresponding to the source model components whose redshifts
         are a free parameter (only has an effect in multi-plane lensing) with same indexes indicating joint redshift,
         in ascending numbering e.g. [-1, 0, 0, 1, 0, 2], -1 indicating not sampled fixed indexes. These indexes are
         the sample as for the lens
        :param source_grid_offset: optional, if True when using a pixel-based modelling (e.g. with STARLETS-like profiles),
        adds two additional sampled parameters describing RA/Dec offsets between data coordinate grid and pixelated source plane coordinate grid.
        :param num_shapelet_lens: number of shapelet coefficients in the 'SHAPELETS_CART' or 'SHAPELETS_POLAR' mass profile.
        :param log_sampling_lens: Sample the log10 of the lens model parameters. Format : [[i_lens, ['param_name1', 'param_name2', ...]], [...], ...],
        """

        self._lens_model_list = kwargs_model.get('lens_model_list', [])
        self._lens_redshift_list = kwargs_model.get('lens_redshift_list', None)
        self._source_light_model_list = kwargs_model.get(
            'source_light_model_list', [])
        self._source_redshift_list = kwargs_model.get('source_redshift_list',
                                                      None)
        self._lens_light_model_list = kwargs_model.get('lens_light_model_list',
                                                       [])
        self._point_source_model_list = kwargs_model.get(
            'point_source_model_list', [])
        self._optical_depth_model_list = kwargs_model.get(
            'optical_depth_model_list', [])
        self._kwargs_model = kwargs_model

        # check how many redshifts need to be sampled
        num_z_sampling = 0
        if lens_redshift_sampling_indexes is not None:
            num_z_sampling = int(np.max(lens_redshift_sampling_indexes) + 1)
        if source_redshift_sampling_indexes is not None:
            num_z_source = int(np.max(source_redshift_sampling_indexes) + 1)
            num_z_sampling = max(num_z_sampling, num_z_source)
        self._num_z_sampling, self._lens_redshift_sampling_indexes, self._source_redshift_sampling_indexes = num_z_sampling, lens_redshift_sampling_indexes, source_redshift_sampling_indexes

        self._lens_model_class, self._source_model_class, _, _, _ = class_creator.create_class_instances(
            all_models=True, **kwargs_model)
        self._image2SourceMapping = Image2SourceMapping(
            lensModel=self._lens_model_class,
            sourceModel=self._source_model_class)

        if kwargs_fixed_lens is None:
            kwargs_fixed_lens = [{} for i in range(len(self._lens_model_list))]
        if kwargs_fixed_source is None:
            kwargs_fixed_source = [
                {} for i in range(len(self._source_light_model_list))
            ]
        if kwargs_fixed_lens_light is None:
            kwargs_fixed_lens_light = [
                {} for i in range(len(self._lens_light_model_list))
            ]
        if kwargs_fixed_ps is None:
            kwargs_fixed_ps = [
                {} for i in range(len(self._point_source_model_list))
            ]
        if kwargs_fixed_special is None:
            kwargs_fixed_special = {}

        self._joint_lens_with_lens = joint_lens_with_lens
        self._joint_lens_light_with_lens_light = joint_lens_light_with_lens_light
        self._joint_source_with_source = joint_source_with_source

        self._joint_lens_with_light = joint_lens_with_light
        self._joint_lens_with_source_light = joint_lens_with_source_light
        self._joint_source_with_point_source = copy.deepcopy(
            joint_source_with_point_source)

        # Set up the parameters being sampled in log space in a similar way than the parameters being fixed.
        self._log_sampling_lens = log_sampling_lens
        kwargs_logsampling_lens = [[]
                                   for i in range(len(self._lens_model_list))]
        kwargs_logsampling_lens = self._update_log_sampling(
            kwargs_logsampling_lens, log_sampling_lens)

        for param_list in self._joint_source_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        self._joint_lens_light_with_point_source = copy.deepcopy(
            joint_lens_light_with_point_source)
        for param_list in self._joint_lens_light_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        if mass_scaling_list is None:
            mass_scaling_list = [False] * len(self._lens_model_list)
        self._mass_scaling_list = mass_scaling_list
        if 1 in self._mass_scaling_list:
            self._num_scale_factor = np.max(self._mass_scaling_list)
            self._mass_scaling = True
        else:
            self._num_scale_factor = 0
            self._mass_scaling = False
        self._point_source_offset = point_source_offset
        if num_point_source_list is None:
            num_point_source_list = [1] * len(self._point_source_model_list)

        # Attention: if joint coordinates with other source profiles, only indicate one as bool
        if image_plane_source_list is None:
            image_plane_source_list = [False] * len(
                self._source_light_model_list)
        self._image_plane_source_list = image_plane_source_list

        try:
            self._num_images = num_point_source_list[0]
        except:
            self._num_images = 0
        self._solver_type = solver_type
        if self._solver_type == 'NONE':
            self._solver = False
        else:
            self._solver = True
            self._solver_module = Solver(solver_type=self._solver_type,
                                         lensModel=self._lens_model_class,
                                         num_images=self._num_images)

        source_model_list = self._source_light_model_list
        if len(source_model_list) != 1 or source_model_list[0] not in [
                'SLIT_STARLETS', 'SLIT_STARLETS_GEN2'
        ]:
            # source_grid_offset only defined for source profiles compatible with pixel-based solver
            source_grid_offset = False

        self._joint_extinction_with_lens_light = joint_extinction_with_lens_light
        # fix parameters joint within the same model types
        kwargs_fixed_lens_updated = self._add_fixed_lens(
            kwargs_fixed_lens, kwargs_lens_init)
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_lens)
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_source_light)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(
            kwargs_fixed_lens_light, self._joint_lens_light_with_lens_light)
        kwargs_fixed_source_updated = self._fix_joint_param(
            kwargs_fixed_source, self._joint_source_with_source)
        kwargs_fixed_ps_updated = copy.deepcopy(kwargs_fixed_ps)
        kwargs_fixed_extinction_updated = self._fix_joint_param(
            kwargs_fixed_extinction, self._joint_extinction_with_lens_light)
        # fix parameters joint with other model types
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_light)
        kwargs_fixed_source_updated = self._fix_joint_param(
            kwargs_fixed_source_updated, self._joint_source_with_point_source)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(
            kwargs_fixed_lens_light_updated,
            self._joint_lens_light_with_point_source)
        self.lensParams = LensParam(self._lens_model_list,
                                    kwargs_fixed_lens_updated,
                                    kwargs_logsampling=kwargs_logsampling_lens,
                                    num_images=self._num_images,
                                    solver_type=self._solver_type,
                                    kwargs_lower=kwargs_lower_lens,
                                    kwargs_upper=kwargs_upper_lens,
                                    num_shapelet_lens=num_shapelet_lens)
        self.lensLightParams = LightParam(self._lens_light_model_list,
                                          kwargs_fixed_lens_light_updated,
                                          param_type='lens_light',
                                          linear_solver=linear_solver,
                                          kwargs_lower=kwargs_lower_lens_light,
                                          kwargs_upper=kwargs_upper_lens_light)
        self.souceParams = LightParam(self._source_light_model_list,
                                      kwargs_fixed_source_updated,
                                      param_type='source_light',
                                      linear_solver=linear_solver,
                                      kwargs_lower=kwargs_lower_source,
                                      kwargs_upper=kwargs_upper_source)
        self.pointSourceParams = PointSourceParam(
            self._point_source_model_list,
            kwargs_fixed_ps_updated,
            num_point_source_list=num_point_source_list,
            linear_solver=linear_solver,
            kwargs_lower=kwargs_lower_ps,
            kwargs_upper=kwargs_upper_ps)
        self.extinctionParams = LightParam(
            self._optical_depth_model_list,
            kwargs_fixed_extinction_updated,
            kwargs_lower=kwargs_lower_extinction,
            kwargs_upper=kwargs_upper_extinction,
            linear_solver=False)
        self.specialParams = SpecialParam(
            Ddt_sampling=Ddt_sampling,
            mass_scaling=self._mass_scaling,
            kwargs_fixed=kwargs_fixed_special,
            num_scale_factor=self._num_scale_factor,
            kwargs_lower=kwargs_lower_special,
            kwargs_upper=kwargs_upper_special,
            point_source_offset=self._point_source_offset,
            num_images=self._num_images,
            source_size=source_size,
            num_tau0=num_tau0,
            num_z_sampling=num_z_sampling,
            source_grid_offset=source_grid_offset)
        for lens_source_joint in self._joint_lens_with_source_light:
            i_source = lens_source_joint[0]
            if i_source in self._image_plane_source_list:
                raise ValueError(
                    "linking a source light model with a lens model AND simultaneously parameterizing the"
                    " source position in the image plane is not valid!")
예제 #9
0
    def __init__(self, kwargs_model,
                 kwargs_fixed_lens=None, kwargs_fixed_source=None, kwargs_fixed_lens_light=None, kwargs_fixed_ps=None,
                 kwargs_fixed_special=None, kwargs_fixed_extinction=None,
                 kwargs_lower_lens=None, kwargs_lower_source=None, kwargs_lower_lens_light=None, kwargs_lower_ps=None,
                 kwargs_lower_special=None, kwargs_lower_extinction=None,
                 kwargs_upper_lens=None, kwargs_upper_source=None, kwargs_upper_lens_light=None, kwargs_upper_ps=None,
                 kwargs_upper_special=None, kwargs_upper_extinction=None,
                 kwargs_lens_init=None, linear_solver=True, joint_lens_with_lens=[], joint_lens_light_with_lens_light=[],
                 joint_source_with_source=[], joint_lens_with_light=[], joint_source_with_point_source=[],
                 joint_lens_light_with_point_source=[], joint_extinction_with_lens_light=[],
                 joint_lens_with_source_light=[], mass_scaling_list=None, point_source_offset=False,
                 num_point_source_list=None, image_plane_source_list=None, solver_type='NONE', Ddt_sampling=None,
                 source_size=False, num_tau0=0):
        """

        :return:
        """

        self._lens_model_list = kwargs_model.get('lens_model_list', [])
        self._source_light_model_list = kwargs_model.get('source_light_model_list', [])
        self._lens_light_model_list = kwargs_model.get('lens_light_model_list', [])
        self._point_source_model_list = kwargs_model.get('point_source_model_list', [])
        self._optical_depth_model_list = kwargs_model.get('optical_depth_model_list', [])

        lens_model_class, source_model_class, _, _, _ = class_creator.create_class_instances(all_models=True, **kwargs_model)
        self._image2SourceMapping = Image2SourceMapping(lensModel=lens_model_class, sourceModel=source_model_class)

        if kwargs_fixed_lens is None:
            kwargs_fixed_lens = [{} for i in range(len(self._lens_model_list))]
        if kwargs_fixed_source is None:
            kwargs_fixed_source = [{} for i in range(len(self._source_light_model_list))]
        if kwargs_fixed_lens_light is None:
            kwargs_fixed_lens_light = [{} for i in range(len(self._lens_light_model_list))]
        if kwargs_fixed_ps is None:
            kwargs_fixed_ps = [{} for i in range(len(self._point_source_model_list))]
        if kwargs_fixed_special is None:
            kwargs_fixed_special = {}

        self._joint_lens_with_lens = joint_lens_with_lens
        self._joint_lens_light_with_lens_light = joint_lens_light_with_lens_light
        self._joint_source_with_source = joint_source_with_source

        self._joint_lens_with_light = joint_lens_with_light
        self._joint_lens_with_source_light = joint_lens_with_source_light
        self._joint_source_with_point_source = copy.deepcopy(joint_source_with_point_source)
        for param_list in self._joint_source_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        self._joint_lens_light_with_point_source = copy.deepcopy(joint_lens_light_with_point_source)
        for param_list in self._joint_lens_light_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        if mass_scaling_list is None:
            mass_scaling_list = [False] * len(self._lens_model_list)
        self._mass_scaling_list = mass_scaling_list
        if 1 in self._mass_scaling_list:
            self._num_scale_factor = np.max(self._mass_scaling_list)
            self._mass_scaling = True
        else:
            self._num_scale_factor = 0
            self._mass_scaling = False
        self._point_source_offset = point_source_offset
        if num_point_source_list is None:
            num_point_source_list = [1] * len(self._point_source_model_list)

        # Attention: if joint coordinates with other source profiles, only indicate one as bool
        if image_plane_source_list is None:
            image_plane_source_list = [False] * len(self._source_light_model_list)
        self._image_plane_source_list = image_plane_source_list

        try:
            self._num_images = num_point_source_list[0]
        except:
            self._num_images = 0
        self._solver_type = solver_type
        if self._solver_type == 'NONE':
            self._solver = False
        else:
            self._solver = True
            self._solver_module = Solver(solver_type=self._solver_type, lensModel=lens_model_class,
                                         num_images=self._num_images)

        self._joint_extinction_with_lens_light = joint_extinction_with_lens_light
        # fix parameters joint within the same model types
        kwargs_fixed_lens_updated = self._add_fixed_lens(kwargs_fixed_lens, kwargs_lens_init)
        kwargs_fixed_lens_updated = self._fix_joint_param(kwargs_fixed_lens_updated, self._joint_lens_with_lens)
        kwargs_fixed_lens_updated = self._fix_joint_param(kwargs_fixed_lens_updated, self._joint_lens_with_source_light)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(kwargs_fixed_lens_light, self._joint_lens_light_with_lens_light)
        kwargs_fixed_source_updated = self._fix_joint_param(kwargs_fixed_source, self._joint_source_with_source)
        kwargs_fixed_ps_updated = copy.deepcopy(kwargs_fixed_ps)
        kwargs_fixed_extinction_updated = self._fix_joint_param(kwargs_fixed_extinction, self._joint_extinction_with_lens_light)
        # fix parameters joint with other model types
        kwargs_fixed_lens_updated = self._fix_joint_param(kwargs_fixed_lens_updated, self._joint_lens_with_light)
        kwargs_fixed_source_updated = self._fix_joint_param(kwargs_fixed_source_updated, self._joint_source_with_point_source)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(kwargs_fixed_lens_light_updated,
                                                            self._joint_lens_light_with_point_source)
        self.lensParams = LensParam(self._lens_model_list, kwargs_fixed_lens_updated, num_images=self._num_images,
                                    solver_type=self._solver_type, kwargs_lower=kwargs_lower_lens,
                                    kwargs_upper=kwargs_upper_lens)
        self.lensLightParams = LightParam(self._lens_light_model_list, kwargs_fixed_lens_light_updated, type='lens_light',
                                          linear_solver=linear_solver, kwargs_lower=kwargs_lower_lens_light,
                                          kwargs_upper=kwargs_upper_lens_light)
        self.souceParams = LightParam(self._source_light_model_list, kwargs_fixed_source_updated, type='source_light',
                                      linear_solver=linear_solver, kwargs_lower=kwargs_lower_source,
                                      kwargs_upper=kwargs_upper_source)
        self.pointSourceParams = PointSourceParam(self._point_source_model_list, kwargs_fixed_ps_updated,
                                                  num_point_source_list=num_point_source_list,
                                                  linear_solver=linear_solver, kwargs_lower=kwargs_lower_ps,
                                                  kwargs_upper=kwargs_upper_ps)
        self.extinctionParams = LightParam(self._optical_depth_model_list, kwargs_fixed_extinction_updated,
                                           kwargs_lower=kwargs_lower_extinction, kwargs_upper=kwargs_upper_extinction,
                                           linear_solver=False)
        self.specialParams = SpecialParam(Ddt_sampling=Ddt_sampling, mass_scaling=self._mass_scaling,
                                          kwargs_fixed=kwargs_fixed_special, num_scale_factor=self._num_scale_factor,
                                          kwargs_lower=kwargs_lower_special, kwargs_upper=kwargs_upper_special,
                                          point_source_offset=self._point_source_offset, num_images=self._num_images,
                                          source_size=source_size, num_tau0=num_tau0)
        for lens_source_joint in self._joint_lens_with_source_light:
            i_source = lens_source_joint[0]
            if i_source in self._image_plane_source_list:
                raise ValueError("linking a source light model with a lens model AND simultaneously parameterizing the"
                                 " source position in the image plane is not valid!")
예제 #10
0
    def __init__(self,
                 kwargs_model,
                 kwargs_fixed_lens=None,
                 kwargs_fixed_source=None,
                 kwargs_fixed_lens_light=None,
                 kwargs_fixed_ps=None,
                 kwargs_fixed_special=None,
                 kwargs_fixed_extinction=None,
                 kwargs_lower_lens=None,
                 kwargs_lower_source=None,
                 kwargs_lower_lens_light=None,
                 kwargs_lower_ps=None,
                 kwargs_lower_special=None,
                 kwargs_lower_extinction=None,
                 kwargs_upper_lens=None,
                 kwargs_upper_source=None,
                 kwargs_upper_lens_light=None,
                 kwargs_upper_ps=None,
                 kwargs_upper_special=None,
                 kwargs_upper_extinction=None,
                 kwargs_lens_init=None,
                 linear_solver=True,
                 joint_lens_with_lens=[],
                 joint_lens_light_with_lens_light=[],
                 joint_source_with_source=[],
                 joint_lens_with_light=[],
                 joint_source_with_point_source=[],
                 joint_lens_light_with_point_source=[],
                 joint_extinction_with_lens_light=[],
                 joint_lens_with_source_light=[],
                 mass_scaling_list=None,
                 point_source_offset=False,
                 num_point_source_list=None,
                 image_plane_source_list=None,
                 solver_type='NONE',
                 Ddt_sampling=None,
                 source_size=False,
                 num_tau0=0,
                 lens_redshift_sampling_indexes=None,
                 source_redshift_sampling_indexes=None,
                 source_grid_offset=False,
                 num_shapelet_lens=0):
        """

        :param kwargs_model:
        :param kwargs_fixed_lens:
        :param kwargs_fixed_source:
        :param kwargs_fixed_lens_light:
        :param kwargs_fixed_ps:
        :param kwargs_fixed_special:
        :param kwargs_fixed_extinction:
        :param kwargs_lower_lens:
        :param kwargs_lower_source:
        :param kwargs_lower_lens_light:
        :param kwargs_lower_ps:
        :param kwargs_lower_special:
        :param kwargs_lower_extinction:
        :param kwargs_upper_lens:
        :param kwargs_upper_source:
        :param kwargs_upper_lens_light:
        :param kwargs_upper_ps:
        :param kwargs_upper_special:
        :param kwargs_upper_extinction:
        :param kwargs_lens_init:
        :param linear_solver:
        :param joint_lens_with_lens:
        :param joint_lens_light_with_lens_light:
        :param joint_source_with_source:
        :param joint_lens_with_light:
        :param joint_source_with_point_source:
        :param joint_lens_light_with_point_source:
        :param joint_extinction_with_lens_light:
        :param joint_lens_with_source_light:
        :param mass_scaling_list:
        :param point_source_offset:
        :param num_point_source_list:
        :param image_plane_source_list: optional, list of booleans for the source_light components.
         If a component is set =True it will parameterized the positions in the image plane and ray-trace the
         parameters back to the source position on the fly during the fitting.
        :param solver_type:
        :param Ddt_sampling:
        :param source_size:
        :param num_tau0:
        :param lens_redshift_sampling_indexes: list of integers corresponding to the lens model components whose redshifts
         are a free parameter (only has an effect in multi-plane lensing) with same indexes indicating joint redshift,
         in ascending numbering e.g. [-1, 0, 0, 1, 0, 2], -1 indicating not sampled fixed indexes
        :param source_redshift_sampling_indexes: list of integers corresponding to the source model components whose redshifts
         are a free parameter (only has an effect in multi-plane lensing) with same indexes indicating joint redshift,
         in ascending numbering e.g. [-1, 0, 0, 1, 0, 2], -1 indicating not sampled fixed indexes. These indexes are
         the sample as for the lens
        :param source_grid_offset: optional, if True when using a pixel-based modelling (e.g. with STARLETS-like profiles),
        adds two additional sampled parameters describing RA/Dec offsets between data coordinate grid and pixelated source plane coordinate grid.
        :param num_shapelet_lens: number of shapelet coefficients in the 'SHAPELETS_CART' or 'SHAPELETS_POLAR' mass profile.
        """

        self._lens_model_list = kwargs_model.get('lens_model_list', [])
        self._lens_redshift_list = kwargs_model.get('lens_redshift_list', None)
        self._source_light_model_list = kwargs_model.get(
            'source_light_model_list', [])
        self._source_redshift_list = kwargs_model.get('source_redshift_list',
                                                      None)
        self._lens_light_model_list = kwargs_model.get('lens_light_model_list',
                                                       [])
        self._point_source_model_list = kwargs_model.get(
            'point_source_model_list', [])
        self._optical_depth_model_list = kwargs_model.get(
            'optical_depth_model_list', [])
        self._kwargs_model = kwargs_model

        # check how many redshifts need to be sampled
        num_z_sampling = 0
        if lens_redshift_sampling_indexes is not None:
            num_z_sampling = int(np.max(lens_redshift_sampling_indexes) + 1)
        if source_redshift_sampling_indexes is not None:
            num_z_source = int(np.max(source_redshift_sampling_indexes) + 1)
            num_z_sampling = max(num_z_sampling, num_z_source)
        self._num_z_sampling, self._lens_redshift_sampling_indexes, self._source_redshift_sampling_indexes = num_z_sampling, lens_redshift_sampling_indexes, source_redshift_sampling_indexes

        self._lens_model_class, self._source_model_class, _, _, _ = class_creator.create_class_instances(
            all_models=True, **kwargs_model)
        self._image2SourceMapping = Image2SourceMapping(
            lensModel=self._lens_model_class,
            sourceModel=self._source_model_class)

        if kwargs_fixed_lens is None:
            kwargs_fixed_lens = [{} for i in range(len(self._lens_model_list))]
        if kwargs_fixed_source is None:
            kwargs_fixed_source = [
                {} for i in range(len(self._source_light_model_list))
            ]
        if kwargs_fixed_lens_light is None:
            kwargs_fixed_lens_light = [
                {} for i in range(len(self._lens_light_model_list))
            ]
        if kwargs_fixed_ps is None:
            kwargs_fixed_ps = [
                {} for i in range(len(self._point_source_model_list))
            ]
        if kwargs_fixed_special is None:
            kwargs_fixed_special = {}

        self._joint_lens_with_lens = joint_lens_with_lens
        self._joint_lens_light_with_lens_light = joint_lens_light_with_lens_light
        self._joint_source_with_source = joint_source_with_source

        self._joint_lens_with_light = joint_lens_with_light
        self._joint_lens_with_source_light = joint_lens_with_source_light
        self._joint_source_with_point_source = copy.deepcopy(
            joint_source_with_point_source)
        for param_list in self._joint_source_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        self._joint_lens_light_with_point_source = copy.deepcopy(
            joint_lens_light_with_point_source)
        for param_list in self._joint_lens_light_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        if mass_scaling_list is None:
            mass_scaling_list = [False] * len(self._lens_model_list)
        self._mass_scaling_list = mass_scaling_list
        if 1 in self._mass_scaling_list:
            self._num_scale_factor = np.max(self._mass_scaling_list)
            self._mass_scaling = True
        else:
            self._num_scale_factor = 0
            self._mass_scaling = False
        self._point_source_offset = point_source_offset
        if num_point_source_list is None:
            num_point_source_list = [1] * len(self._point_source_model_list)

        # Attention: if joint coordinates with other source profiles, only indicate one as bool
        if image_plane_source_list is None:
            image_plane_source_list = [False] * len(
                self._source_light_model_list)
        self._image_plane_source_list = image_plane_source_list

        try:
            self._num_images = num_point_source_list[0]
        except:
            self._num_images = 0
        self._solver_type = solver_type
        if self._solver_type == 'NONE':
            self._solver = False
        else:
            self._solver = True
            self._solver_module = Solver(solver_type=self._solver_type,
                                         lensModel=self._lens_model_class,
                                         num_images=self._num_images)

        source_model_list = self._source_light_model_list
        if (len(source_model_list) != 1 or source_model_list[0]
                not in ['SLIT_STARLETS', 'SLIT_STARLETS_GEN2']):
            # source_grid_offset only defined for source profiles compatible with pixel-based solver
            source_grid_offset = False

        self._joint_extinction_with_lens_light = joint_extinction_with_lens_light
        # fix parameters joint within the same model types
        kwargs_fixed_lens_updated = self._add_fixed_lens(
            kwargs_fixed_lens, kwargs_lens_init)
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_lens)
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_source_light)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(
            kwargs_fixed_lens_light, self._joint_lens_light_with_lens_light)
        kwargs_fixed_source_updated = self._fix_joint_param(
            kwargs_fixed_source, self._joint_source_with_source)
        kwargs_fixed_ps_updated = copy.deepcopy(kwargs_fixed_ps)
        kwargs_fixed_extinction_updated = self._fix_joint_param(
            kwargs_fixed_extinction, self._joint_extinction_with_lens_light)
        # fix parameters joint with other model types
        kwargs_fixed_lens_updated = self._fix_joint_param(
            kwargs_fixed_lens_updated, self._joint_lens_with_light)
        kwargs_fixed_source_updated = self._fix_joint_param(
            kwargs_fixed_source_updated, self._joint_source_with_point_source)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(
            kwargs_fixed_lens_light_updated,
            self._joint_lens_light_with_point_source)
        self.lensParams = LensParam(self._lens_model_list,
                                    kwargs_fixed_lens_updated,
                                    num_images=self._num_images,
                                    solver_type=self._solver_type,
                                    kwargs_lower=kwargs_lower_lens,
                                    kwargs_upper=kwargs_upper_lens,
                                    num_shapelet_lens=num_shapelet_lens)
        self.lensLightParams = LightParam(self._lens_light_model_list,
                                          kwargs_fixed_lens_light_updated,
                                          type='lens_light',
                                          linear_solver=linear_solver,
                                          kwargs_lower=kwargs_lower_lens_light,
                                          kwargs_upper=kwargs_upper_lens_light)
        self.souceParams = LightParam(self._source_light_model_list,
                                      kwargs_fixed_source_updated,
                                      type='source_light',
                                      linear_solver=linear_solver,
                                      kwargs_lower=kwargs_lower_source,
                                      kwargs_upper=kwargs_upper_source)
        self.pointSourceParams = PointSourceParam(
            self._point_source_model_list,
            kwargs_fixed_ps_updated,
            num_point_source_list=num_point_source_list,
            linear_solver=linear_solver,
            kwargs_lower=kwargs_lower_ps,
            kwargs_upper=kwargs_upper_ps)
        self.extinctionParams = LightParam(
            self._optical_depth_model_list,
            kwargs_fixed_extinction_updated,
            kwargs_lower=kwargs_lower_extinction,
            kwargs_upper=kwargs_upper_extinction,
            linear_solver=False)
        self.specialParams = SpecialParam(
            Ddt_sampling=Ddt_sampling,
            mass_scaling=self._mass_scaling,
            kwargs_fixed=kwargs_fixed_special,
            num_scale_factor=self._num_scale_factor,
            kwargs_lower=kwargs_lower_special,
            kwargs_upper=kwargs_upper_special,
            point_source_offset=self._point_source_offset,
            num_images=self._num_images,
            source_size=source_size,
            num_tau0=num_tau0,
            num_z_sampling=num_z_sampling,
            source_grid_offset=source_grid_offset)
        for lens_source_joint in self._joint_lens_with_source_light:
            i_source = lens_source_joint[0]
            if i_source in self._image_plane_source_list:
                raise ValueError(
                    "linking a source light model with a lens model AND simultaneously parameterizing the"
                    " source position in the image plane is not valid!")
예제 #11
0
    def __init__(self, kwargs_model,
                 kwargs_fixed_lens=None, kwargs_fixed_source=None, kwargs_fixed_lens_light=None, kwargs_fixed_ps=None,
                 kwargs_fixed_cosmo=None,
                 kwargs_lower_lens=None, kwargs_lower_source=None, kwargs_lower_lens_light=None, kwargs_lower_ps=None,
                 kwargs_lower_cosmo=None,
                 kwargs_upper_lens=None, kwargs_upper_source=None, kwargs_upper_lens_light=None, kwargs_upper_ps=None,
                 kwargs_upper_cosmo=None,
                 kwargs_lens_init=None, linear_solver=True, joint_lens_with_lens=[], joint_lens_light_with_lens_light=[],
                 joint_source_with_source=[], joint_lens_with_light=[], joint_source_with_point_source=[],
                 joint_lens_light_with_point_source=[], mass_scaling_list=None, point_source_offset=False,
                 num_point_source_list=None, image_plane_source_list=None, solver_type='NONE', cosmo_type=None):
        """

        :return:
        """

        self._lens_model_list = kwargs_model.get('lens_model_list', [])
        self._source_light_model_list = kwargs_model.get('source_light_model_list', [])
        self._lens_light_model_list = kwargs_model.get('lens_light_model_list', [])
        self._point_source_model_list = kwargs_model.get('point_source_model_list', [])
        lensModel = LensModel(lens_model_list=self._lens_model_list, z_source=kwargs_model.get('z_source', None),
                              lens_redshift_list=kwargs_model.get('redshift_list', None),
                              multi_plane=kwargs_model.get('multi_plane', False))
        sourceModel = LightModel(light_model_list=self._source_light_model_list,
                                 deflection_scaling_list=kwargs_model.get('source_deflection_scaling_list', None),
                                 source_redshift_list=kwargs_model.get('source_redshift_list', None))
        self._image2SourceMapping = Image2SourceMapping(lensModel=lensModel, sourceModel=sourceModel)

        if kwargs_fixed_lens is None:
            kwargs_fixed_lens = [{} for i in range(len(self._lens_model_list))]
        if kwargs_fixed_source is None:
            kwargs_fixed_source = [{} for i in range(len(self._source_light_model_list))]
        if kwargs_fixed_lens_light is None:
            kwargs_fixed_lens_light = [{} for i in range(len(self._lens_light_model_list))]
        if kwargs_fixed_ps is None:
            kwargs_fixed_ps = [{} for i in range(len(self._point_source_model_list))]
        if kwargs_fixed_cosmo is None:
            kwargs_fixed_cosmo = {}

        self._joint_lens_with_lens = joint_lens_with_lens
        self._joint_lens_light_with_lens_light = joint_lens_light_with_lens_light
        self._joint_source_with_source = joint_source_with_source

        self._joint_lens_with_light = joint_lens_with_light
        self._joint_source_with_point_source = copy.deepcopy(joint_source_with_point_source)
        for param_list in self._joint_source_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        self._joint_lens_light_with_point_source = copy.deepcopy(joint_lens_light_with_point_source)
        for param_list in self._joint_lens_light_with_point_source:
            if len(param_list) == 2:
                param_list.append(['center_x', 'center_y'])
        if mass_scaling_list is None:
            mass_scaling_list = [False] * len(self._lens_model_list)
        self._mass_scaling_list = mass_scaling_list
        if 1 in self._mass_scaling_list:
            self._num_scale_factor = np.max(self._mass_scaling_list)
            self._mass_scaling = True
        else:
            self._num_scale_factor = 0
            self._mass_scaling = False
        self._point_source_offset = point_source_offset
        if num_point_source_list is None:
            num_point_source_list = [1] * len(self._point_source_model_list)

        # Attention: if joint coordinates with other source profiles, only indicate one as bool
        if image_plane_source_list is None:
            image_plane_source_list = [False] * len(self._source_light_model_list)
        self._image_plane_source_list = image_plane_source_list

        try:
            self._num_images = num_point_source_list[0]
        except:
            self._num_images = 0
        self._solver_type = solver_type
        if self._solver_type == 'NONE':
            self._solver = False
        else:
            self._solver = True
            self._solver_module = Solver(solver_type=self._solver_type, lensModel=lensModel,
                                         num_images=self._num_images)

        # fix parameters joint within the same model types
        kwargs_fixed_lens_updated = self._add_fixed_lens(kwargs_fixed_lens, kwargs_lens_init)
        kwargs_fixed_lens_updated = self._fix_joint_param(kwargs_fixed_lens_updated, self._joint_lens_with_lens)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(kwargs_fixed_lens_light, self._joint_lens_light_with_lens_light)
        kwargs_fixed_source_updated = self._fix_joint_param(kwargs_fixed_source, self._joint_source_with_source)
        kwargs_fixed_ps_updated = copy.deepcopy(kwargs_fixed_ps)
        # fix parameters joint with other model types
        kwargs_fixed_lens_updated = self._fix_joint_param(kwargs_fixed_lens_updated, self._joint_lens_with_light)
        kwargs_fixed_source_updated = self._fix_joint_param(kwargs_fixed_source_updated, self._joint_source_with_point_source)
        kwargs_fixed_lens_light_updated = self._fix_joint_param(kwargs_fixed_lens_light_updated,
                                                            self._joint_lens_light_with_point_source)
        self.lensParams = LensParam(self._lens_model_list, kwargs_fixed_lens_updated, num_images=self._num_images,
                                    solver_type=self._solver_type, kwargs_lower=kwargs_lower_lens,
                                    kwargs_upper=kwargs_upper_lens)
        self.lensLightParams = LightParam(self._lens_light_model_list, kwargs_fixed_lens_light_updated, type='lens_light',
                                          linear_solver=linear_solver, kwargs_lower=kwargs_lower_lens_light,
                                          kwargs_upper=kwargs_upper_lens_light)
        self.souceParams = LightParam(self._source_light_model_list, kwargs_fixed_source_updated, type='source_light',
                                      linear_solver=linear_solver, kwargs_lower=kwargs_lower_source,
                                      kwargs_upper=kwargs_upper_source)
        self.pointSourceParams = PointSourceParam(self._point_source_model_list, kwargs_fixed_ps_updated,
                                                  num_point_source_list=num_point_source_list,
                                                  linear_solver=linear_solver, kwargs_lower=kwargs_lower_ps,
                                                  kwargs_upper=kwargs_upper_ps)
        self.cosmoParams = CosmoParam(cosmo_type=cosmo_type, mass_scaling=self._mass_scaling,
                                      kwargs_fixed=kwargs_fixed_cosmo, num_scale_factor=self._num_scale_factor,
                                      kwargs_lower=kwargs_lower_cosmo, kwargs_upper=kwargs_upper_cosmo,
                                      point_source_offset=self._point_source_offset, num_images=self._num_images)
예제 #12
0
    def setup(self):
        self.light_model_list = ['GAUSSIAN', 'MULTI_GAUSSIAN', 'SERSIC', 'SERSIC_ELLIPSE', 'DOUBLE_SERSIC',
                                 'CORE_SERSIC', 'DOUBLE_CORE_SERSIC', 'BULDGE_DISK', 'SHAPELETS', 'HERNQUIST',
                                 'HERNQUIST_ELLIPSE', 'PJAFFE', 'PJAFFE_ELLIPSE', 'UNIFORM', 'NONE'
                                 ]
        self.kwargs = [
            {'amp': 1., 'sigma_x': 1, 'sigma_y': 1., 'center_x': 0, 'center_y': 0},  # 'GAUSSIAN'
            {'amp': [1., 2], 'sigma': [1, 3], 'center_x': 0, 'center_y': 0},  # 'MULTI_GAUSSIAN'
            {'I0_sersic': 1, 'R_sersic': 0.5, 'n_sersic': 1, 'center_x': 0, 'center_y': 0},  # 'SERSIC'
            {'I0_sersic': 1, 'R_sersic': 0.5, 'n_sersic': 1, 'q': 0.8, 'phi_G': 0.5, 'center_x': 0, 'center_y': 0},  # 'SERSIC_ELLIPSE'
            {'I0_sersic': 1, 'R_sersic': 0.5, 'n_sersic': 1, 'q': 0.8, 'phi_G': 0.5, 'center_x': 0, 'center_y': 0,
             'I0_2': 1, 'R_2': 0.05, 'n_2': 2, 'phi_G_2': 0, 'q_2': 1},  # 'DOUBLE_SERSIC'
            {'I0_sersic': 1, 'R_sersic': 0.5, 'Re': 0.1, 'gamma': 2., 'n_sersic': 1, 'q': 0.8, 'phi_G': 0.5, 'center_x': 0, 'center_y': 0},
            # 'CORE_SERSIC'
            {'I0_sersic': 1, 'R_sersic': 0.5, 'Re': 0.1, 'gamma': 2., 'n_sersic': 1, 'q': 0.8, 'phi_G': 0.5,
             'center_x': 0, 'center_y': 0, 'I0_2': 1, 'R_2': 0.05, 'n_2': 2, 'phi_G_2': 0, 'q_2': 1},
            # 'DOUBLE_CORE_SERSIC'
            {'I0_b': 1, 'R_b': 0.1, 'phi_G_b': 0, 'q_b': 1, 'I0_d': 2, 'R_d': 1, 'phi_G_d': 0.5, 'q_d': 0.7, 'center_x': 0, 'center_y': 0},  # BULDGE_DISK
            {'amp': [1, 1, 1], 'beta': 0.5, 'n_max': 1, 'center_x': 0, 'center_y': 0},  # 'SHAPELETS'
            {'sigma0': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0},  # 'HERNQUIST'
            {'sigma0': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0, 'q': 0.8, 'phi_G': 0},  # 'HERNQUIST_ELLIPSE'
            {'sigma0': 1, 'Ra': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0},  # 'PJAFFE'
            {'sigma0': 1, 'Ra': 1, 'Rs': 0.5, 'center_x': 0, 'center_y': 0, 'q': 0.8, 'phi_G': 0},  # 'PJAFFE_ELLIPSE'
            {'mean': 1},  # 'UNIFORM'
            {},  # 'NONE'

        ]
        self.kwargs_sigma = [
            {'amp_sigma': 1., 'sigma_x_sigma': 1, 'sigma_y_sigma': 1., 'center_x_sigma': 0, 'center_y_sigma': 0},
            # 'GAUSSIAN'
            {'amp_sigma': 1., 'sigma_sigma': 1, 'center_x_sigma': 0, 'center_y_sigma': 0},
            # 'MULTI_GAUSSIAN'
            {'I0_sersic_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1, 'center_y_sigma': 1},  # 'SERSIC'
            {'I0_sersic_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
             'center_y_sigma': 1, 'ellipse_sigma': 0.1},  # 'SERSIC_ELLIPSE'
            {'I0_sersic_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
             'center_y_sigma': 1, 'ellipse_sigma': 0.1, 'I0_2_sigma': 1, 'R_2_sigma': 0.05, 'n_2_sigma': 2},  # 'DOUBLE_SERSIC'
            {'I0_sersic_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
             'center_y_sigma': 1, 'ellipse_sigma': 0.1, 'Re_sigma': 0.01, 'gamma_sigma': 0.1},  # 'CORE_SERSIC'
            {'I0_sersic_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
             'center_y_sigma': 1, 'ellipse_sigma': 0.1, 'Re_sigma': 0.01, 'gamma_sigma': 0.1, 'I0_2_sigma': 1, 'R_2_sigma': 0.05, 'n_2_sigma': 2},  # 'DOUBLE_CORE_SERSIC'
            {'I0_b_sigma': 1, 'R_b_sigma': 0.1, 'ellipse_sigma': 0.1, 'I0_d_sigma': 2, 'R_d_sigma': 1,
             'center_x_sigma': 0, 'center_y_sigma': 0},  # BULDGE_DISK
            {'amp_sigma': 1, 'beta_sigma': 0.1, 'n_max_sigma': 1, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'SHAPELETS'
            {'sigma0_sigma': 1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'HERNQUIST'
            {'sigma0_sigma': 1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0, 'ellipse_sigma': 0.1},  # 'HERNQUIST_ELLIPSE'
            {'sigma0_sigma': 1, 'Ra_sigma': 0.1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'PJAFFE'
            {'sigma0_sigma': 1, 'Ra_sigma': 0.1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0, 'ellipse_sigma': 0.1},  # 'PJAFFE'
            {'mean_sigma': 0.1},  # 'UNIFORM'
            {},  # 'NONE'

        ]
        self.kwargs_fixed = [{}, {'sigma': [1, 3]}, {}, {}, {}, {}, {}, {}, {'amp': [1, 1, 1]}, {}, {}, {}, {}, {}, {}
                             ]
        self.kwargs_mean = []
        for i in range(len(self.light_model_list)):
            kwargs_mean_k = self.kwargs[i].copy()
            kwargs_mean_k.update(self.kwargs_sigma[i])
            self.kwargs_mean.append(kwargs_mean_k)
        self.param = LightParam(light_model_list=self.light_model_list,
                               kwargs_fixed=self.kwargs_fixed, type='source_light', linear_solver=False)
        self.param_fixed = LightParam(light_model_list=self.light_model_list,
                                kwargs_fixed=self.kwargs, type='source_light', linear_solver=False)
예제 #13
0
 def setup(self):
     self.light_model_list = [
         'GAUSSIAN',
         'MULTI_GAUSSIAN',
         'SERSIC',
         'SERSIC_ELLIPSE',
         'CORE_SERSIC',
         'SHAPELETS',
         'HERNQUIST',
         'HERNQUIST_ELLIPSE',
         'PJAFFE',
         'PJAFFE_ELLIPSE',
         'UNIFORM',
         'SHAPELETS',
         'SHAPELETS_POLAR_EXP',
         'SLIT_STARLETS',
     ]
     self.kwargs = [
         {
             'amp': 1.,
             'sigma': 1,
             'center_x': 0,
             'center_y': 0
         },  # 'GAUSSIAN'
         {
             'amp': [1., 2],
             'sigma': [1, 3],
             'center_x': 0,
             'center_y': 0
         },  # 'MULTI_GAUSSIAN'
         {
             'amp': 1,
             'R_sersic': 0.5,
             'n_sersic': 1,
             'center_x': 0,
             'center_y': 0
         },  # 'SERSIC'
         {
             'amp': 1,
             'R_sersic': 0.5,
             'n_sersic': 1,
             'e1': 0.1,
             'e2': 0.1,
             'center_x': 0,
             'center_y': 0
         },  # 'SERSIC_ELLIPSE'
         {
             'amp': 1,
             'R_sersic': 0.5,
             'Rb': 0.1,
             'gamma': 2.,
             'n_sersic': 1,
             'e1': 0.1,
             'e2': 0.1,
             'center_x': 0,
             'center_y': 0
         },
         # 'CORE_SERSIC'
         {
             'amp': [1, 1, 1],
             'beta': 0.5,
             'n_max': 1,
             'center_x': 0,
             'center_y': 0
         },  # 'SHAPELETS'
         {
             'amp': 1,
             'Rs': 0.5,
             'center_x': 0,
             'center_y': 0
         },  # 'HERNQUIST'
         {
             'amp': 1,
             'Rs': 0.5,
             'center_x': 0,
             'center_y': 0,
             'e1': 0.1,
             'e2': 0.1
         },  # 'HERNQUIST_ELLIPSE'
         {
             'amp': 1,
             'Ra': 1,
             'Rs': 0.5,
             'center_x': 0,
             'center_y': 0
         },  # 'PJAFFE'
         {
             'amp': 1,
             'Ra': 1,
             'Rs': 0.5,
             'center_x': 0,
             'center_y': 0,
             'e1': 0.1,
             'e2': 0.1
         },  # 'PJAFFE_ELLIPSE'
         {
             'amp': 1
         },  # 'UNIFORM'
         {
             'amp': [1],
             'beta': 1,
             'n_max': 0,
             'center_x': 0,
             'center_y': 0
         },  # 'SHAPELETS'
         {
             'amp': [1],
             'beta': 1,
             'n_max': 0,
             'center_x': 0,
             'center_y': 0
         },  # 'SHAPELETS_POLAR_EXP'
         {
             'amp': np.ones((3 * 20**2, )),
             'n_scales': 3,
             'n_pixels': 20**2,
             'scale': 0.05,
             'center_x': 0,
             'center_y': 0
         },  # 'SLIT_STARLETS'
     ]
     # self.kwargs_sigma = [
     #     {'amp_sigma': 1., 'sigma_sigma': 1, 'center_x_sigma': 0, 'center_y_sigma': 0},
     #     # 'GAUSSIAN'
     #     {'amp_sigma': [1., 1.], 'sigma_sigma': [1, 1], 'center_x_sigma': 0, 'center_y_sigma': 0},
     #     # 'MULTI_GAUSSIAN'
     #     {'amp_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1, 'center_y_sigma': 1},  # 'SERSIC'
     #     {'amp_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
     #      'center_y_sigma': 1, 'e1_sigma': 0.1, 'e2_sigma': 0.1},  # 'SERSIC_ELLIPSE'
     #     {'amp_sigma': 1, 'R_sersic_sigma': 0.5, 'n_sersic_sigma': 1, 'center_x_sigma': 1,
     #      'center_y_sigma': 1, 'e1_sigma': 0.1, 'e2_sigma': 0.1, 'Re_sigma': 0.01, 'gamma_sigma': 0.1},  # 'CORE_SERSIC'
     #     {'amp_sigma': [1, 1, 1], 'beta_sigma': 0.1, 'n_max_sigma': 1, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'SHAPELETS'
     #     {'amp_sigma': 1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'HERNQUIST'
     #     {'amp_sigma': 1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0, 'e1_sigma': 0.1, 'e2_sigma': 0.1},  # 'HERNQUIST_ELLIPSE'
     #     {'amp_sigma': 1, 'Ra_sigma': 0.1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0},  # 'PJAFFE'
     #     {'amp_sigma': 1, 'Ra_sigma': 0.1, 'Rs_sigma': 0.5, 'center_x_sigma': 0, 'center_y_sigma': 0, 'e1_sigma': 0.1, 'e2_sigma': 0.1},  # 'PJAFFE'
     #     {'amp_sigma': 0.1},  # 'UNIFORM'
     # ]
     self.kwargs_fixed = [
         {},
         {
             'sigma': [1, 3]
         },
         {},
         {},
         {},
         {
             'n_max': 1
         },
         {},
         {},
         {},
         {},
         {},
         {
             'n_max': 0
         },
         {
             'n_max': 0
         },
         {
             'n_scales': 3,
             'n_pixels': 20**2,
             'scale': 0.05,
             'center_x': 0,
             'center_y': 0
         },
     ]
     self.kwargs_fixed_linear = [
         {},
         {
             'sigma': [1, 3]
         },
         {},
         {},
         {},
         {
             'n_max': 1
         },
         {},
         {},
         {},
         {},
         {},
         {},
         {},
         {
             'n_scales': 3,
             'n_pixels': 20**2,
             'scale': 0.05,
             'center_x': 0,
             'center_y': 0
         },
     ]
     # self.kwargs_mean = []
     # for i in range(len(self.light_model_list)):
     #     kwargs_mean_k = self.kwargs[i].copy()
     #     #kwargs_mean_k.update(self.kwargs_sigma[i])
     #     self.kwargs_mean.append(kwargs_mean_k)
     self.param = LightParam(light_model_list=self.light_model_list,
                             kwargs_fixed=self.kwargs_fixed,
                             param_type='source_light',
                             linear_solver=False)
     self.param_linear = LightParam(light_model_list=self.light_model_list,
                                    kwargs_fixed=self.kwargs_fixed_linear,
                                    param_type='source_light',
                                    linear_solver=True)
     self.param_fixed = LightParam(light_model_list=self.light_model_list,
                                   kwargs_fixed=self.kwargs,
                                   param_type='source_light',
                                   linear_solver=False)