Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_pipeline(pipeline_name):
phase1 = ph.LensSourcePlanePhase(lens_galaxies=[gm.GalaxyModel(sie=mp.EllipticalIsothermal)],
source_galaxies=[gm.GalaxyModel(sersic=lp.EllipticalSersic)],
optimizer_class=nl.MultiNest,
positions=[[[1.0, 1.0], [1.0, -1.0], [-1.0, 1.0], [-1.0, -1.0]]],
phase_name="{}/phase1".format(pipeline_name))
phase1.optimizer.n_live_points = 30
phase1.optimizer.sampling_efficiency = 0.8
return pl.PipelineImaging(pipeline_name, phase1)
def make_pipeline(pipeline_name):
class MMPhase(ph.LensPlanePhase):
pass
phase1 = MMPhase(lens_galaxies=[gm.GalaxyModel(sersic0=lp.EllipticalSersic, sersic1=lp.EllipticalSersic,
sie=mp.EllipticalIsothermal, align_centres=True)],
optimizer_class=nl.MultiNest, phase_name="{}/phase1".format(pipeline_name))
phase1.optimizer.n_live_points = 20
phase1.optimizer.sampling_efficiency = 0.8
return pl.PipelineImaging(pipeline_name, phase1)
self.lens_galaxies[0].sersic0.axis_ratio = 0.2
self.lens_galaxies[0].sersic0.phi = 90.0
self.lens_galaxies[0].sersic0.centre_0 = 1.0
self.lens_galaxies[0].sersic0.centre_1 = 2.0
self.lens_galaxies[0].sersic1.axis_ratio = 0.2
self.lens_galaxies[0].sersic1.phi = 90.0
self.lens_galaxies[0].sersic1.centre_0 = 1.0
self.lens_galaxies[0].sersic1.centre_1 = 2.0
phase1 = MMPhase(lens_galaxies=[gm.GalaxyModel(sersic0=lp.EllipticalSersic, sersic1=lp.EllipticalSersic)],
optimizer_class=nl.MultiNest, phase_name="{}/phase1".format(pipeline_name))
phase1.optimizer.n_live_points = 20
phase1.optimizer.sampling_efficiency = 0.8
return pl.PipelineImaging(pipeline_name, phase1)
self.lens_galaxies[0].sersic.centre_1 = -1.0
self.lens_galaxies[1].sersic.centre_0 = 1.0
self.lens_galaxies[1].sersic.centre_1 = 1.0
def modify_mask_function(img):
return msk.Mask.circular(shape=img.shape, pixel_scale=img.pixel_scale, radius_mask_arcsec=5.)
phase1 = LensPlanex2GalPhase(lens_galaxies=[gm.GalaxyModel(sersic=lp.EllipticalSersic),
gm.GalaxyModel(sersic=lp.EllipticalSersic)],
mask_function=modify_mask_function, optimizer_class=nl.MultiNest,
phase_name="{}/phase1".format(pipeline_name))
phase1.optimizer.n_live_points = 40
phase1.optimizer.sampling_efficiency = 0.8
return pl.PipelineImaging(pipeline_name, phase1)
def make_pipeline(pipeline_name):
phase1 = ph.LensPlanePhase(lens_galaxies=[gm.GalaxyModel(sersic=lp.EllipticalSersic)],
optimizer_class=nl.MultiNest, phase_name="{}/phase1".format(pipeline_name))
phase1.optimizer.n_live_points = 40
phase1.optimizer.sampling_efficiency = 0.8
return pl.PipelineImaging(pipeline_name, phase1)
class SourceHyperPhase(ph.LensSourcePlaneHyperPhase):
def pass_priors(self, previous_results):
phase1_results = previous_results[-1]
phase1h_results = previous_results[-1].hyper
# self.lens_galaxies[0] = previous_results[-1].variable.lens_galaxies[0]
self.source_galaxies = phase1_results.variable.source_galaxies
self.source_galaxies[0].hyper_galaxy = phase1h_results.constant.source_galaxies[0].hyper_galaxy
phase2 = SourceHyperPhase(lens_galaxies=[gm.GalaxyModel(sie=mp.EllipticalIsothermal)],
source_galaxies=[gm.GalaxyModel(sersic=lp.EllipticalSersic)],
optimizer_class=nl.MultiNest, phase_name="{}/phase2".format(pipeline_name))
phase2.optimizer.n_live_points = 40
phase2.optimizer.sampling_efficiency = 0.8
return pl.PipelineImaging(pipeline_name, phase1, phase1h, phase2)
def test_addition(self):
phase_1 = DummyPhaseImaging()
phase_2 = DummyPhaseImaging()
phase_3 = DummyPhaseImaging()
pipeline1 = pl.PipelineImaging("", phase_1, phase_2)
pipeline2 = pl.PipelineImaging("", phase_3)
assert (phase_1, phase_2, phase_3) == (pipeline1 + pipeline2).phases
from autolens.pipeline import phase
from autolens.pipeline import pipeline
from autofit.core import non_linear as nl
from autolens.model.galaxy import galaxy_model as gp
from autolens.model.profiles import light_profiles as lp
from autolens.model.profiles import mass_profiles as mp
phase1 = phase.LensSourcePlanePhase(lens_galaxies=[gp.GalaxyModel(light=lp.EllipticalSersic,
mass=mp.EllipticalIsothermal)],
source_galaxies=[gp.GalaxyModel(light=lp.EllipticalSersic)],
optimizer_class=nl.MultiNest, phase_name='ph1_fit_all')
phase1.optimizer.n_live_points = 80
phase1.optimizer.sampling_efficiency = 0.6
return pipeline.PipelineImaging(pipeline_name, phase1)
self.lens_galaxies.lens.shear = previous_results[2].variable.lens.shear
self.source_galaxies.source = previous_results[3].variable.source
phase5 = InversionPhase(lens_galaxies=dict(lens=gm.GalaxyModel(light=lp.EllipticalSersic,
mass=mp.EllipticalIsothermal,
shear=mp.ExternalShear)),
source_galaxies=dict(source=gm.GalaxyModel(pixelization=pix.AdaptiveMagnification,
regularization=reg.Constant)),
optimizer_class=nl.MultiNest, mask_function=mask_function_circular,
phase_name=pipeline_path + '/phase_5_inversion')
phase5.optimizer.const_efficiency_mode = True
phase5.optimizer.n_live_points = 60
phase5.optimizer.sampling_efficiency = 0.4
return pipeline.PipelineImaging(pipeline_path, phase1, phase2, phase3, phase4, phase5)