Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def do_something():
af.conf.instance = af.conf.Config(
config_path="{}/../../test_files/config/radial_min".format(directory)
)
def reset_config():
"""
Use configuration from the default path. You may want to change this to set a specific path.
"""
af.conf.instance = af.conf.default
# 3) An elliptical exponential light-profile for the source galaxy's light (to be honest, even this is a gross
# over-simplification, but lets worry about that later).
# This has a total of 18 non-linear parameters, which is over double the number of parameters we've fitted up to now.
# In future exercises, we'll fit even more complex models, with some 20-30+ non-linear parameters.
# The goal of this, rather short, exercise, is to fit this 'realistic' model to a simulated image, where the lens's
# light is visible and mass is elliptical. What could go wrong?
# If you are using Docker, the paths to the chapter is as follows (e.g. comment out this line)!
# path = '/home/user/workspace/howtolens/chapter_2_lens_modeling'
# If you arn't using docker, you need to change the path below to the chapter 2 directory and uncomment it
# path = '/path/to/user/workspace/howtolens/chapter_2_lens_modeling'
path = '/home/jammy/PyCharm/Projects/AutoLens/workspace/howtolens/chapter_2_lens_modeling'
conf.instance = conf.Config(config_path=path+'/configs/3_realism_and_complexity', output_path=path+"/output")
# Another simulate image function, albeit it generates a new image
def simulate():
from autolens.data.array import grids
from autolens.model.galaxy import galaxy as g
from autolens.lens import ray_tracing
psf = ccd.PSF.simulate_as_gaussian(shape=(11, 11), sigma=0.05, pixel_scale=0.05)
image_plane_grid_stack = grids.GridStack.grid_stack_for_simulation(shape=(130, 130), pixel_scale=0.1, psf_shape=(11, 11))
lens_galaxy = g.Galaxy(light=lp.EllipticalSersic(centre=(0.0, 0.0), axis_ratio=0.9, phi=45.0, intensity=0.04,
effective_radius=0.5, sersic_index=3.5),
mass=mp.EllipticalIsothermal(centre=(0.0, 0.0), axis_ratio=0.8, phi=45.0, einstein_radius=0.8))
source_galaxy = g.Galaxy(light=lp.EllipticalSersic(centre=(0.0, 0.0), axis_ratio=0.5, phi=90.0, intensity=0.03,
import autofit as af
import matplotlib
backend = af.conf.instance.visualize.get("figures", "backend", str)
matplotlib.use(backend)
from matplotlib import pyplot as plt
import autoarray as aa
from autolens.model.inversion.plotters import mapper_plotters
from autolens.model.inversion import mappers
def plot_inversion_subplot(
inversion,
mask=None,
positions=None,
grid=None,
units="arcsec",
kpc_per_arcsec=None,
figsize=None,
def main():
"""Main CLI entry point."""
import autolens.commands
cwd_config_path = "{}/config".format(os.getcwd())
if not conf.is_config(cwd_config_path):
conf.copy_default(cwd_config_path)
options = docopt(__doc__, version=__version__)
# Here we'll try to dynamically match the command the user is trying to run
# with a pre-defined command class we've already created.
for (k, v) in options.items():
if hasattr(autolens.commands, k) and v:
module = getattr(autolens.commands, k)
command = [command[1] for command in getmembers(module, isclass) if command[0] != 'Base'][0]
command = command(options)
command.run()
import autofit as af
import matplotlib
backend = af.conf.instance.visualize.get("figures", "backend", str)
matplotlib.use(backend)
from matplotlib import pyplot as plt
import autoarray as aa
from autolens.model.profiles.plotters import profile_plotters
def plot_profile_image(
galaxy,
grid,
mask=None,
positions=None,
plot_critical_curves=False,
plot_caustics=False,
as_subplot=False,
units="arcsec",
-------
hyper_phase
A copy of the original phase with a modified name and path
"""
phase = copy.deepcopy(self.phase)
phase.paths.zip()
phase.optimizer = phase.optimizer.copy_with_name_extension(
extension=self.hyper_name + "_" + phase.paths.phase_tag,
remove_phase_tag=True,
)
phase.optimizer.const_efficiency_mode = af.conf.instance.non_linear.get(
"MultiNest", "extension_combined_const_efficiency_mode", bool
)
phase.optimizer.sampling_efficiency = af.conf.instance.non_linear.get(
"MultiNest", "extension_combined_sampling_efficiency", float
)
phase.optimizer.n_live_points = af.conf.instance.non_linear.get(
"MultiNest", "extension_combined_n_live_points", int
)
phase.optimizer.multimodal = af.conf.instance.non_linear.get(
"MultiNest", "extension_combined_multimodal", bool
)
phase.optimizer.evidence_tolerance = af.conf.instance.non_linear.get(
"MultiNest", "extension_combined_evidence_tolerance", float
)
phase.is_hyper_phase = True
phase.customize_priors = self.customize_priors
return phase