Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup(self):
z_lens = 0.55
z_source = 2.5
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.nfw = NFWVirTrunc(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
self.lensCosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
NFWVirTrunc(z_lens=z_lens, z_source=z_source, cosmo=None)
def setup(self):
self.z_lens, self.z_source = 0.5, 2
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.nfw = NFW()
self.nfwmc = NFWMC(z_source=self.z_source, z_lens=self.z_lens, cosmo=cosmo)
self.lensCosmo = LensCosmo(z_lens=self.z_lens, z_source=self.z_source, cosmo=cosmo)
def setup(self):
z_L = 0.8
z_S = 3.0
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.lensCosmo = LensCosmo(z_L, z_S, cosmo=cosmo)
def setup(self):
np.random.seed(seed=41)
self.z_L = 0.8
self.z_S = 3.0
self.H0_true = 70
self.omega_m_true = 0.3
cosmo = FlatLambdaCDM(H0=self.H0_true, Om0=self.omega_m_true, Ob0=0.05)
lensCosmo = LensCosmo(self.z_L, self.z_S, cosmo=cosmo)
self.Dd_true = lensCosmo.D_d
self.D_dt_true = lensCosmo.D_dt
self.sigma_Dd = 100
self.sigma_Ddt = 100
num_samples = 10000
self.D_dt_samples = np.random.normal(self.D_dt_true, self.sigma_Ddt, num_samples)
self.D_d_samples = np.random.normal(self.Dd_true, self.sigma_Dd, num_samples)
def cosmo2angular_diameter_distances(H_0, omega_m, z_lens, z_source):
"""
:param H_0: Hubble constant [km/s/Mpc]
:param omega_m: dimensionless matter density at z=0
:param z_lens: deflector redshift
:param z_source: source redshift
:return: angular diameter distances Dd and Ds/Dds
"""
cosmo = FlatLambdaCDM(H0=H_0, Om0=omega_m, Ob0=0.)
lensCosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
Dd = lensCosmo.dd
Ds = lensCosmo.ds
Dds = lensCosmo.dds
return Dd, Ds/Dds
def _get_cosom(self, H_0, Om0, Ode0=None):
"""
:param H_0:
:param Om0:
:param Ode0:
:return:
"""
if self._flat is True:
cosmo = FlatLambdaCDM(H0=H_0, Om0=Om0)
else:
cosmo = LambdaCDM(H0=H_0, Om0=Om0, Ode0=Ode0)
lensCosmo = LensCosmo(z_lens=self.z_lens, z_source=self.z_source, cosmo=cosmo)
return lensCosmo
def __init__(self, z_lens, z_source, cosmo=None):
"""
:param z_lens: redshift of lens
:param z_source: redshift of source
:param cosmo: astropy cosmology instance
"""
if cosmo is None:
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self._lens_cosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
super(NFWVirTrunc, self).__init__()
:param Hernquist_approx: bool, if True, uses a Hernquist light profile matched to the half light radius of the deflector light profile to compute the kinematics
:param MGE_light: bool, if true performs the MGE for the light distribution
:param MGE_mass: bool, if true performs the MGE for the mass distribution
:param kwargs_numerics_galkin: numerical settings for the integrated line-of-sight velocity dispersion
:param kwargs_mge_mass: keyword arguments that go into the MGE decomposition routine
:param kwargs_mge_light: keyword arguments that go into the MGE decomposition routine
:param sampling_number: int, number of spectral rendering to compute the light weighted integrated LOS
dispersion within the aperture. This keyword should be chosen high enough to result in converged results within the tolerance.
:param num_kin_sampling: number of kinematic renderings on a total IFU
:param num_psf_sampling: number of PSF displacements for each kinematic rendering on the IFU
"""
self.z_d = z_lens
self.z_s = z_source
self._kwargs_aperture_kin = kwargs_aperture
self._kwargs_psf_kin = kwargs_seeing
self.lensCosmo = LensCosmo(z_lens, z_source, cosmo=cosmo)
self.LensModel, self.SourceModel, self.LensLightModel, self.PointSource, extinction_class = class_creator.create_class_instances(
all_models=True, **kwargs_model)
self._lensLightProfile = LightProfileAnalysis(light_model=self.LensLightModel)
self._lensMassProfile = LensProfileAnalysis(lens_model=self.LensModel)
self._lens_light_model_list = self.LensLightModel.profile_type_list
self._lens_model_list = self.LensModel.lens_model_list
self._kwargs_cosmo = {'d_d': self.lensCosmo.dd, 'd_s': self.lensCosmo.ds, 'd_ds': self.lensCosmo.dds}
self._lens_model_kinematics_bool = lens_model_kinematics_bool
self._light_model_kinematics_bool = light_model_kinematics_bool
self._sampling_number = sampling_number
self._num_kin_sampling = num_kin_sampling
self._num_psf_sampling = num_psf_sampling
if kwargs_mge_mass is None:
self._kwargs_mge_mass = {'n_comp': 20}
else :