def test__tag(self): hyper = al.SetupHyper( hyper_galaxies_lens=True, hyper_background_noise=al.hyper_data.HyperBackgroundNoise, hyper_image_sky=al.hyper_data.HyperImageSky, ) setup_mass = al.SetupMassLightDark(align_bulge_dark_centre=True) setup = al.SetupPipeline(setup_hyper=hyper, setup_mass=setup_mass) assert ( setup.tag == "setup__" "hyper[galaxies_lens__bg_sky__bg_noise]__" "mass[light_dark__bulge_sersic__disk_exp__mlr_free__dark_nfw_ludlow__with_shear__align_bulge_dark_centre]" ) setup_source = al.SetupSourceInversion( pixelization_prior_model=al.pix.Rectangular, regularization_prior_model=al.reg.Constant, ) setup_light = al.SetupLightParametric(light_centre=(1.0, 2.0)) setup_mass = al.SetupMassLightDark(mass_centre=(3.0, 4.0), with_shear=False) setup = al.SetupPipeline(setup_source=setup_source, setup_light=setup_light, setup_mass=setup_mass) assert ( setup.tag == "setup__" "light[parametric__bulge_sersic__disk_exp__align_bulge_disk_centre__centre_(1.00,2.00)]__" "mass[light_dark__bulge_sersic__disk_exp__mlr_free__dark_nfw_ludlow__no_shear__centre_(3.00,4.00)]__" "source[inversion__pix_rect__reg_const]") setup_mass = al.SetupMassLightDark(align_bulge_dark_centre=True) setup = al.SetupPipeline(setup_mass=setup_mass) assert ( setup.tag == "setup__" "mass[light_dark__bulge_sersic__disk_exp__mlr_free__dark_nfw_ludlow__with_shear__align_bulge_dark_centre]" ) smbh = al.SetupSMBH(smbh_centre_fixed=True) setup_subhalo = al.SetupSubhalo( subhalo_instance=al.mp.SphericalNFWMCRLudlow(centre=(1.0, 2.0), mass_at_200=1e8)) setup = al.SetupPipeline(setup_smbh=smbh, setup_subhalo=setup_subhalo) assert ( setup.tag == "setup__" "smbh[point_mass__centre_fixed]__" "subhalo[nfw_sph_ludlow__mass_is_model__source_is_model__grid_5__centre_(1.00,2.00)__mass_1.0e+08]" )
def test__with_shear_tag(self): setup_mass = al.SetupMassLightDark(with_shear=True) assert setup_mass.with_shear_tag == "__with_shear" setup_mass = al.SetupMassLightDark(with_shear=False) assert setup_mass.with_shear_tag == "__no_shear"
def test__update_stellar_mass_priors_using_einstein_radius(self): grid = al.Grid2D.uniform(shape_native=(200, 200), pixel_scales=0.05) tracer = mock.MockTracer(einstein_radius=1.0, einstein_mass=4.0) fit = mock.MockFit(grid=grid) result = mock.MockResult(max_log_likelihood_tracer=tracer, max_log_likelihood_fit=fit) bulge_prior_model = af.PriorModel(al.lmp.SphericalSersic) bulge_prior_model.intensity = af.UniformPrior(lower_limit=0.99, upper_limit=1.01) bulge_prior_model.effective_radius = af.UniformPrior(lower_limit=0.99, upper_limit=1.01) bulge_prior_model.sersic_index = af.UniformPrior(lower_limit=2.99, upper_limit=3.01) setup = al.SetupMassLightDark(bulge_prior_model=bulge_prior_model) setup.update_stellar_mass_priors_from_result( prior_model=bulge_prior_model, result=result, einstein_mass_range=[0.001, 10.0], bins=10, ) assert setup.bulge_prior_model.mass_to_light_ratio.lower_limit == pytest.approx( 0.00040519, 1.0e-1) assert setup.bulge_prior_model.mass_to_light_ratio.upper_limit == pytest.approx( 4.051935, 1.0e-1)
def test__mass_tag(self): slam = al.SLaM( pipeline_source_parametric=al.SLaMPipelineSourceParametric(), pipeline_light_parametric=al.SLaMPipelineLightParametric(), pipeline_mass=al.SLaMPipelineMass(), ) assert ( slam.mass_tag == f"mass__" f"light[parametric__bulge_sersic__disk_exp__align_bulge_disk_centre]__" f"mass[total__power_law__with_shear]__" f"source[parametric__bulge_sersic]") pipeline_source_parametric = al.SLaMPipelineSourceParametric( setup_light=al.SetupLightParametric( bulge_prior_model=al.lp.SphericalExponential, disk_prior_model=None, align_bulge_disk_centre=False, ), setup_mass=al.SetupMassTotal( mass_prior_model=al.mp.EllipticalPowerLaw, mass_centre=(0.0, 0.0)), setup_source=al.SetupSourceParametric( bulge_prior_model=al.lp.SphericalDevVaucouleurs), ) pipeline_source_inversion = al.SLaMPipelineSourceInversion( setup_source=al.SetupSourceInversion( pixelization_prior_model=al.pix.VoronoiMagnification, regularization_prior_model=al.reg.AdaptiveBrightness, )) pipeline_light_parametric = al.SLaMPipelineLightParametric( setup_light=al.SetupLightParametric( bulge_prior_model=al.lp.SphericalDevVaucouleurs, disk_prior_model=al.lp.SphericalExponential, align_bulge_disk_centre=False, light_centre=(0.0, 0.0), )) pipeline_mass = al.SLaMPipelineMass(setup_mass=al.SetupMassLightDark( bulge_prior_model=al.lmp.EllipticalSersicRadialGradient)) slam = al.SLaM( pipeline_source_parametric=pipeline_source_parametric, pipeline_source_inversion=pipeline_source_inversion, pipeline_light_parametric=pipeline_light_parametric, pipeline_mass=pipeline_mass, ) assert ( slam.mass_tag == f"mass__" f"light[parametric__bulge_dev_sph__disk_exp_sph__centre_(0.00,0.00)]__" f"mass[light_dark__bulge_sersic_grad__disk_exp__mlr_free__dark_nfw_ludlow__with_shear]__" f"source[inversion__pix_voro_mag__reg_adapt_bright]")
__SLaMPipelineMass__ The `SLaMPipelineMass` pipeline fits the model for the lens `Galaxy`'s decomposed stellar and dark matter mass distribution. A full description of all options can be found ? and ?. The model used to represent the lens `Galaxy`'s mass is an `EllipticalSersic` and `EllipticalExponential` _LightMassProfile_ representing the bulge and disk fitted in the previous pipeline, alongside a `SphericalNFW` for the dark matter halo. For this runner the `SLaMPipelineMass` customizes: - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark(with_shear=True) pipeline_mass = al.SLaMPipelineMass(setup_mass=setup_mass) """ __SLaM__ We combine all of the above `SLaM` pipelines into a `SLaM` object. The `SLaM` object contains a number of methods used in the make_pipeline functions which are used to compose the model based on the input values. It also handles pipeline tagging and path structure. """ slam = al.SLaM( path_prefix=f"slam/{dataset_name}", setup_hyper=hyper, pipeline_source_parametric=pipeline_source_parametric,
The `SLaMPipelineMass` pipeline fits the model for the lens `Galaxy`'s decomposed stellar and dark matter mass distribution. A full description of all options can be found ? and ?. The model used to represent the lens `Galaxy`'s mass is an `EllipticalSersic` and `EllipticalExponential` _LightMassProfile_ representing the bulge and disk fitted in the previous pipeline, alongside a `SphericalNFW` for the dark matter halo. For this runner the `SLaMPipelineMass` customizes: - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark( bulge_prior_model=al.lmp.EllipticalSersic, disk_prior_model=al.lmp.EllipticalExponential, envelope_prior_model=None, with_shear=True, ) pipeline_mass = al.SLaMPipelineMass(setup_mass=setup_mass) """ __SLaM__ We combine all of the above `SLaM` pipelines into a `SLaM` object. The `SLaM` object contains a number of methods used in the make_pipeline functions which are used to compose the model based on the input values. It also handles pipeline tagging and path structure. """ slam = al.SLaM( path_prefix=path.join("slam", dataset_name),
A full description of all options can be found ? and ?. The model used to represent the lens `Galaxy`'s mass is an `EllipticalSersic` and `EllipticalExponential` _LightMassProfile_ representing the bulge and disk fitted in the previous pipeline, alongside a `SphericalNFW` for the dark matter halo. For this runner the `SLaMPipelineMass` customizes: - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark( bulge_prior_model=al.lmp.EllipticalSersic, disk_prior_model=al.lmp.EllipticalSersic, envelope_prior_model=None, with_shear=True, align_bulge_dark_centre=True, ) pipeline_mass = al.SLaMPipelineMass(setup_mass=setup_mass) """ __SLaM__ We combine all of the above `SLaM` pipelines into a `SLaM` object. The `SLaM` object contains a number of methods used in the make_pipeline functions which are used to compose the model based on the input values. It also handles pipeline tagging and path structure. """ slam = al.SLaM(
The `SLaMPipelineMass` pipeline fits the model for the lens `Galaxy`'s decomposed stellar and dark matter mass distribution. A full description of all options can be found ? and ?. The model used to represent the lens `Galaxy`'s mass is an `EllipticalSersic` and `EllipticalExponential` _LightMassProfile_ representing the bulge and disk fitted in the previous pipeline, alongside a `SphericalNFW` for the dark matter halo. For this runner the `SLaMPipelineMass` customizes: - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark( bulge_prior_model=al.lmp.EllipticalCoreSersic, disk_prior_model=al.lmp.EllipticalSersic, align_bulge_dark_centre=True, constant_mass_to_light_ratio=False, ) pipeline_mass = al.SLaMPipelineMass(setup_mass=setup_mass) """ __SLaM__ We combine all of the above `SLaM` pipelines into a `SLaM` object. The `SLaM` object contains a number of methods used in the make_pipeline functions which are used to compose the model based on the input values. It also handles pipeline tagging and path structure. """ slam = al.SLaM(
envelope_prior_model=None, align_bulge_disk_centre=False, align_bulge_disk_elliptical_comps=False, light_centre=None, ) """ This pipeline also uses a `SetupMassLightDark`, which customizes: - If there is an `ExternalShear` in the mass model or not (this lens was not simulated with shear and we do not include it in the mass model).. - If the centre of the `EllipticalSersic` `LightMassProfile` and `EllipticalNFWMCRLudlow` dark `MassProfile` are aligned. """ setup_mass = al.SetupMassLightDark(align_bulge_dark_centre=True, with_shear=False) """ Next, we create a `SetupSourceParametric` which does not customize the pipeline behaviour except for tagging (see below). """ setup_source = al.SetupSourceParametric() """ _Pipeline Tagging_ The `Setup` objects are input into a `SetupPipeline` object, which is passed into the pipeline and used to customize the analysis depending on the setup. This includes tagging the output path of a pipeline. For example, if `with_shear` is True, the pipeline`s output paths are `tagged` with the string `with_shear`. This means you can run the same pipeline on the same data twice (e.g. with and without shear) and the results will go
A full description of all options can be found ? and ?. The model used to represent the lens `Galaxy`'s mass is an `EllipticalSersic` and `EllipticalExponential` _LightMassProfile_ representing the bulge and disk fitted in the previous pipeline, alongside a `SphericalNFW` for the dark matter halo. For this runner the `SLaMPipelineMass` customizes: - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark( bulge_prior_model=al.lmp.EllipticalSersic, disk_prior_model=al.lmp.EllipticalSersic, envelope_prior_model=None, constant_mass_to_light_ratio=True, with_shear=True, ) pipeline_mass = al.SLaMPipelineMass(setup_mass=setup_mass) """ __SLaM__ We combine all of the above `SLaM` pipelines into a `SLaM` object. The `SLaM` object contains a number of methods used in the make_pipeline functions which are used to compose the model based on the input values. It also handles pipeline tagging and path structure. """ slam = al.SLaM(
__SLaMPipelineMass__ The `SLaMPipelineMass` pipeline fits the model for the lens `Galaxy`'s decomposed stellar and dark matter mass distribution. A full description of all options can be found ? and ?. The model used to represent the lens `Galaxy`'s mass is an `EllipticalSersic` and `EllipticalExponential` _LightMassProfile_ representing the bulge and disk fitted in the previous pipeline, alongside a `SphericalNFW` for the dark matter halo. For this runner the `SLaMPipelineMass` customizes: - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark(with_shear=True, mass_centre=(0.0, 0.0)) pipeline_mass = al.SLaMPipelineMass(setup_mass=setup_mass) """ __SLaM__ We combine all of the above `SLaM` pipelines into a `SLaM` object. The `SLaM` object contains a number of methods used in the make_pipeline functions which are used to compose the model based on the input values. It also handles pipeline tagging and path structure. """ slam = al.SLaM( path_prefix=f"slam/{dataset_name}", setup_hyper=hyper, pipeline_source_parametric=pipeline_source_parametric,
disk_prior_model=al.lp.EllipticalExponential, envelope_prior_model=None, align_bulge_disk_centre=False, align_bulge_disk_elliptical_comps=False, light_centre=None, ) """ This pipeline also uses a `SetupMassLightDark`, which customizes: - If the bulge and dark matter models are centrally aligned. - If the bulge and disk have the same mass-to-light ratio. - If there is an `ExternalShear` in the mass model or not. """ setup_mass = al.SetupMassLightDark(align_bulge_dark_centre=True, constant_mass_to_light_ratio=True, with_shear=True) """ Next, we create a `SetupSourceInversion` which customizes: - The `Pixelization` used by the `Inversion` in phase 3 of the pipeline. - The `Regularization` scheme used by the `Inversion` in phase 3 of the pipeline. """ setup_source = al.SetupSourceInversion( pixelization_prior_model=al.pix.VoronoiMagnification, regularization_prior_model=al.reg.Constant, ) """ _Pipeline Tagging_