def test_hessian(self): """ :return: """ doublechameleon = DoubleChameleon() chameleon = Chameleon() x = np.linspace(0.1, 10, 10) phi_G, q = 0.3, 0.8 theta_E = 1. ratio = 2. e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) kwargs_lens = {'alpha_1': theta_E, 'ratio': ratio, 'w_c1': .5, 'w_t1': 1., 'e11': e1, 'e21': e2, 'w_c2': .1, 'w_t2': .5, 'e12': e1, 'e22': e2} kwargs_light = {'amp': theta_E, 'ratio': ratio, 'w_c1': .5, 'w_t1': 1., 'e11': e1, 'e21': e2, 'w_c2': .1, 'w_t2': .5, 'e12': e1, 'e22': e2} kwargs_1 = {'alpha_1': theta_E / (1 + 1./ratio), 'w_c': .5, 'w_t': 1., 'e1': e1, 'e2': e2} kwargs_2 = {'alpha_1': theta_E / (1 + ratio), 'w_c': .1, 'w_t': .5, 'e1': e1, 'e2': e2} f_xx, f_yy, f_xy = doublechameleon.hessian(x=x, y=1., **kwargs_lens) f_xx1, f_yy1, f_xy1 = chameleon.hessian(x=x, y=1., **kwargs_1) f_xx2, f_yy2, f_xy2 = chameleon.hessian(x=x, y=1., **kwargs_2) npt.assert_almost_equal(f_xx, f_xx1 + f_xx2, decimal=8) npt.assert_almost_equal(f_yy, f_yy1 + f_yy2, decimal=8) npt.assert_almost_equal(f_xy, f_xy1 + f_xy2, decimal=8) light = DoubleChameleonLight() f_xx, f_yy, f_xy = doublechameleon.hessian(x=np.linspace(0, 1, 10), y=np.zeros(10), **kwargs_lens) kappa = 1./2 * (f_xx + f_yy) kappa_norm = kappa / np.mean(kappa) flux = light.function(x=np.linspace(0, 1, 10), y=np.zeros(10), **kwargs_light) flux_norm = flux / np.mean(flux) npt.assert_almost_equal(kappa_norm, flux_norm, decimal=5)
def test_function(self): """ :return: """ chameleon = Chameleon() doublechameleon = DoubleChameleon() x = np.linspace(0.1, 10, 10) w_c, w_t = 0.5, 1. phi_G, q = 0.3, 0.8 theta_E = 1. ratio = 2. e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) kwargs_light = { 'amp': 1., 'ratio': 2, 'w_c1': .5, 'w_t1': 1., 'e11': e1, 'e21': e2, 'w_c2': .1, 'w_t2': .5, 'e12': e1, 'e22': e2 } kwargs_1 = { 'amp': 1. / (1 + 1. / ratio), 'w_c': .5, 'w_t': 1., 'e1': e1, 'e2': e2 } kwargs_2 = { 'amp': 1. / (1 + ratio), 'w_c': .1, 'w_t': .5, 'e1': e1, 'e2': e2 } flux = doublechameleon.function(x=x, y=1., **kwargs_light) flux1 = chameleon.function(x=x, y=1., **kwargs_1) flux2 = chameleon.function(x=x, y=1., **kwargs_2) npt.assert_almost_equal(flux, flux1 + flux2, decimal=8)