Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
hyper_galaxy = al.HyperGalaxy(
contribution_factor=1.0, noise_factor=1.0, noise_power=1.0
)
instance.galaxies.lens.hyper_galaxy = hyper_galaxy
fit_likelihood = analysis.fit(instance=instance)
lens_hyper_image = result.image_galaxy_dict[("galaxies", "lens")]
source_hyper_image = result.image_galaxy_dict[("galaxies", "source")]
hyper_model_image = lens_hyper_image + source_hyper_image
g0 = al.Galaxy(
redshift=0.5,
light_profile=instance.galaxies.lens.light,
mass_profile=instance.galaxies.lens.mass,
hyper_galaxy=hyper_galaxy,
hyper_model_image=hyper_model_image,
hyper_galaxy_image=lens_hyper_image,
hyper_minimum_value=0.0,
)
g1 = al.Galaxy(redshift=1.0, light_profile=instance.galaxies.source.light)
tracer = al.Tracer.from_galaxies(galaxies=[g0, g1])
fit = FitImaging(masked_imaging=masked_imaging_7x7, tracer=tracer)
assert (fit_likelihood == fit.likelihood).all()
g0 = al.Galaxy(redshift=0.5)
g1 = al.Galaxy(redshift=1.0)
g2 = al.Galaxy(redshift=2.0)
tracer = al.Tracer.from_galaxies(galaxies=[g0, g1, g2])
fit = al.LensUVPlaneFit.from_masked_data_and_tracer(
lens_data=masked_interferometer_6x6, tracer=tracer
)
assert fit.total_inversions == 0
g2 = al.Galaxy(
redshift=2.0,
pixelization=al.pix.Rectangular(),
regularization=al.reg.Constant(),
)
tracer = al.Tracer.from_galaxies(galaxies=[g0, g1, g2])
fit = al.LensUVPlaneFit.from_masked_data_and_tracer(
lens_data=masked_interferometer_6x6, tracer=tracer
)
assert fit.total_inversions == 1
g0 = al.Galaxy(
redshift=0.5,
pixelization=al.pix.Rectangular(),
def test__from_galaxies__6_galaxies_producing_4_planes(self):
g0 = al.Galaxy(redshift=1.0)
g1 = al.Galaxy(redshift=1.0)
g2 = al.Galaxy(redshift=0.1)
g3 = al.Galaxy(redshift=1.05)
g4 = al.Galaxy(redshift=0.95)
g5 = al.Galaxy(redshift=1.05)
galaxies = [g0, g1, g2, g3, g4, g5]
ordered_plane_redshifts = al.util.lens.ordered_plane_redshifts_from_galaxies(
galaxies=galaxies
)
assert ordered_plane_redshifts == [0.1, 0.95, 1.0, 1.05]
def test__convergence_via_jacobian(self):
mass_profile_1 = al.mass_profiles.SphericalIsothermal(
centre=(0.0, 0.0), einstein_radius=1.0
)
mass_profile_2 = al.mass_profiles.SphericalIsothermal(
centre=(1.0, 1.0), einstein_radius=1.0
)
galaxy = al.Galaxy(mass_1=mass_profile_1, mass_2=mass_profile_2, redshift=1)
grid = aa.grid.uniform(
shape_2d=(20, 20), pixel_scales=0.05, sub_size=2
)
convergence_binned_reg_grid = galaxy.convergence_via_jacobian_from_grid(
grid=grid
)
convergence_sub_grid = galaxy.convergence_via_jacobian_from_grid(grid=grid)
pixel_1_reg_grid = convergence_binned_reg_grid[0]
first_pixel_binned_up = (
convergence_sub_grid[0]
+ convergence_sub_grid[1]
+ convergence_sub_grid[2]
def test__simulate_imaging_from_lens__source_galaxy__compare_to_imaging(self):
lens_galaxy = al.Galaxy(
redshift=0.5,
mass=al.mp.EllipticalIsothermal(
centre=(0.0, 0.0), einstein_radius=1.6, elliptical_comps=(0.17647, 0.0)
),
)
source_galaxy = al.Galaxy(
redshift=0.5,
light=al.lp.EllipticalSersic(
centre=(0.1, 0.1),
elliptical_comps=(0.096225, -0.055555),
intensity=0.3,
effective_radius=1.0,
sersic_index=2.5,
),
)
grid = al.Grid.uniform(shape_2d=(11, 11), pixel_scales=0.2, sub_size=1)
psf = al.Kernel.no_blur(pixel_scales=0.2)
simulator = al.SimulatorImaging(
psf=psf,
def simulate__lens_sie__source_cuspy(instrument):
data_name = "lens_sie__source_cuspy"
# This source-only system has a smooth source (low Sersic Index) and simple SIE mass profile.
lens_galaxy = al.Galaxy(
redshift=0.5,
mass=al.mp.EllipticalIsothermal(
centre=(0.0, 0.0), einstein_radius=1.6, elliptical_comps=(0.17647, 0.0)
),
)
source_galaxy = al.Galaxy(
redshift=1.0,
light=al.lp.EllipticalSersic(
centre=(0.0, 0.0),
e1=-0.055555,
e2=0.096225,
intensity=0.1,
effective_radius=0.5,
sersic_index=3.0,
),
def test___lens_fit_galaxy_visibilities_dict__corresponds_to_galaxy_visibilities(
self, masked_interferometer_7_grid
):
g0 = al.Galaxy(
redshift=0.5,
light_profile=al.lp.EllipticalSersic(intensity=1.0),
mass_profile=al.mp.SphericalIsothermal(einstein_radius=1.0),
)
g1 = al.Galaxy(
redshift=1.0, light_profile=al.lp.EllipticalSersic(intensity=1.0)
)
g2 = al.Galaxy(redshift=1.0)
tracer = al.Tracer.from_galaxies(galaxies=[g0, g1, g2])
fit = al.FitInterferometer(
masked_interferometer=masked_interferometer_7_grid, tracer=tracer
)
traced_grids_of_planes = tracer.traced_grids_of_planes_from_grid(
import os
import autofit as af
import autolens as al
"""The pixel scale of dataset to be simulated."""
pixel_scales = 0.1
grid = al.Grid.uniform(shape_2d=(50, 50), pixel_scales=pixel_scales, sub_size=1)
print(grid)
# Setup the lens galaxy's light (elliptical Sersic), mass (SIE+Shear) and source galaxy light (elliptical Sersic) for
# this simulated lens.
lens_galaxy = al.Galaxy(
redshift=0.5,
mass=al.mp.EllipticalIsothermal(
centre=(0.0, 0.0), elliptical_comps=(0.111111, 0.0), einstein_radius=1.0
),
shear=al.mp.ExternalShear(elliptical_comps=(0.0, 0.05)),
)
source_galaxy = al.Galaxy(
redshift=1.0,
light=al.lp.EllipticalSersic(
centre=(0.1, 0.1),
elliptical_comps=(0.096225, -0.055555),
intensity=0.3,
effective_radius=1.0,
sersic_index=2.5,
),
def test___lens_fit_galaxy_model_image_dict__corresponds_to_profile_galaxy_images(
self, masked_interferometer_7_grid
):
g0 = al.Galaxy(
redshift=0.5,
light_profile=al.lp.EllipticalSersic(intensity=1.0),
mass_profile=al.mp.SphericalIsothermal(einstein_radius=1.0),
)
g1 = al.Galaxy(
redshift=1.0, light_profile=al.lp.EllipticalSersic(intensity=1.0)
)
g2 = al.Galaxy(redshift=1.0)
tracer = al.Tracer.from_galaxies(galaxies=[g0, g1, g2])
fit = al.FitInterferometer(
masked_interferometer=masked_interferometer_7_grid, tracer=tracer
)
traced_grids_of_planes = tracer.traced_grids_of_planes_from_grid(
sersic_index=1.5,
),
)
source_galaxy_1 = al.Galaxy(
redshift=1.0,
light=al.lp.EllipticalSersic(
centre=(-0.25, 0.25),
elliptical_comps=(0.0, 0.15),
intensity=0.1,
effective_radius=0.2,
sersic_index=3.0,
),
)
source_galaxy_2 = al.Galaxy(
redshift=1.0,
light=al.lp.EllipticalSersic(
centre=(0.45, -0.35),
elliptical_comps=(0.0, 0.222222),
intensity=0.03,
effective_radius=0.3,
sersic_index=3.5,
),
)
source_galaxy_3 = al.Galaxy(
redshift=1.0,
light=al.lp.EllipticalSersic(
centre=(-0.05, -0.0),
elliptical_comps=(0.05, 0.1),
intensity=0.03,