def test_log_likelihood(self): for i, likelihood_type in enumerate(self.likelihood_type_list): likelihood = LensLikelihoodBase(z_lens=self.z_lens, z_source=self.z_source, likelihood_type=likelihood_type, **self.kwargs_likelihood_list[i]) print(likelihood_type) logl = likelihood.log_likelihood(ddt=1, dd=1, aniso_scaling=None, sigma_v_sys_error=1, mu_intrinsic=1) print(logl) assert logl > -np.inf
def __init__(self, z_lens, z_source, name='name', likelihood_type='TDKin', anisotropy_model='NONE', ani_param_array=None, ani_scaling_array_list=None, ani_scaling_array=None, num_distribution_draws=50, kappa_ext_bias=False, kappa_pdf=None, kappa_bin_edges=None, mst_ifu=False, lambda_scaling_property=0, **kwargs_likelihood): """ :param z_lens: lens redshift :param z_source: source redshift :param name: string (optional) to name the specific lens :param likelihood_type: string to specify the likelihood type :param ani_param_array: array of anisotropy parameter values for which the kinematics are predicted :param ani_scaling_array: velocity dispersion sigma**2 scaling (also J scaling) of anisotropy parameter relative to default prediction. The scaling corresponds to the ani_param_array parameter spacing (to generate an interpolation function). A value =1 in ani_scaling_array results in the value stored in the provided J() predictions. :param ani_scaling_array_list: list of array with the scalings of J() for each IFU :param num_distribution_draws: int, number of distribution draws from the likelihood that are being averaged over :param kappa_ext_bias: bool, if True incorporates the global external selection function into the likelihood. If False, the likelihood needs to incorporate the individual selection function with sufficient accuracy. :param kappa_pdf: array of probability density function of the external convergence distribution binned according to kappa_bin_edges :param kappa_bin_edges: array of length (len(kappa_pdf)+1), bin edges of the kappa PDF :param mst_ifu: bool, if True replaces the lambda_mst parameter by the lambda_ifu parameter (and distribution) in sampling this lens. :param lambda_scaling_property: float (optional), scaling of lambda_mst = lambda_mst_global + alpha * lambda_scaling_property :param kwargs_likelihood: keyword arguments specifying the likelihood function, see individual classes for their use """ TransformedCosmography.__init__(self, z_lens=z_lens, z_source=z_source) if ani_scaling_array_list is None and ani_scaling_array is not None: ani_scaling_array_list = [ani_scaling_array] AnisotropyScalingIFU.__init__(self, anisotropy_model=anisotropy_model, ani_param_array=ani_param_array, ani_scaling_array_list=ani_scaling_array_list) LensLikelihoodBase.__init__(self, z_lens=z_lens, z_source=z_source, likelihood_type=likelihood_type, name=name, **kwargs_likelihood) self._num_distribution_draws = int(num_distribution_draws) self._kappa_ext_bias = kappa_ext_bias self._mst_ifu = mst_ifu if kappa_pdf is not None and kappa_bin_edges is not None: self._kappa_dist = PDFSampling(bin_edges=kappa_bin_edges, pdf_array=kappa_pdf) self._draw_kappa = True else: self._draw_kappa = False self._lambda_scaling_property = lambda_scaling_property
def test_predictions_measurements(self): for i, likelihood_type in enumerate(self.likelihood_type_list): likelihood = LensLikelihoodBase(z_lens=self.z_lens, z_source=self.z_source, likelihood_type=likelihood_type, **self.kwargs_likelihood_list[i]) ddt_measurement = likelihood.ddt_measurement() likelihood.sigma_v_measurement(sigma_v_sys_error=0) likelihood.sigma_v_prediction(ddt=1, dd=1, aniso_scaling=1) assert len(ddt_measurement) == 2
def test_raise(self): with self.assertRaises(ValueError): LensLikelihoodBase(z_lens=0.5, z_source=2, likelihood_type='BAD') with self.assertRaises(ValueError): likelihood = LensLikelihoodBase(z_lens=0.5, z_source=2, likelihood_type='DdtGaussian', **{ 'ddt_mean': 1, 'ddt_sigma': 0.1 }) likelihood.likelihood_type = 'BAD' likelihood.log_likelihood(ddt=1, dd=1)