def test_interpolated_sersic(self): from lenstronomy.Analysis.lens_analysis import LensAnalysis kwargs_light = [{'n_sersic': 2, 'R_sersic': 0.5, 'amp': 1, 'center_x': 0.01, 'center_y': 0.01}] kwargs_lens = [{'n_sersic': 2, 'R_sersic': 0.5, 'k_eff': 1, 'center_x': 0.01, 'center_y': 0.01}] deltaPix = 0.1 numPix = 100 kwargs_interp = LensAnalysis.light2mass_interpol(['SERSIC'], kwargs_lens_light=kwargs_light, numPix=numPix, deltaPix=deltaPix, subgrid_res=5) kwargs_lens_interp = [kwargs_interp] from lenstronomy.Analysis.lens_properties import LensProp z_lens = 0.5 z_source = 1.5 r_ani = 0.62 kwargs_anisotropy = {'r_ani': r_ani} R_slit = 3.8 dR_slit = 1. kwargs_aperture = {'center_ra': 0, 'width': dR_slit, 'length': R_slit, 'angle': 0, 'center_dec': 0} aperture_type = 'slit' psf_fwhm = 0.7 anisotropy_model = 'OsipkovMerritt' r_eff = 0.5 kwargs_options = {'lens_model_list': ['SERSIC'], 'lens_light_model_list': ['SERSIC']} lensProp = LensProp(z_lens, z_source, kwargs_options) v_sigma = lensProp.velocity_dispersion_numerical(kwargs_lens, kwargs_light, kwargs_anisotropy, kwargs_aperture, psf_fwhm, aperture_type, anisotropy_model, MGE_light=True, MGE_mass=True, r_eff=r_eff) kwargs_options_interp = {'lens_model_list': ['INTERPOL'], 'lens_light_model_list': ['SERSIC']} lensProp_interp = LensProp(z_lens, z_source, kwargs_options_interp) v_sigma_interp = lensProp_interp.velocity_dispersion_numerical(kwargs_lens_interp, kwargs_light, kwargs_anisotropy, kwargs_aperture, psf_fwhm, aperture_type, anisotropy_model, kwargs_numerics={}, MGE_light=True, MGE_mass=True, r_eff=r_eff) npt.assert_almost_equal(v_sigma / v_sigma_interp, 1, 1)
def test_velocity_dispersion_new(self): z_lens = 0.5 z_source = 1.5 kwargs_options = { 'lens_model_list': ['SPEP', 'SHEAR', 'SIS', 'SIS', 'SIS'], 'foreground_shear': False, 'lens_model_deflector_bool': [True, False, False, False, False], 'lens_light_deflector_bool': [True], 'lens_light_model_list': ['SERSIC_ELLIPSE', 'SERSIC'] } lensProp = LensProp(z_lens, z_source, kwargs_options) kwargs_lens = [{ 'theta_E': 1.4272358196260446, 'e1': 0, 'center_x': -0.044798916793300093, 'center_y': 0.0054408937891703788, 'e2': 0, 'gamma': 1.8 }, { 'e1': -0.050871696555354479, 'e2': -0.0061601733920590464 }, { 'center_y': 2.79985456, 'center_x': -2.32019894, 'theta_E': 0.28165274714097904 }, { 'center_y': 3.83985426, 'center_x': -2.32019933, 'theta_E': 0.0038110812674654873 }, { 'center_y': 4.31985428, 'center_x': -1.68019931, 'theta_E': 0.45552039839735037 }] phi, q = -0.52624727893702705, 0.79703498156919605 e1, e2 = param_util.phi_q2_ellipticity(phi, q) kwargs_lens_light = [{ 'n_sersic': 1.1212528655709217, 'center_x': -0.019674496231393473, 'e1': e1, 'e2': e2, 'amp': 1.1091367792010356, 'center_y': 0.076914975081560991, 'R_sersic': 0.42691611878867058 }, { 'R_sersic': 0.03025682660635394, 'amp': 139.96763298885992, 'n_sersic': 1.90000008624093865, 'center_x': -0.019674496231393473, 'center_y': 0.076914975081560991 }] r_ani = 0.62 kwargs_anisotropy = {'r_ani': r_ani} R_slit = 3.8 dR_slit = 1. kwargs_aperture = { 'center_ra': 0, 'width': dR_slit, 'length': R_slit, 'angle': 0, 'center_dec': 0 } aperture_type = 'slit' psf_fwhm = 0.7 anisotropy_model = 'OsipkovMerritt' r_eff = 0.211919902322 v_sigma = lensProp.velocity_dispersion_numerical( kwargs_lens, kwargs_lens_light, kwargs_anisotropy, kwargs_aperture, psf_fwhm, aperture_type, anisotropy_model, MGE_light=True, r_eff=r_eff, lens_model_kinematics_bool=kwargs_options[ 'lens_model_deflector_bool']) v_sigma_mge_lens = lensProp.velocity_dispersion_numerical( kwargs_lens, kwargs_lens_light, kwargs_anisotropy, kwargs_aperture, psf_fwhm, aperture_type, anisotropy_model, MGE_light=True, MGE_mass=True, r_eff=r_eff, lens_model_kinematics_bool=kwargs_options[ 'lens_model_deflector_bool']) vel_disp_temp = lensProp.velocity_dispersion(kwargs_lens, kwargs_lens_light, aniso_param=r_ani, r_eff=r_eff, R_slit=R_slit, dR_slit=dR_slit, psf_fwhm=psf_fwhm, num_evaluate=5000) print(v_sigma, vel_disp_temp) #assert 1 == 0 npt.assert_almost_equal(v_sigma / vel_disp_temp, 1, decimal=1) npt.assert_almost_equal(v_sigma_mge_lens / v_sigma, 1, decimal=1)