def _extract_array(self, kwargs_list): """ inverse of _update_kwargs :param kwargs_list: :return: """ lens_model = self._lens_mode_list[0] if self._solver_type == 'CENTER': center_x = kwargs_list[0]['center_x'] center_y = kwargs_list[0]['center_y'] x = [center_x, center_y] elif self._solver_type == 'ELLIPSE': e1 = kwargs_list[0]['e1'] e2 = kwargs_list[0]['e2'] x = [e1, e2] elif self._solver_type == 'SHAPELETS': coeffs = list(kwargs_list[0]['coeffs']) [c10, c01] = coeffs[1: 3] x = [c10, c01] elif self._solver_type == 'THETA_E_PHI': theta_E = kwargs_list[0]['theta_E'] gamma1 = kwargs_list[1]['gamma1'] gamma2 = kwargs_list[1]['gamma2'] phi_ext, gamma_ext = param_util.shear_cartesian2polar(gamma1, gamma2) x = [theta_E, phi_ext] elif self._solver_type == 'THETA_E_ELLIPSE': theta_E = kwargs_list[0]['theta_E'] e1 = kwargs_list[0]['e1'] e2 = kwargs_list[0]['e2'] phi_ext, gamma_ext = param_util.shear_cartesian2polar(e1, e2) x = [theta_E, phi_ext] else: raise ValueError("Solver type %s not supported for 2-point solver!" % self._solver_type) return x
def test_phi_gamma_ellipticity_2(): e1, e2 = -0.04, -0.01 phi, gamma = param_util.shear_cartesian2polar(e1, e2) e1_out, e2_out = param_util.shear_polar2cartesian(phi, gamma) npt.assert_almost_equal(e1, e1_out, decimal=10) npt.assert_almost_equal(e2, e2_out, decimal=10)
def args_to_kwargs(self, args): (thetaE, center_x, center_y, e1, e2, g1, g2) = args gamma = self.kwargs_lens[0]['gamma'] kwargs_epl = { 'theta_E': thetaE, 'center_x': center_x, 'center_y': center_y, 'e1': e1, 'e2': e2, 'gamma': gamma } phi, _ = shear_cartesian2polar(g1, g2) gamma1, gamma2 = shear_polar2cartesian(phi, self._shear_strength) kwargs_shear = {'gamma1': gamma1, 'gamma2': gamma2} self.kwargs_lens[0] = kwargs_epl self.kwargs_lens[1] = kwargs_shear self.kwargs_lens[2]['center_x'] = center_x self.kwargs_lens[2]['center_y'] = center_y phi, _ = ellipticity2phi_q(e1, e2) self.kwargs_lens[2]['phi_m'] = phi return self.kwargs_lens
def args_to_kwargs(self, args): """ :param args: array of lens model parameters :return: dictionary of lens model parameters with fixed shear = shear_strength """ (thetaE, center_x, center_y, e1, e2, g1, g2) = args gamma = self.kwargs_lens[0]['gamma'] kwargs_epl = { 'theta_E': thetaE, 'center_x': center_x, 'center_y': center_y, 'e1': e1, 'e2': e2, 'gamma': gamma } phi, _ = shear_cartesian2polar(g1, g2) gamma1, gamma2 = shear_polar2cartesian(phi, self._shear_strength) kwargs_shear = {'gamma1': gamma1, 'gamma2': gamma2} self.kwargs_lens[0] = kwargs_epl self.kwargs_lens[1] = kwargs_shear return self.kwargs_lens
def test_phi_gamma_ellipticity(): phi = -1. gamma = 0.1 e1, e2 = param_util.shear_polar2cartesian(phi, gamma) print(e1, e2, 'e1, e2') phi_out, gamma_out = param_util.shear_cartesian2polar(e1, e2) assert phi == phi_out assert gamma == gamma_out
def test_phi_gamma_ellipticity(): phi = -1. gamma = 0.1 e1, e2 = param_util.shear_polar2cartesian(phi, gamma) print(e1, e2, 'e1, e2') phi_out, gamma_out = param_util.shear_cartesian2polar(e1, e2) npt.assert_almost_equal(phi_out, phi, decimal=8) npt.assert_almost_equal(gamma_out, gamma_out, decimal=8)
def _new_shear(self, start_e1, start_e2, delta_phi, delta_gamma): phi_start, gamma_start = shear_cartesian2polar(start_e1, start_e2) phi_min, phi_max = phi_start + delta_phi, phi_start - delta_phi gamma_min, gamma_max = max(0.0001, gamma_start - delta_gamma), gamma_start + delta_gamma e1_min, e2_min = shear_polar2cartesian(phi_min, gamma_min) e1_max, e2_max = shear_polar2cartesian(phi_max, gamma_max) return e1_min, e2_min, e1_max, e2_max
def get_param_ranges(self, reoptimize=False, scale=1): if reoptimize: delta_phi, delta_ellip = scale * 30 * np.pi * 180**-1, scale * 0.15 low_e1, low_e2, high_e1, high_e2 = self._new_ellip( self._kwargs_lens[0]['e1'], self._kwargs_lens[0]['e2'], delta_phi, delta_ellip) phi, _ = shear_cartesian2polar(self._kwargs_lens[1]['gamma1'], self._kwargs_lens[1]['gamma2']) low_shear_PA = phi * 0.8 * scale high_shear_pA = phi * 1.2 * scale theta_E = scale * 0.005 center = 0.005 low_Rein = self._kwargs_lens[0]['theta_E'] - theta_E hi_Rein = self._kwargs_lens[0]['theta_E'] + theta_E low_centerx = self._kwargs_lens[0]['center_x'] - center hi_centerx = self._kwargs_lens[0]['center_x'] + center low_centery = self._kwargs_lens[0]['center_y'] - center hi_centery = self._kwargs_lens[0]['center_y'] + center else: low_e1 = -0.3 low_e2 = low_e1 high_e1 = 0.3 high_e2 = high_e1 low_shear_PA = -np.pi high_shear_pA = np.pi low_Rein = self._theta_E_start - 0.1 hi_Rein = self._theta_E_start + 0.1 low_centerx = -0.015 hi_centerx = 0.015 low_centery = low_centerx hi_centery = hi_centerx sie_list_low = [low_Rein, low_centerx, low_centery, low_e1, low_e2] sie_list_high = [hi_Rein, hi_centerx, hi_centery, high_e1, high_e2] shear_list_low = [low_shear_PA] shear_list_high = [high_shear_pA] return sie_list_low + shear_list_low, sie_list_high + shear_list_high
def _kwargs_to_tovary(self,kwargs): values = [] for n in range(0, int(self._Ntovary)): for key in self.routine.param_names[n]: if key == 'shear_magnitude' or key == 'shear_PA': phi, _ = shear_cartesian2polar(kwargs[n]['gamma1'], kwargs[n]['gamma2']) values.append(phi) else: if key not in self.routine.fixed_names[n]: values.append(kwargs[n][key]) return np.array(values)
def _extract_array(self, kwargs_list): """ inverse of _update_kwargs :param kwargs_list: :return: """ if self._solver_type == 'PROFILE_SHEAR_GAMMA_PSI': phi_ext = kwargs_list[1]['psi_ext'] # % (np.pi) # e1 = kwargs_list[1]['e1'] # e2 = kwargs_list[1]['e2'] # phi_ext, gamma_ext = param_util.ellipticity2phi_gamma(e1, e2) elif self._solver_type == 'PROFILE_SHEAR': gamma1 = kwargs_list[1]['gamma1'] gamma2 = kwargs_list[1]['gamma2'] phi_ext, gamma_ext = param_util.shear_cartesian2polar( gamma1, gamma2) # phi_G_no_sense, gamma_ext = param_util.ellipticity2phi_gamma(kwargs_list[1]['e1'], kwargs_list[1]['e2']) # e1, e2 = param_util.phi_gamma_ellipticity(phi_G, gamma_ext) # kwargs_list[1]['e1'] = e1 else: phi_ext = 0 lens_model = self._lens_mode_list[0] if lens_model in ['SPEP', 'SPEMD', 'SIE', 'NIE', 'PEMD', 'EPL']: e1 = kwargs_list[0]['e1'] e2 = kwargs_list[0]['e2'] center_x = kwargs_list[0]['center_x'] center_y = kwargs_list[0]['center_y'] theta_E = kwargs_list[0]['theta_E'] x = [theta_E, e1, e2, center_x, center_y, phi_ext] elif lens_model in ['NFW_ELLIPSE', 'CNFW_ELLIPSE']: e1 = kwargs_list[0]['e1'] e2 = kwargs_list[0]['e2'] center_x = kwargs_list[0]['center_x'] center_y = kwargs_list[0]['center_y'] alpha_Rs = kwargs_list[0]['alpha_Rs'] x = [alpha_Rs, e1, e2, center_x, center_y, phi_ext] elif lens_model in ['SHAPELETS_CART']: coeffs = list(kwargs_list[0]['coeffs']) [c10, c01, c20, c11, c02] = coeffs[1:6] x = [c10, c01, c20, c11, c02, phi_ext] else: raise ValueError( "Lens model %s not supported for 4-point solver!" % lens_model) return x
def _update_kwargs(self, x, kwargs_list): """ :param x: list of parameters corresponding to the free parameter of the first lens model in the list :param kwargs_list: list of lens model kwargs :return: updated kwargs_list """ lens_model = self._lens_mode_list[0] if self._solver_type == 'CENTER': [center_x, center_y] = x kwargs_list[0]['center_x'] = center_x kwargs_list[0]['center_y'] = center_y elif self._solver_type == 'ELLIPSE': [e1, e2] = x kwargs_list[0]['e1'] = e1 kwargs_list[0]['e2'] = e2 elif self._solver_type == 'SHAPELETS': [c10, c01] = x coeffs = list(kwargs_list[0]['coeffs']) coeffs[1:3] = [c10, c01] kwargs_list[0]['coeffs'] = coeffs elif self._solver_type == 'THETA_E_PHI': [theta_E, phi_G] = x kwargs_list[0]['theta_E'] = theta_E phi_G_no_sense, gamma_ext = param_util.shear_cartesian2polar( kwargs_list[1]['gamma1'], kwargs_list[1]['gamma2']) gamma1, gamma2 = param_util.shear_polar2cartesian(phi_G, gamma_ext) kwargs_list[1]['gamma1'] = gamma1 kwargs_list[1]['gamma2'] = gamma2 elif self._solver_type == 'THETA_E_ELLIPSE': [theta_E, phi_G] = x kwargs_list[0]['theta_E'] = theta_E phi_G_no_sense, q = param_util.ellipticity2phi_q( kwargs_list[0]['e1'], kwargs_list[0]['e2']) e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) kwargs_list[0]['e1'] = e1 kwargs_list[0]['e2'] = e2 else: raise ValueError( "Solver type %s not supported for 2-point solver!" % self._solver_type) return kwargs_list
def _update_kwargs(self, x, kwargs_list): """ :param x: list of parameters corresponding to the free parameter of the first lens model in the list :param kwargs_list: list of lens model kwargs :return: updated kwargs_list """ if self._solver_type == 'PROFILE_SHEAR_GAMMA_PSI': phi_G = x[5] # % (2 * np.pi) kwargs_list[1]['psi_ext'] = phi_G if self._solver_type == 'PROFILE_SHEAR': phi_G = x[5] % np.pi phi_G_no_sense, gamma_ext = param_util.shear_cartesian2polar( kwargs_list[1]['gamma1'], kwargs_list[1]['gamma2']) gamma1, gamma2 = param_util.shear_polar2cartesian(phi_G, gamma_ext) kwargs_list[1]['gamma1'] = gamma1 kwargs_list[1]['gamma2'] = gamma2 lens_model = self._lens_mode_list[0] if lens_model in ['SPEP', 'SPEMD', 'SIE', 'NIE', 'PEMD', 'EPL']: [theta_E, e1, e2, center_x, center_y, _] = x kwargs_list[0]['theta_E'] = theta_E kwargs_list[0]['e1'] = e1 kwargs_list[0]['e2'] = e2 kwargs_list[0]['center_x'] = center_x kwargs_list[0]['center_y'] = center_y elif lens_model in ['NFW_ELLIPSE', 'CNFW_ELLIPSE']: [alpha_Rs, e1, e2, center_x, center_y, _] = x kwargs_list[0]['alpha_Rs'] = alpha_Rs kwargs_list[0]['e1'] = e1 kwargs_list[0]['e2'] = e2 kwargs_list[0]['center_x'] = center_x kwargs_list[0]['center_y'] = center_y elif lens_model in ['SHAPELETS_CART']: [c10, c01, c20, c11, c02, _] = x coeffs = list(kwargs_list[0]['coeffs']) coeffs[1:6] = [c10, c01, c20, c11, c02] kwargs_list[0]['coeffs'] = coeffs else: raise ValueError( "Lens model %s not supported for 4-point solver!" % lens_model) return kwargs_list
def add_gamma_psi_ext_columns(metadata): """Add alternate shear definitions (gamma1, gamma2) for external shear defined in terms of shear modulus and angle (gamma_ext, psi_ext) Parameters ---------- metadata : pd.DataFrame the metadatadata generated by Baobab Returns ------- pd.DataFrame metadata augmented with gamma1, gamma2 for the external shear component """ gamma1 = metadata['external_shear_gamma1'].values gamma2 = metadata['external_shear_gamma2'].values psi_ext, gamma_ext = param_util.shear_cartesian2polar(gamma1=gamma1, gamma2=gamma2) metadata['external_shear_gamma_ext'] = gamma_ext metadata['external_shear_psi_ext'] = psi_ext return metadata
def test_solver_simplified_2(self): lens_model_list = ['SPEP', 'SHEAR_GAMMA_PSI'] lensModel = LensModel(lens_model_list) lensEquationSolver = LensEquationSolver(lensModel) sourcePos_x = 0.1 sourcePos_y = -0.1 deltapix = 0.05 numPix = 150 gamma = 1.96 e1, e2 = -0.01, -0.01 psi_ext, gamma_ext = param_util.shear_cartesian2polar(e1, e2) kwargs_shear = {'gamma_ext': gamma_ext, 'psi_ext': psi_ext} # gamma_ext: shear strength, psi_ext: shear angel (in radian) kwargs_spemd = {'theta_E': 1., 'gamma': gamma, 'center_x': 0, 'center_y': 0, 'e1': -0.2, 'e2': -0.03} kwargs_lens = [kwargs_spemd, kwargs_shear] x_pos, y_pos = lensEquationSolver.findBrightImage(sourcePos_x, sourcePos_y, kwargs_lens, numImages=4, min_distance=deltapix, search_window=numPix * deltapix) kwargs_lens_init = [{'theta_E': 1.3, 'gamma': gamma, 'e1': 0, 'e2': 0, 'center_x': 0., 'center_y': 0}, {'gamma_ext': gamma_ext, 'psi_ext': psi_ext}] solver = Solver4Point(lensModel, solver_type='PROFILE_SHEAR') kwargs_lens_new, accuracy = solver.constraint_lensmodel(x_pos, y_pos, kwargs_lens_init) assert accuracy < 10**(-10) x_source, y_source = lensModel.ray_shooting(x_pos, y_pos, kwargs_lens_new) x_source, y_source = np.mean(x_source), np.mean(y_source) x_pos_new, y_pos_new = lensEquationSolver.findBrightImage(x_source, y_source, kwargs_lens_new, numImages=4, min_distance=deltapix, search_window=numPix * deltapix) print(x_pos, x_pos_new) x_pos = np.sort(x_pos) x_pos_new = np.sort(x_pos_new) y_pos = np.sort(y_pos) y_pos_new = np.sort(y_pos_new) for i in range(len(x_pos)): npt.assert_almost_equal(x_pos[i], x_pos_new[i], decimal=6) npt.assert_almost_equal(y_pos[i], y_pos_new[i], decimal=6) npt.assert_almost_equal(kwargs_lens_new[1]['psi_ext'], kwargs_lens[1]['psi_ext'], decimal=8) npt.assert_almost_equal(kwargs_lens_new[1]['gamma_ext'], kwargs_lens[1]['gamma_ext'], decimal=8)
def derivatives(self, x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0): phi_G, gam = param_util.shear_cartesian2polar(e1, e2) q = max(1 - gam, 0.00001) x, y = self._coord_rotate(x, y, phi_G, center_x, center_y) if isinstance(x, float) and isinstance(y, float): alpha_x, alpha_y = self._compute_derivative_atcoord( x, y, n_sersic, R_sersic, k_eff, phi_G, q, center_x=center_x, center_y=center_y) else: assert isinstance(x, np.ndarray) or isinstance(x, list) assert isinstance(y, np.ndarray) or isinstance(y, list) x = np.array(x) y = np.array(y) shape0 = x.shape assert shape0 == y.shape alpha_x, alpha_y = np.empty_like(x).ravel(), np.empty_like( y).ravel() if isinstance(phi_G, float) or isinstance(phi_G, int): phiG = np.ones_like(alpha_x) * float(phi_G) q = np.ones_like(alpha_x) * float(q) for i, (x_i, y_i, phi_i, q_i) in \ enumerate(zip(x.ravel(), y.ravel(), phiG.ravel(), q.ravel())): fxi, fyi = self._compute_derivative_atcoord(x_i, y_i, n_sersic, R_sersic, k_eff, phi_i, q_i, center_x=center_x, center_y=center_y) alpha_x[i], alpha_y[i] = fxi, fyi alpha_x = alpha_x.reshape(shape0) alpha_y = alpha_y.reshape(shape0) alpha_x, alpha_y = self._coord_rotate(alpha_x, alpha_y, -phi_G, 0, 0) return alpha_x, alpha_y
def caustics_epl_shear(kwargs_lens, num_th=500, maginf=0, sourceplane=True, return_which=None): """ Analytically calculates the caustics of an EPL+shear lens model. Since for gamma>2, the outer critical curve does not exist, the option to find the curves for a set, finite magnification exists, by supplying maginf, so that the routine finds the curve of this magnification, rather than the true caustic. :param kwargs_lens: List of kwargs in lenstronomy style, following ['EPL', 'SHEAR'] format :param num_th: resolution. :param maginf: the outer critical curve for t>1 will be replaced with the curve where the inverse magnification is maginf :param sourceplane: if True (default), ray-shoot the calculated critical curves to the source plane :param return_which: options 'quad' (boundary of area within which there are 4 images), 'double' (boundary of area within which there are 2 images), 'caustic' (the diamond caustic) and 'cut' (the cut, if it exists, that is if t<2, else, if t>2, returns the caustic) and None (in that case: return quad, caustic, cut) :return: (2,N) array if return_which set, else a tuple of (caustic, cut, quad) """ e1, e2 = kwargs_lens[0]['e1'], kwargs_lens[0]['e2'] if len(kwargs_lens) > 1: gamma1unr, gamma2unr = kwargs_lens[1]['gamma1'], kwargs_lens[1][ 'gamma2'] else: gamma1unr, gamma2unr = 0, 0 _check_center(kwargs_lens) t = kwargs_lens[0]['gamma'] - 1 if 'gamma' in kwargs_lens[0] else 1 theta_ell, q = ellipticity2phi_q(e1, e2) theta_gamma, gamma_mag = shear_cartesian2polar(gamma1unr, gamma2unr) b = np.sqrt(q) * kwargs_lens[0]['theta_E'] cen = np.expand_dims( np.array([kwargs_lens[0]['center_x'], kwargs_lens[0]['center_y']]), 1) theta_gamma -= theta_ell gamma1, gamma2 = shear_polar2cartesian(theta_gamma, gamma_mag) M = rotmat(-theta_ell) phiell, q = ellipticity2phi_q(e1, e2) theta = np.linspace(0, 2 * np.pi, num_th, endpoint=False) r = 1 R, phi = pol_to_ell(1, theta, q) Omega = omega(phi, t, q) aa = 1 bb = -(2 - t) frac_roverR = r / R cc = (1 - t) * (2 - t) * (cdot(np.exp(1j * theta), Omega)) / frac_roverR * 2 / (1 + q) cc -= (1 - t)**2 * (2 / (1 + q))**2 * np.abs(Omega)**2 / frac_roverR**2 # Shear stuff: gammaint_fac = (-np.exp(2j * theta) * (2 - t) / 2 + (1 - t) * np.exp(1j * theta) * 2 / (1 + q) * Omega / frac_roverR) gamma = gamma1 + 1j * gamma2 aa -= np.abs(gamma)**2 bb -= 2 * cdot(gamma, gammaint_fac) usol = np.array(solvequadeq(cc, bb, aa)).T xcr_4, ycr_4 = pol_to_cart(b * usol[:, 1]**(-1 / t) * frac_roverR, theta) if t > 1: # If t>1, get the approximate outer caustic instead (where inverse magnification = maginf). usol = np.array(solvequadeq(cc, bb, aa - maginf)).T xcr_cut, ycr_cut = pol_to_cart(b * usol[:, 1]**(-1 / t) * frac_roverR, theta) else: usol = np.array(solvequadeq(cc, bb, aa + maginf)).T xcr_cut, ycr_cut = pol_to_cart(b * usol[:, 0]**(-1 / t) * frac_roverR, theta) al_cut = _alpha_epl_shear(xcr_cut, ycr_cut, b, q, t, gamma1, gamma2, Omega=Omega) al_4 = _alpha_epl_shear(xcr_4, ycr_4, b, q, t, gamma1, gamma2, Omega=Omega) if sourceplane: xca_cut, yca_cut = xcr_cut - al_cut.real, ycr_cut - al_cut.imag xca_4, yca_4 = xcr_4 - al_4.real, ycr_4 - al_4.imag else: xca_cut, yca_cut = xcr_cut, ycr_cut xca_4, yca_4 = xcr_4, ycr_4 if return_which == 'caustic': return M @ (xca_4, yca_4) + cen if return_which == 'cut': return M @ (xca_cut, yca_cut) + cen rcut, thcut = cart_to_pol(xca_cut, yca_cut) r, th = cart_to_pol(xca_4, yca_4) r2 = np.interp(th, thcut, rcut, period=2 * np.pi) if return_which == 'double': r = np.fmax(r, r2) else: # Quad r = np.fmin(r, r2) pos_tosample = np.empty((2, num_th)) pos_tosample[0], pos_tosample[1] = pol_to_cart(r, th) if return_which in ('double', 'quad'): return M @ pos_tosample + cen return M @ (xca_4, yca_4) + cen, M @ ( xca_cut, yca_cut ) + cen, M @ pos_tosample + cen # Mostly for some backward compatibility
def get_param_ranges(self, reoptimize=False, scale=1): if reoptimize: delta_phi, delta_ellip = scale * 30 * np.pi * 180**-1, scale * 0.15 delta_shear_phi, delta_shear = scale * 30 * np.pi * 180**-1, scale * 0.02 low_e1, low_e2, high_e1, high_e2 = self._new_ellip( self._kwargs_lens[0]['e1'], self._kwargs_lens[0]['e2'], delta_phi, delta_ellip) low_shear_e1, low_shear_e2, high_shear_e1, high_shear_e2 = self._new_shear( self._kwargs_lens[1]['gamma1'], self._kwargs_lens[1]['gamma2'], delta_shear_phi, delta_shear) theta_E = scale * 0.005 center = 0.005 low_Rein = self._kwargs_lens[0]['theta_E'] - theta_E hi_Rein = self._kwargs_lens[0]['theta_E'] + theta_E low_centerx = self._kwargs_lens[0]['center_x'] - center hi_centerx = self._kwargs_lens[0]['center_x'] + center low_centery = self._kwargs_lens[0]['center_y'] - center hi_centery = self._kwargs_lens[0]['center_y'] + center low_gamma = self._kwargs_lens[0]['gamma'] - 0.03 high_gamma = self._kwargs_lens[0]['gamma'] + 0.03 if self._constrain_params is not None: # keep the same PA, but change the shear magnitude if 'shear' in self._constrain_params.keys(): phi_start, gamma_start = shear_cartesian2polar( self._kwargs_lens[1]['gamma1'], self._kwargs_lens[1]['gamma2']) rescale = self._constrain_params['shear'][ 0] * gamma_start**-1 low_shear_e1 = self._kwargs_lens[1][ 'gamma1'] * rescale * 0.8 high_shear_e1 = self._kwargs_lens[1][ 'gamma1'] * rescale * 1.2 low_shear_e2 = self._kwargs_lens[1][ 'gamma2'] * rescale * 0.8 high_shear_e2 = self._kwargs_lens[1][ 'gamma2'] * rescale * 1.2 else: low_e1 = -0.3 low_e2 = low_e1 high_e1 = 0.3 high_e2 = high_e1 low_shear_e1 = -0.08 high_shear_e1 = 0.08 low_shear_e2 = low_shear_e1 high_shear_e2 = high_shear_e1 low_Rein = self._theta_E_start - 0.1 hi_Rein = self._theta_E_start + 0.1 low_centerx = -0.015 hi_centerx = 0.015 low_centery = low_centerx hi_centery = hi_centerx low_gamma = self._kwargs_lens[0]['gamma'] - 0.06 high_gamma = self._kwargs_lens[0]['gamma'] + 0.06 if self._constrain_params is not None: if 'shear' in self._constrain_params.keys(): shear_value = self._constrain_params['shear'][0] low_shear_e1 = -0.5 * shear_value high_shear_e1 = 0.5 * shear_value low_shear_e2 = -(shear_value**2 - low_shear_e1**2)**0.5 high_shear_e2 = (shear_value**2 - low_shear_e1**2)**0.5 sie_list_low = [ low_Rein, low_centerx, low_centery, low_e1, low_e2, low_gamma ] sie_list_high = [ hi_Rein, hi_centerx, hi_centery, high_e1, high_e2, high_gamma ] shear_list_low = [low_shear_e1, low_shear_e2] shear_list_high = [high_shear_e1, high_shear_e2] return sie_list_low + shear_list_low, sie_list_high + shear_list_high