Skip to content

Commit

Permalink
new likelihood supported
Browse files Browse the repository at this point in the history
  • Loading branch information
sibirrer committed Jul 19, 2021
1 parent 84ff535 commit 68f069d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions hierarc/Likelihood/LensLikelihood/base_lens_likelihood.py
Expand Up @@ -2,7 +2,7 @@


LIKELIHOOD_TYPES = ['DdtGaussian', 'DdtDdKDE', 'DdtDdGaussian', 'DsDdsGaussian', 'DdtLogNorm', 'IFUKinCov', 'DdtHist',
'DdtHistKDE', 'DdtHistKin', 'DdtGaussKin', 'Mag', 'TDMag']
'DdtHistKDE', 'DdtHistKin', 'DdtGaussKin', 'Mag', 'TDMag', 'TDMagMagnitude']


class LensLikelihoodBase(object):
Expand Down Expand Up @@ -59,6 +59,9 @@ def __init__(self, z_lens, z_source, likelihood_type, name='name', **kwargs_like
elif likelihood_type == 'TDMag':
from hierarc.Likelihood.LensLikelihood.td_mag_likelihood import TDMagLikelihood
self._lens_type = TDMagLikelihood(**kwargs_likelihood)
elif likelihood_type == 'TDMagMagnitude':
from hierarc.Likelihood.LensLikelihood.td_mag_magnitude_likelihood import TDMagMagnitudeLikelihood
self._lens_type = TDMagMagnitudeLikelihood(**kwargs_likelihood)
else:
raise ValueError('likelihood_type %s not supported! Supported are %s.' % (likelihood_type, LIKELIHOOD_TYPES))

Expand Down Expand Up @@ -91,7 +94,7 @@ def log_likelihood(self, ddt, dd, aniso_scaling=None, sigma_v_sys_error=None, mu
sigma_v_sys_error=sigma_v_sys_error)
elif self.likelihood_type in ['Mag']:
return self._lens_type.log_likelihood(mu_intrinsic=mu_intrinsic)
elif self.likelihood_type in ['TDMag']:
elif self.likelihood_type in ['TDMag', 'TDMagMagnitude']:
return self._lens_type.log_likelihood(ddt=ddt, mu_intrinsic=mu_intrinsic)
else:
raise ValueError('likelihood type %s not fully supported.' % self.likelihood_type)
Expand Down
Expand Up @@ -25,7 +25,8 @@ def setup(self):
'DdtHistKin',
'DdtGaussKin',
'Mag',
'TDMag']
'TDMag',
'TDMagMagnitude']

self.kwargs_likelihood_list = [{'ddt_mean': 1, 'ddt_sigma': 0.1},
{'dd_samples': dd_samples, 'ddt_samples': ddt_samples, 'kde_type': 'scipy_gaussian', 'bandwidth': 1},
Expand All @@ -40,7 +41,12 @@ def setup(self):
{'amp_measured': [1.], 'cov_amp_measured': [[1.]], 'magnification_model': [1.], 'cov_magnification_model': [[1.]], 'magnitude_zero_point': 20.},
{'time_delay_measured': [1.], 'cov_td_measured': [[1.]], 'amp_measured': [1., 1.],
'cov_amp_measured': [[1., 0], [0, 1.]], 'fermat_diff': [1.], 'magnification_model': [1., 1.],
'cov_model': np.ones((3, 3)), 'magnitude_zero_point': 20.}
'cov_model': np.ones((3, 3)), 'magnitude_zero_point': 20.},
{'time_delay_measured': [1.], 'cov_td_measured': [[1.]],
'magnitude_measured': [1., 1.],
'cov_magnitude_measured': [[1., 0], [0, 1.]], 'fermat_diff': [1.],
'magnification_model': [1., 1.],
'cov_model': np.ones((3, 3))}
]

def test_log_likelihood(self):
Expand Down
Expand Up @@ -59,7 +59,6 @@ def test_log_likelihood(self):
magnification_model = np.ones(num)
cov_td_measured = np.zeros((num - 1, num - 1))
cov_magnitude_measured = np.zeros((num, num))
amp_int = 10
magnitude_measured = magnitude_intrinsic - 2.5 * np.log10(magnification_model)
cov_model = np.zeros((num + num - 1, num + num - 1))

Expand Down

0 comments on commit 68f069d

Please sign in to comment.