h0rton.h0_inference.h0_posterior

Module Contents

Classes

H0Posterior Represents the posterior over H0
class h0rton.h0_inference.h0_posterior.H0Posterior(H0_prior, kappa_ext_prior, kwargs_model, baobab_time_delays, Om0, define_src_pos_wrt_lens, exclude_vel_disp=True, aniso_param_prior=None, kinematics=None, kappa_transformed=True, kwargs_lens_eqn_solver={})[source]

Represents the posterior over H0

required_params = ['lens_mass_center_x', 'src_light_center_x', 'lens_mass_center_y', 'src_light_center_y', 'lens_mass_gamma', 'lens_mass_theta_E', 'lens_mass_e1', 'lens_mass_e2', 'external_shear_gamma1', 'external_shear_gamma2', 'src_light_R_sersic'][source]
classmethod from_dict(cls, lens_dict)[source]

Initialize H0Posterior from a dictionary

lens_dict : dict
contains properties required to initialize H0Posterior. See __init__ method above for the required parameters and their formats.
set_cosmology_observables(self, z_lens, z_src, measured_td_wrt0, measured_td_err, abcd_ordering_i, true_img_dec, true_img_ra, kappa_ext, measured_vd=None, measured_vd_err=None)[source]

Set the cosmology observables for a given lens system, persistent across all the samples for that system

z_lens : float z_src : float lens_mass_dict : dict

dict of lens mass kwargs
ext_shear_dict : dict
dict of external shear kwargs
ps_dict : dict
dict of point source kwargs
measured_vd : float
measured velocity dispersion
measured_vd_err : float
measurement error of velocity dispersion
lens_light_R_sersic : float
effective radius of lens light in arcsec
measured_td : np.array of shape [n_images,]
the measured time delays in days
measured_td_err : float
the time delay measurement error in days
abcd_ordering_i : np.array of shape [n_images,]
the image ordering followed by measured_td in increasing dec. Example: if the measured_td are [a, b, c, d] and the corresponding image dec are [0.3, -0.1, 0.8, 0.4], then abcd_ordering_i are [1, 0, 3, 2].
true_img_dec : np.array of shape [n_images, ]
dec of the true image positions in arcsec
true_img_ra : np.array of shape [n_images, ]
ra of the true image positions in arcsec
_reorder_measured_td_to_tdlmc(self)[source]

Reorder the measured time delays (same for all lens model samples)

Unused!

format_lens_model(self, sample)[source]

Set the lens model parameters for a given lens mass model

sample : dict
a sampled set of lens model parameters
get_img_pos(self, ps_dict, kwargs_lens)[source]

Sets the kwargs_ps class attribute as those coresponding to the point source model LENSED_POSITION

ps_dict : dict
point source parameters definitions, either of SOURCE_POSITION or LENSED_POSITION
sample_H0(self, random_state)[source]
sample_kappa_ext_original(self, random_state)[source]
sample_kappa_ext_transformed(self, random_state)[source]
sample_aniso_param(self, random_state)[source]
calculate_offset_from_true_image_positions(self, model_ra, model_dec, true_img_ra, true_img_dec, increasing_dec_i, abcd_ordering_i)[source]

Calculates the difference in arcsec between the (inferred or fed-in) image positions known to H0Posterior and the provided true image positions

true_img_ra : array-like, of length self.n_img
ra of true image positions in TDLMC order
true_img_dec : array-like, of length self.n_img
dec of true image positions in TDLMC order
array-like
offset in arcsec for each image
get_h0_sample(self, sampled_lens_model_raw, random_state)[source]

Get MC samples from the H0Posterior

sampled_lens_model_raw : dict
sampled lens model parameters, pre-formatting

random_state : np.random.RandomState object

tuple of floats
the candidate H0 and its weight
set_truth_lens_model(self, sampled_lens_model_raw)[source]
get_h0_sample_truth(self, random_state)[source]

Get MC samples from the H0Posterior

sampled_lens_model_raw : dict
sampled lens model parameters, pre-formatting

random_state : np.random.RandomState object

tuple of floats
the candidate H0 and its weight
chuck_images(self, inferred_td, x_image, y_image)[source]

If the number of predicted images are greater than the measured, choose the images that best correspond to the measured.