diff --git a/test/test_LensPosterior/test_kin_constraints_composite.py b/test/test_LensPosterior/test_kin_constraints_composite.py index 4523826..d9b1a21 100644 --- a/test/test_LensPosterior/test_kin_constraints_composite.py +++ b/test/test_LensPosterior/test_kin_constraints_composite.py @@ -108,6 +108,67 @@ def test_likelihoodconfiguration_om(self): kwargs_kin = {"a_ani": 1} ln_class.lens_log_likelihood(cosmo, kwargs_lens={}, kwargs_kin=kwargs_kin) + kwargs_lens_light_test = [ + { + "amp": [1, 1], + "sigma": [1, 2] + } + ] + lens_light_model_list_test = ["MULTI_GAUSSIAN"] + + kin_constraints_test = KinConstraintsComposite( + z_lens=z_lens, + z_source=z_source, + gamma_in_array=gamma_in_array, + log_m2l_array=log_m2l_array, + rho0_array=rho0_array, + r_s_array=r_s_array, + theta_E=theta_E, + theta_E_error=0.01, + gamma=gamma, + gamma_error=0.02, + r_eff=r_eff, + r_eff_error=0.05, + sigma_v_measured=[200], + sigma_v_error_independent=[10], + sigma_v_error_covariant=0, + kwargs_aperture=kwargs_aperture, + kwargs_seeing=kwargs_seeing, + anisotropy_model=anisotropy_model, + kwargs_lens_light=kwargs_lens_light_test, + lens_light_model_list=lens_light_model_list_test, + **kwargs_kin_api_settings + ) + + kappa_s_array = 10 ** np.random.normal(8, 0, 100) / 1e6 + r_s_angle_array = np.random.normal(0.1, 0, 100) + + kin_constraints_kappa = KinConstraintsComposite( + z_lens=z_lens, + z_source=z_source, + gamma_in_array=gamma_in_array, + log_m2l_array=log_m2l_array, + rho0_array=[], + r_s_array=[], + theta_E=theta_E, + theta_E_error=0.01, + gamma=gamma, + gamma_error=0.02, + r_eff=r_eff, + r_eff_error=0.05, + sigma_v_measured=[200], + sigma_v_error_independent=[10], + sigma_v_error_covariant=0, + kwargs_aperture=kwargs_aperture, + kwargs_seeing=kwargs_seeing, + anisotropy_model=anisotropy_model, + kwargs_lens_light=kwargs_lens_light, + lens_light_model_list=lens_light_model_list, + kappa_s_array=kappa_s_array, + r_s_angle_array=r_s_angle_array, + **kwargs_kin_api_settings + ) + def test_likelihoodconfiguration_gom(self): anisotropy_model = "GOM" kwargs_aperture = { @@ -356,6 +417,82 @@ def test_raise(self): **kwargs_kin_api_settings ) + with self.assertRaises(ValueError): + anisotropy_model = "OM" + kwargs_aperture = { + "aperture_type": "shell", + "r_in": 0, + "r_out": 3 / 2.0, + "center_ra": 0.0, + "center_dec": 0, + } + kwargs_seeing = {"psf_type": "GAUSSIAN", "fwhm": 1.4} + + # numerical settings (not needed if power-law profiles with Hernquist light distribution is computed) + kwargs_numerics_galkin = { + "interpol_grid_num": 50, # numerical interpolation, should converge -> infinity + "log_integration": True, + # log or linear interpolation of surface brightness and mass models + "max_integrate": 100, + "min_integrate": 0.001, + } # lower/upper bound of numerical integrals + + # redshift + z_lens = 0.5 + z_source = 1.5 + theta_E = 1.0 + r_eff = 1 + gamma = 2.1 + + kwargs_mge_light = { + "grid_spacing": 0.1, + "grid_num": 10, + "n_comp": 20, + "center_x": 0, + "center_y": 0, + } + + # settings for kinematics calculation with KinematicsAPI of lenstronomy + kwargs_kin_api_settings = { + "multi_observations": False, + "kwargs_numerics_galkin": kwargs_numerics_galkin, + "kwargs_mge_light": kwargs_mge_light, + "sampling_number": 10, + "num_kin_sampling": 10, + "num_psf_sampling": 10, + } + kwargs_lens_light = [{"Rs": r_eff * 0.551, "amp": 1.0}] + + gamma_in_array = np.linspace(0.1, 2.9, 5) + log_m2l_array = np.linspace(0.1, 1, 5) + kappa_s_array = 10 ** np.random.normal(8, 0.2, 100) / 1e6 + r_s_angle_array = np.random.normal(0.1, 0.01, 101) + + kin_constraints = KinConstraintsComposite( + z_lens=z_lens, + z_source=z_source, + gamma_in_array=gamma_in_array, + log_m2l_array=log_m2l_array, + rho0_array=[], + r_s_array=[], + theta_E=theta_E, + theta_E_error=0.01, + gamma=gamma, + gamma_error=0.02, + r_eff=r_eff, + r_eff_error=0.05, + sigma_v_measured=[200], + sigma_v_error_independent=[10], + sigma_v_error_covariant=0, + kwargs_aperture=kwargs_aperture, + kwargs_seeing=kwargs_seeing, + anisotropy_model=anisotropy_model, + kwargs_lens_light=kwargs_lens_light, + kappa_s_array=kappa_s_array, + r_s_angle_array=r_s_angle_array, + **kwargs_kin_api_settings + ) + if __name__ == "__main__": pytest.main() diff --git a/test/test_Likelihood/test_parameter_scaling.py b/test/test_Likelihood/test_parameter_scaling.py index b4f81ab..508fcb6 100644 --- a/test/test_Likelihood/test_parameter_scaling.py +++ b/test/test_Likelihood/test_parameter_scaling.py @@ -382,6 +382,36 @@ def test_raise(self): gamma_in=1, gamma_in_sigma=0, log_m2l=0, log_m2l_sigma=0 ) + gom_param_array = [ + np.linspace(start=0, stop=1, num=10), + np.linspace(start=1, stop=2, num=5), + ] + + gamma_in_array = np.linspace(start=0.1, stop=2.9, num=5) + + param_arrays = [ + gom_param_array[0], + gom_param_array[1], + gamma_in_array, + ] + param_scaling_array = np.multiply.outer( + gom_param_array[0], + np.multiply.outer( + gom_param_array[1], + gamma_in_array, + ), + ) + self.scaling_nfw_2d_no_m2l = ParameterScalingIFU( + anisotropy_model="GOM", + param_arrays=param_arrays, + scaling_grid_list=[param_scaling_array], + ) + + with self.assertRaises(ValueError): + param_draw = self.scaling_nfw_2d_no_m2l.draw_lens_parameters( + gamma_in=-1, gamma_in_sigma=1, log_m2l=0.5, log_m2l_sigma=3 + ) + if __name__ == "__main__": pytest.main()