lenstronomy.Cosmo package¶
Submodules¶
lenstronomy.Cosmo.background module¶
-
class
lenstronomy.Cosmo.background.
Background
(cosmo=None, interp=False, **kwargs_interp)[source]¶ Bases:
object
class to compute cosmological distances
-
T_xy
(z_observer, z_source)[source]¶ Parameters: - z_observer – observer
- z_source – source
Returns: transverse comoving distance in units of Mpc
-
a_z
(z)[source]¶ returns scale factor (a_0 = 1) for given redshift :param z: redshift :return: scale factor
-
d_xy
(z_observer, z_source)[source]¶ Parameters: - z_observer – observer redshift
- z_source – source redshift
Returns: angular diameter distance in units of Mpc
-
ddt
(z_lens, z_source)[source]¶ time-delay distance
Parameters: - z_lens – redshift of lens
- z_source – redshift of source
Returns: time-delay distance in units of proper Mpc
-
rho_crit
¶ critical density :return: value in M_sol/Mpc^3
-
lenstronomy.Cosmo.cosmo_solver module¶
-
lenstronomy.Cosmo.cosmo_solver.
cosmo2angular_diameter_distances
(H_0, omega_m, z_lens, z_source)[source]¶ Parameters: - H_0 – Hubble constant [km/s/Mpc]
- omega_m – dimensionless matter density at z=0
- z_lens – deflector redshift
- z_source – source redshift
Returns: angular diameter distances Dd and Ds/Dds
-
lenstronomy.Cosmo.cosmo_solver.
ddt2h0
(ddt, z_lens, z_source, cosmo)[source]¶ converts time-delay distance to H0 for a given expansion history
Parameters: - ddt – time-delay distance in Mpc
- z_lens – deflector redshift
- z_source – source redshift
- cosmo – astropy.cosmology class instance
Returns: h0 value which matches the cosmology class effectively replacing the h0 value used in the creation of this class
-
class
lenstronomy.Cosmo.cosmo_solver.
SolverFlatLCDM
(z_d, z_s)[source]¶ Bases:
object
class to solve multidimensional non-linear equations to determine the cosmological parameters H0 and omega_m given the angular diameter distance relations
-
class
lenstronomy.Cosmo.cosmo_solver.
InvertCosmo
(z_d, z_s, H0_range=array([ 10., 11.01123596, 12.02247191, 13.03370787, 14.04494382, 15.05617978, 16.06741573, 17.07865169, 18.08988764, 19.1011236, 20.11235955, 21.12359551, 22.13483146, 23.14606742, 24.15730337, 25.16853933, 26.17977528, 27.19101124, 28.20224719, 29.21348315, 30.2247191, 31.23595506, 32.24719101, 33.25842697, 34.26966292, 35.28089888, 36.29213483, 37.30337079, 38.31460674, 39.3258427, 40.33707865, 41.34831461, 42.35955056, 43.37078652, 44.38202247, 45.39325843, 46.40449438, 47.41573034, 48.42696629, 49.43820225, 50.4494382, 51.46067416, 52.47191011, 53.48314607, 54.49438202, 55.50561798, 56.51685393, 57.52808989, 58.53932584, 59.5505618, 60.56179775, 61.57303371, 62.58426966, 63.59550562, 64.60674157, 65.61797753, 66.62921348, 67.64044944, 68.65168539, 69.66292135, 70.6741573, 71.68539326, 72.69662921, 73.70786517, 74.71910112, 75.73033708, 76.74157303, 77.75280899, 78.76404494, 79.7752809, 80.78651685, 81.79775281, 82.80898876, 83.82022472, 84.83146067, 85.84269663, 86.85393258, 87.86516854, 88.87640449, 89.88764045, 90.8988764, 91.91011236, 92.92134831, 93.93258427, 94.94382022, 95.95505618, 96.96629213, 97.97752809, 98.98876404, 100. ]), omega_m_range=array([0.05, 0.06010638, 0.07021277, 0.08031915, 0.09042553, 0.10053191, 0.1106383, 0.12074468, 0.13085106, 0.14095745, 0.15106383, 0.16117021, 0.1712766, 0.18138298, 0.19148936, 0.20159574, 0.21170213, 0.22180851, 0.23191489, 0.24202128, 0.25212766, 0.26223404, 0.27234043, 0.28244681, 0.29255319, 0.30265957, 0.31276596, 0.32287234, 0.33297872, 0.34308511, 0.35319149, 0.36329787, 0.37340426, 0.38351064, 0.39361702, 0.4037234, 0.41382979, 0.42393617, 0.43404255, 0.44414894, 0.45425532, 0.4643617, 0.47446809, 0.48457447, 0.49468085, 0.50478723, 0.51489362, 0.525, 0.53510638, 0.54521277, 0.55531915, 0.56542553, 0.57553191, 0.5856383, 0.59574468, 0.60585106, 0.61595745, 0.62606383, 0.63617021, 0.6462766, 0.65638298, 0.66648936, 0.67659574, 0.68670213, 0.69680851, 0.70691489, 0.71702128, 0.72712766, 0.73723404, 0.74734043, 0.75744681, 0.76755319, 0.77765957, 0.78776596, 0.79787234, 0.80797872, 0.81808511, 0.82819149, 0.83829787, 0.84840426, 0.85851064, 0.86861702, 0.8787234, 0.88882979, 0.89893617, 0.90904255, 0.91914894, 0.92925532, 0.9393617, 0.94946809, 0.95957447, 0.96968085, 0.97978723, 0.98989362, 1. ]))[source]¶ Bases:
object
class to do an interpolation and call the inverse of this interpolation to get H_0 and omega_m
lenstronomy.Cosmo.kde_likelihood module¶
-
class
lenstronomy.Cosmo.kde_likelihood.
KDELikelihood
(D_d_sample, D_delta_t_sample, kde_type='scipy_gaussian', bandwidth=1)[source]¶ Bases:
object
class that samples the cosmographic likelihood given a distribution of points in the 2-dimensional distribution of D_d and D_delta_t
-
logLikelihood
(D_d, D_delta_t)[source]¶ likelihood of the data (represented in the distribution of this class) given a model with predicted angular diameter distances.
Parameters: - D_d – model predicted angular diameter distance
- D_delta_t – model predicted time-delay distance
Returns: loglikelihood (log of KDE value)
-
lenstronomy.Cosmo.lcdm module¶
-
class
lenstronomy.Cosmo.lcdm.
LCDM
(z_lens, z_source, flat=True)[source]¶ Bases:
object
Flat LCDM cosmology background with free Hubble parameter and Omega_m at fixed lens redshift configuration
-
D_d
(H_0, Om0, Ode0=None)[source]¶ angular diameter to deflector :param H_0: Hubble parameter [km/s/Mpc] :param Om0: normalized matter density at present time :return: float [Mpc]
-
D_ds
(H_0, Om0, Ode0=None)[source]¶ angular diameter from deflector to source :param H_0: Hubble parameter [km/s/Mpc] :param Om0: normalized matter density at present time :return: float [Mpc]
-
lenstronomy.Cosmo.lens_cosmo module¶
-
class
lenstronomy.Cosmo.lens_cosmo.
LensCosmo
(z_lens, z_source, cosmo=None)[source]¶ Bases:
object
class to manage the physical units and distances present in a single plane lens with fixed input cosmology
-
arcsec2phys_lens
(arcsec)[source]¶ convert angular to physical quantities for lens plane :param arcsec: angular size at lens plane [arcsec] :return: physical size at lens plane [Mpc]
-
arcsec2phys_source
(arcsec)[source]¶ convert angular to physical quantities for source plane :param arcsec: angular size at source plane [arcsec] :return: physical size at source plane [Mpc]
-
dd
¶ Returns: angular diameter distance to the deflector [Mpc]
-
dds
¶ Returns: angular diameter distance from deflector to source [Mpc]
-
ddt
¶ Returns: time delay distance [Mpc]
-
ds
¶ Returns: angular diameter distance to the source [Mpc]
-
h
¶
-
kappa2proj_mass
(kappa)[source]¶ convert convergence to projected mass M_sun/Mpc^2 :param kappa: lensing convergence :return: projected mass [M_sun/Mpc^2]
-
mass_in_coin
(theta_E)[source]¶ Parameters: theta_E – Einstein radius [arcsec] Returns: mass in coin calculated in mean density of the universe
-
mass_in_theta_E
(theta_E)[source]¶ mass within Einstein radius (area * epsilon crit) [M_sun] :param theta_E: Einstein radius [arcsec] :return: mass within Einstein radius [M_sun]
-
nfwParam_physical
(M, c)[source]¶ returns the NFW parameters in physical units
Parameters: - M – physical mass in M_sun
- c – concentration
Returns: rho0, Rs, r200
-
nfw_M_theta_vir
(M)[source]¶ returns virial radius in angular units of arc seconds on the sky
Parameters: M – physical mass in M_sun Returns: angle (in arc seconds) of the virial radius
-
nfw_angle2physical
(Rs_angle, alpha_Rs)[source]¶ converts the angular parameters into the physical ones for an NFW profile
Parameters: - alpha_Rs – observed bending angle at the scale radius in units of arcsec
- Rs – scale radius in units of arcsec
Returns: rho0, Rs, c, r200, M200
-
nfw_physical2angle
(M, c)[source]¶ converts the physical mass and concentration parameter of an NFW profile into the lensing quantities
Parameters: - M – mass enclosed 200 rho_crit in units of M_sun (physical units, meaning no little h)
- c – NFW concentration parameter (r200/r_s)
Returns: Rs_angle (angle at scale radius) (in units of arcsec), alpha_Rs (observed bending angle at the scale radius
-
phys2arcsec_lens
(phys)[source]¶ convert physical Mpc into arc seconds :param phys: physical distance [Mpc] :return: angular diameter [arcsec]
-
sigma_crit
¶ returns the critical projected lensing mass density in units of M_sun/Mpc^2 :return: critical projected lensing mass density
-
sigma_crit_angle
¶ returns the critical surface density in units of M_sun/arcsec^2 (in physical solar mass units) when provided a physical mass per physical Mpc^2 :return: critical projected mass density
-
sis_sigma_v2theta_E
(v_sigma)[source]¶ converts the velocity dispersion into an Einstein radius for a SIS profile :param v_sigma: velocity dispersion (km/s) :return: theta_E (arcsec)
-
sis_theta_E2sigma_v
(theta_E)[source]¶ converts the lensing Einstein radius into a physical velocity dispersion :param theta_E: Einstein radius (in arcsec) :return: velocity dispersion in units (km/s)
-
time_delay2fermat_pot
(dt)[source]¶ Parameters: dt – time delay in units of days Returns: Fermat potential in units arcsec**2 for a given cosmology
-
time_delay_units
(fermat_pot, kappa_ext=0)[source]¶ Parameters: - fermat_pot – in units of arcsec^2 (e.g. Fermat potential)
- kappa_ext – unit-less external shear not accounted for in the Fermat potential
Returns: time delay in days
-
uldm_angular2phys
(kappa_0, theta_c)[source]¶ converts the anguar parameters entering the LensModel Uldm() (Ultra Light Dark Matter) class in physical masses, i.e. the total soliton mass and the mass of the particle :param kappa_0: central convergence of profile :param theta_c: core radius (in arcseconds) :return: m_eV_log10, M_sol_log10, the log10 of the masses, m in eV and M in M_sun
-
uldm_mphys2angular
(m_log10, M_log10)[source]¶ converts physical ULDM mass in the ones, in angular units, that enter the LensModel Uldm() class :param m_log10: exponent of ULDM mass in eV :param M_log10: exponent of soliton mass in M_sun :return: kappa_0, theta_c, the central convergence and core radius (in arcseconds)
-
lenstronomy.Cosmo.nfw_param module¶
-
class
lenstronomy.Cosmo.nfw_param.
NFWParam
(cosmo=None)[source]¶ Bases:
object
class which contains a halo model parameters dependent on cosmology for NFW profile All distances are given in physical units. Mass definitions are relative to 200 crit including redshift evolution. The redshift evolution is cosmology dependent (dark energy). The H0 dependence is propagated into the input and return units.
-
M200
(rs, rho0, c)[source]¶ M(R_200) calculation for NFW profile
Parameters: - rs (float) – scale radius
- rho0 (float) – density normalization (characteristic density)
- c (float [4,40]) – concentration
Returns: M(R_200) density
-
M_r200
(r200, z)[source]¶ Parameters: - r200 – r200 in physical Mpc/h
- z – redshift
Returns: M200 in M_sun/h
-
c_M_z
(M, z)[source]¶ fitting function of http://moriond.in2p3.fr/J08/proceedings/duffy.pdf for the mass and redshift dependence of the concentration parameter
Parameters: - M (float or numpy array) – halo mass in M_sun/h
- z (float >0) – redshift
Returns: concentration parameter as float
-
c_rho0
(rho0, z)[source]¶ computes the concentration given density normalization rho_0 in h^2/Mpc^3 (physical) (inverse of function rho0_c) :param rho0: density normalization in h^2/Mpc^3 (physical) :param z: redshift :return: concentration parameter c
-
nfw_Mz
(M, z)[source]¶ returns all needed parameter (in physical units modulo h) to draw the profile of the main halo r200 in physical Mpc/h rho_s in h^2/Mpc^3 (physical) Rs in Mpc/h physical c unit less
-
r200_M
(M, z)[source]¶ computes the radius R_200 crit of a halo of mass M in physical distances M/h
Parameters: - M (float or numpy array) – halo mass in M_sun/h
- z (float) – redshift
Returns: radius R_200 in physical Mpc/h
-
rho0_c
(c, z)[source]¶ computes density normalization as a function of concentration parameter
Parameters: - c – concentration
- z – redshift
Returns: density normalization in h^2/Mpc^3 (physical)
-
rhoc
= 277536627000.0¶
-