Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def pass_priors(self, previous_results):
self.lens_galaxies.lens.light.centre_0 = mm.GaussianPrior(mean=0.0, sigma=0.1)
self.lens_galaxies.lens.light.centre_1 = mm.GaussianPrior(mean=0.0, sigma=0.1)
def pass_priors(self, previous_results):
self.lens_galaxies.right_lens.light.centre_0 = mm.GaussianPrior(mean=0.0, sigma=0.05)
self.lens_galaxies.right_lens.light.centre_1 = mm.GaussianPrior(mean=1.0, sigma=0.05)
self.lens_galaxies.right_lens.light.sersic_index = 4.0
self.lens_galaxies.right_lens.mass = phase_3_results.variable.right_lens.mass
# When we pass a a 'variable' galaxy from a previous phase, parameters fixed to constants remain constant.
# Because centre_0 and centre_1 of the mass profile were fixed to constants in phase 3, they're still
# constants after the line after. We need to therefore manually over-ride their priors.
self.lens_galaxies.left_lens.mass.centre_0 = phase_3_results.variable.left_lens.mass.centre_0
self.lens_galaxies.left_lens.mass.centre_1 = phase_3_results.variable.left_lens.mass.centre_1
self.lens_galaxies.right_lens.mass.centre_0 = phase_3_results.variable.right_lens.mass.centre_0
self.lens_galaxies.right_lens.mass.centre_1 = phase_3_results.variable.right_lens.mass.centre_1
# We also want the Sersic index's to be free parameters now, so lets change it from a constant to a
# variable.
self.lens_galaxies.left_lens.light.sersic_index = mm.GaussianPrior(mean=4.0, sigma=2.0)
self.lens_galaxies.right_lens.light.sersic_index = mm.GaussianPrior(mean=4.0, sigma=2.0)
# Things are much simpler for the source galaxies - just like them togerther!
self.source_galaxies.source = phase_3_results.variable.source
self.lens_galaxies.lens.mass.centre_0 = mm.UniformPrior(lower_limit=-0.05, upper_limit=0.05)
self.lens_galaxies.lens.mass.centre_1 = mm.UniformPrior(lower_limit=-0.05, upper_limit=0.05)
# By default, the axis-ratio (ellipticity) of our lens galaxy's light profile is a UniformPrior between 0.2 and
# 1.0. However, by looking at the image it looks fairly circular, so lets use a GaussianPrior nearer 1.0.
self.lens_galaxies.lens.light.axis_ratio = mm.GaussianPrior(mean=0.8, sigma=0.15)
# We'll also assume that the light profile's axis_ratio informs us of the mass-profile's axis_ratio, but
# because this may not strictly be true (e.g. because of dark matter) we'll use a wider prior.
self.lens_galaxies.lens.mass.axis_ratio = mm.GaussianPrior(mean=0.8, sigma=0.25)
# By default, the orientation of the galaxy's light profile, phi, uses a UniformPrior between 0.0 and
# 180.0 degrees. However, if you look really close at the image (and maybe adjust the color-map of the plot),
# you'll be able to notice that it is elliptical and that it is oriented around 45.0 degrees counter-clockwise
# from the x-axis. Lets update our prior
self.lens_galaxies.lens.light.phi = mm.GaussianPrior(mean=45.0, sigma=15.0)
# Again, lets kind of assume that the light's orientation roughly traces that of mass.
self.lens_galaxies.lens.mass.phi = mm.GaussianPrior(mean=45.0, sigma=30.0)
# The effective radius of a light profile is its 'half-light' radius, the radius at which 50% of its
# total luminosity is internal to a circle defined within that radius. PyAutoLens assumes a
# UniformPrior on this quantity between 0.0" and 4.0", but inspection of the image (again, using a colormap
# scaling) shows the lens's light doesn't extend anywhere near 4.0", so lets reduce it.
self.lens_galaxies.lens.light.effective_radius = mm.GaussianPrior(mean=0.5, sigma=0.8)
# Typically, we have some knowledge of what morphology our lens galaxy is. Infact, most strong lenses are
# massive elliptical galaxies, and anyone who studies galaxy morphology will tell you these galaxies have a
# Sersic index near 4. So lets change our Sersic index from a UniformPrior between 0.8 and 8.0 to reflect this.
self.lens_galaxies.lens.light.sersic_index = mm.GaussianPrior(mean=4.0, sigma=1.0)
# Finally, the 'ring' that the lensed source forms clearly has a radius of about 0.8". This is its Einstein
# These two lines change the centre of the lens galaxy's mass-profile to UniformPriors around the coordinates
# (-0.1", 0.1"). For real lens modeling, this might be done by visually inspecting the centre of emission of
# the lens galaxy's light.
# The term 'lens_galaxy' refers to the name of the galaxy that we give it below (scroll down cell [5].
# By naming galaxies in this way, we can easily keep track of how to pass their priors).
# The word 'mass' corresponds to the word we used when setting up the GalaxyModel above.
self.lens_galaxies.lens_galaxy.mass.centre_0 = model_mapper.UniformPrior(lower_limit=-0.1, upper_limit=0.1)
self.lens_galaxies.lens_galaxy.mass.centre_1 = model_mapper.UniformPrior(lower_limit=-0.1, upper_limit=0.1)
# Lets also change the prior on the lens galaxy's einstein radius, to a GaussianPrior centred on 1.4".
# For real lens modeling, this might be done by visually estimating the radius the lens's arcs / ring appear.
self.lens_galaxies.lens_galaxy.mass.einstein_radius = model_mapper.GaussianPrior(mean=1.4, sigma=0.2)
# We can also customize the source galaxy - lets say we believe it is compact and limit its effective radius
self.source_galaxies.source_galaxy.light.effective_radius = \
model_mapper.UniformPrior(lower_limit=0.0, upper_limit=0.3)
self.lens_galaxies.lens.mass.axis_ratio = mm.GaussianPrior(mean=0.8, sigma=0.25)
# By default, the orientation of the galaxy's light profile, phi, uses a UniformPrior between 0.0 and
# 180.0 degrees. However, if you look really close at the image (and maybe adjust the color-map of the plot),
# you'll be able to notice that it is elliptical and that it is oriented around 45.0 degrees counter-clockwise
# from the x-axis. Lets update our prior
self.lens_galaxies.lens.light.phi = mm.GaussianPrior(mean=45.0, sigma=15.0)
# Again, lets kind of assume that the light's orientation roughly traces that of mass.
self.lens_galaxies.lens.mass.phi = mm.GaussianPrior(mean=45.0, sigma=30.0)
# The effective radius of a light profile is its 'half-light' radius, the radius at which 50% of its
# total luminosity is internal to a circle defined within that radius. PyAutoLens assumes a
# UniformPrior on this quantity between 0.0" and 4.0", but inspection of the image (again, using a colormap
# scaling) shows the lens's light doesn't extend anywhere near 4.0", so lets reduce it.
self.lens_galaxies.lens.light.effective_radius = mm.GaussianPrior(mean=0.5, sigma=0.8)
# Typically, we have some knowledge of what morphology our lens galaxy is. Infact, most strong lenses are
# massive elliptical galaxies, and anyone who studies galaxy morphology will tell you these galaxies have a
# Sersic index near 4. So lets change our Sersic index from a UniformPrior between 0.8 and 8.0 to reflect this.
self.lens_galaxies.lens.light.sersic_index = mm.GaussianPrior(mean=4.0, sigma=1.0)
# Finally, the 'ring' that the lensed source forms clearly has a radius of about 0.8". This is its Einstein
# radius, so lets change the prior from a UniformPrior between 0.0" and 4.0".
self.lens_galaxies.lens.mass.einstein_radius = mm.GaussianPrior(mean=0.8, sigma=0.2)
def pass_priors(self, previous_results):
# Lets restrict the prior's on the centres around the pixel we know the galaxy's light centre peaks.
self.lens_galaxies.left_lens.light.centre_0 = mm.GaussianPrior(mean=0.0, sigma=0.05)
self.lens_galaxies.left_lens.light.centre_1 = mm.GaussianPrior(mean=-1.0, sigma=0.05)
# Given we are only fitting the very central region of the lens galaxy, we don't want to let a parameter
# like th Sersic index vary. Lets fix it to 4.0.
self.lens_galaxies.left_lens.light.sersic_index = 4.0
self.lens_galaxies.lens.mass.phi = mm.GaussianPrior(mean=45.0, sigma=30.0)
# The effective radius of a light profile is its 'half-light' radius, the radius at which 50% of its
# total luminosity is internal to a circle defined within that radius. PyAutoLens assumes a
# UniformPrior on this quantity between 0.0" and 4.0", but inspection of the image (again, using a colormap
# scaling) shows the lens's light doesn't extend anywhere near 4.0", so lets reduce it.
self.lens_galaxies.lens.light.effective_radius = mm.GaussianPrior(mean=0.5, sigma=0.8)
# Typically, we have some knowledge of what morphology our lens galaxy is. Infact, most strong lenses are
# massive elliptical galaxies, and anyone who studies galaxy morphology will tell you these galaxies have a
# Sersic index near 4. So lets change our Sersic index from a UniformPrior between 0.8 and 8.0 to reflect this.
self.lens_galaxies.lens.light.sersic_index = mm.GaussianPrior(mean=4.0, sigma=1.0)
# Finally, the 'ring' that the lensed source forms clearly has a radius of about 0.8". This is its Einstein
# radius, so lets change the prior from a UniformPrior between 0.0" and 4.0".
self.lens_galaxies.lens.mass.einstein_radius = mm.GaussianPrior(mean=0.8, sigma=0.2)
def pass_priors(self, previous_results):
self.lens_galaxies.right_lens.light.centre_0 = mm.GaussianPrior(mean=0.0, sigma=0.05)
self.lens_galaxies.right_lens.light.centre_1 = mm.GaussianPrior(mean=1.0, sigma=0.05)
self.lens_galaxies.right_lens.light.sersic_index = 4.0