Exemplo n.º 1
0
    def test__slope_equal_to_power_law_input(self):
        power_law = l1d.SphericalPowerLaw(
            einstein_radius=1.8, slope=2, redshift_source=0.8, redshift_lens=0.3
        )
        radii = np.arange(0.2, 3, 0.002)

        fit = l1d.PowerLawFit(profile=power_law, mask=None, radii=radii)

        slope_lensing = fit.slope_via_lensing()

        assert slope_lensing == pytest.approx(power_law.slope, 1e-4)
Exemplo n.º 2
0
    def test__xi_two_equal_to_zero_for_sis(self):
        power_law = l1d.SphericalPowerLaw(
            einstein_radius=1.8, slope=2, redshift_source=0.8, redshift_lens=0.3
        )
        radii = np.arange(0.2, 3, 0.002)

        fit = l1d.PowerLawFit(profile=power_law, mask=None, radii=radii)

        xi_two = fit.xi_two()

        assert xi_two == pytest.approx(0, 1e-3)
Exemplo n.º 3
0
    def test__three_d_mass_from_dynamics_slope_and_normalization_equals_analytic(self):
        dm = l1d.NFWHilbert(
            mass_at_200=2.5e12, redshift_lens=0.3, redshift_source=1.0
        )
        baryons = l1d.Hernquist(
            mass=3.4e11, effective_radius=3.2, redshift_lens=0.3, redshift_source=1.0
        )
        combined = l1d.CombinedProfile(profiles=[dm, baryons])

        radii = np.arange(0.2, 8, 0.002)

        fit = l1d.PowerLawFit(profile=combined, mask=None, radii=radii)

        rho_0, slope = fit.slope_and_normalisation_via_dynamics()

        reff = combined.effective_radius
        mdyn = combined.three_dimensional_mass_enclosed_within_effective_radius

        mdyn_from_dyn = mass_dynamical(rho0=rho_0, g=slope, Reff=reff * u.kpc)

        assert mdyn == pytest.approx(mdyn_from_dyn, 1e-3)
Exemplo n.º 4
0
    def test__einstein_mass_from_dynamics_slope_and_normalization_equals_analytic(self):
        dm = l1d.NFWHilbert(
            mass_at_200=2.5e12, redshift_lens=0.3, redshift_source=1.0
        )
        baryons = l1d.Hernquist(
            mass=3.4e11, effective_radius=3.2, redshift_lens=0.3, redshift_source=1.0
        )
        combined = l1d.CombinedProfile(profiles=[dm, baryons])

        radii = np.arange(0.2, 8, 0.002)

        fit = l1d.PowerLawFit(profile=combined, mask=None, radii=radii)

        rho_0, slope = fit.slope_and_normalisation_via_dynamics()

        rein = combined.einstein_radius_in_kpc_from_radii(radii=radii)
        mein = combined.einstein_mass_in_solar_masses_from_radii(radii=radii)

        mein_from_dyn = mass_einstein(rho0=rho_0, g=slope, Rein=rein * u.kpc)

        assert mein == pytest.approx(mein_from_dyn, 1e-3)
Exemplo n.º 5
0
            redshift_lens=slacs["z_lens"][lens],
            redshift_source=slacs["z_source"][lens],
        )
        DM = l1d.NFWHilbert(
            mass_at_200=slacs["M200"][lens],
            redshift_lens=slacs["z_lens"][lens],
            redshift_source=slacs["z_source"][lens],
        )

        true_profile = l1d.CombinedProfile(profiles=[baryons, DM])

        mask_einstein_radius = true_profile.mask_einstein_radius_from_radii(
            width=5, radii=radii)

        fit_mask = l1d.PowerLawFit(profile=true_profile,
                                   radii=radii,
                                   mask=mask_einstein_radius)

        fit_no_mask = l1d.PowerLawFit(profile=true_profile,
                                      radii=radii,
                                      mask=None)

        einstein_radius = true_profile.einstein_radius_in_kpc_from_radii(
            radii=radii)

        effective_radius = true_profile.effective_radius

        einstein_mass = true_profile.einstein_mass_in_solar_masses_from_radii(
            radii=radii)

        three_d_mass = true_profile.three_dimensional_mass_enclosed_within_effective_radius
Exemplo n.º 6
0
Hernquist = l1d.Hernquist(
    mass=10**slacs["log[M*/M]_chab"][lens_name],
    effective_radius=slacs["R_eff"][lens_name],
    redshift_lens=slacs["z_lens"][lens_name],
    redshift_source=slacs["z_source"][lens_name],
)

true_profile = l1d.CombinedProfile(profiles=[Hernquist, DM_Hilb])

kappa_baryons = Hernquist.convergence_from_radii(radii=radii)
kappa_DM = DM_Hilb.convergence_from_radii(radii=radii)
einstein_radius = true_profile.einstein_radius_in_kpc_from_radii(radii=radii)
effective_radius = true_profile.effective_radius
kappa_total = true_profile.convergence_from_radii(radii=radii)

fit = l1d.PowerLawFit(profile=true_profile, mask=None, radii=radii)

lens_slope = fit.slope_via_lensing()
dyn_slope = fit.slope_and_normalisation_via_dynamics()[1]
kappa_lensing = fit.convergence_via_lensing()
kappa_dynamics = fit.convergence_via_dynamics()
kappa_best_fit = fit.convergence()

radial_range = np.arange(0.2, 20, 0.1)

slope_ein = []
slope_eff = []

for i in range(len(radial_range)):
    mask_ein = true_profile.mask_einstein_radius_from_radii(
        radii=radii, width=radial_range[i])
Exemplo n.º 7
0
Hernquist = l1d.Hernquist(
    mass=10 ** 11.21, effective_radius=5.68, redshift_lens=0.351, redshift_source=1.071
)
Hernquist_2 = l1d.CombinedProfile(profiles=[Hernquist])
total = l1d.CombinedProfile(profiles=[Hernquist, DM_Hilb])
kappa_total = total.convergence_from_radii(radii=radii)
alpha = Hernquist.deflections_from_radii(radii=radii)

d_alpha = np.gradient(alpha, radii[:])
dd_alpha = np.gradient(d_alpha, radii[:])

mask_einstein_radius = total.mask_radial_range_from_radii(
    lower_bound=0.9, upper_bound=1.0, radii=radii
)

fit = l1d.PowerLawFit(profile=total, mask=None, radii=radii)
fit_ein = l1d.PowerLawFit(profile=total, mask=mask_einstein_radius, radii=radii)
print("concentration:", DM_Hilb.concentration)
print(
    "3D mass enclosed in Reff:",
    total.three_dimensional_mass_enclosed_within_effective_radius,
)
print(
    "2D mass enclosed in Reff:",
    total.two_dimensional_mass_enclosed_within_effective_radius,
)
print("Reff:", total.effective_radius)
print("Rein:", total.einstein_radius_in_kpc_from_radii(radii=radii))
print(
    "Rein via regression to kappa:",
    fit.einstein_radius_with_error(