Exemplo n.º 1
0
    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]")
Exemplo n.º 2
0
    def test__source_inversion_tag(self):

        slam = al.SLaM(
            pipeline_source_parametric=al.SLaMPipelineSourceParametric(),
            pipeline_source_inversion=al.SLaMPipelineSourceInversion(),
            pipeline_mass=al.SLaMPipelineMass(),
        )

        assert (slam.source_inversion_tag == f"source__"
                f"mass[total__sie__with_shear]__"
                f"source[inversion__pix_rect__reg_const]")
        assert slam.source_inversion_tag == slam.source_tag

        pipeline_source_parametric = al.SLaMPipelineSourceParametric(
            setup_light=al.SetupLightParametric(
                bulge_prior_model=al.lp.SphericalExponential,
                disk_prior_model=None),
            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,
            ))

        slam = al.SLaM(
            pipeline_source_parametric=pipeline_source_parametric,
            pipeline_source_inversion=pipeline_source_inversion,
            pipeline_light_parametric=al.SLaMPipelineLightParametric(),
            pipeline_mass=al.SLaMPipelineMass(),
        )

        assert (slam.source_inversion_tag == f"source__"
                f"light[parametric__bulge_exp_sph]__"
                f"mass[total__power_law__with_shear__centre_(0.00,0.00)]__"
                f"source[inversion__pix_voro_mag__reg_adapt_bright]")
        assert slam.source_inversion_tag == slam.source_tag
Exemplo n.º 3
0
    def test__source_parametric_tag(self):

        slam = al.SLaM(
            pipeline_source_parametric=al.SLaMPipelineSourceParametric(),
            pipeline_mass=al.SLaMPipelineMass(),
        )

        assert (slam.source_parametric_tag == f"source__"
                f"mass[total__sie__with_shear]__"
                f"source[parametric__bulge_sersic]")
        assert slam.source_parametric_tag == slam.source_tag

        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,
                align_bulge_disk_centre=False,
            ),
        )

        slam = al.SLaM(
            pipeline_source_parametric=pipeline_source_parametric,
            pipeline_light_parametric=al.SLaMPipelineLightParametric(),
            pipeline_mass=al.SLaMPipelineMass(),
        )

        assert (slam.source_parametric_tag == f"source__"
                f"light[parametric__bulge_exp_sph]__"
                f"mass[total__power_law__with_shear__centre_(0.00,0.00)]__"
                f"source[parametric__bulge_dev_sph]")
        assert slam.source_parametric_tag == slam.source_tag
_SLaMPipelineSourceParametric_ determines the source model used by the parametric source pipeline. A full description of all 
options can be found ? and ?.

By default, this assumes an _EllipticalIsothermal_ profile for the lens galaxy's mass. Our experience with lens 
modeling has shown they are the simpliest models that provide a good fit to the majority of strong lenses.

For this runner the _SLaMPipelineSourceParametric_ customizes:

 - If there is an _ExternalShear_ in the mass model or not.
"""

setup_mass = al.SetupMassTotal(mass_prior_model=al.mp.EllipticalIsothermal,
                               with_shear=True,
                               mass_centre=(0.0, 0.0))
setup_source = al.SetupSourceParametric()

pipeline_source_parametric = al.SLaMPipelineSourceParametric(
    setup_mass=setup_mass, setup_source=setup_source)

# %%
"""
__SLaMPipelineSourceInversion__

The Source inversion pipeline aims to initialize a robust model for the source galaxy using an _Inversion_.

_SLaMPipelineSourceInversion_ determines the _Inversion_ used by the inversion source pipeline. A full description of all 
options can be found ? and ?.

By default, this again assumes _EllipticalIsothermal_ profile for the lens galaxy's mass model.
Exemplo n.º 5
0
    def test__tag(self):

        setup = al.SetupSourceParametric()

        assert setup.tag == "source[parametric__bulge_sersic]"
Exemplo n.º 6
0
_SLaMPipelineSourceParametric_ determines the source model used by the parametric source pipeline. A full description of all 
options can be found ? and ?.

By default, this assumes an `EllipticalIsothermal` profile for the lens `Galaxy`'s mass. Our experience with lens 
modeling has shown they are the simpliest models that provide a good fit to the majority of strong lenses.

For this runner the `SLaMPipelineSourceParametric` customizes:

 - The `MassProfile` fitted by the pipeline (and the following `SLaMPipelineSourceInversion`.
 - If there is an `ExternalShear` in the mass model or not.
"""

setup_mass = al.SetupMassTotal(mass_prior_model=al.mp.EllipticalIsothermal,
                               with_shear=True)
setup_source = al.SetupSourceParametric(
    disk_prior_model=al.lp.EllipticalExponential)

pipeline_source_parametric = al.SLaMPipelineSourceParametric(
    setup_mass=setup_mass, setup_source=setup_source)
"""
__SLaMPipelineMassTotal__

The `SLaMPipelineMassTotal` pipeline fits the model for the lens `Galaxy`'s total mass distribution. 

A full description of all options can be found ? and ?.

The model used to represent the lens `Galaxy`'s mass is input into `SLaMPipelineMass` and this runner uses an 
`EllipticalIsothermal` in this example.

For this runner the `SLaMPipelineMass` customizes:
By default, this assumes an `EllipticalIsothermal` profile for the lens `Galaxy`'s mass and an `EllipticalSersic` + 
`EllipticalExponential` model for the lens `Galaxy`'s light. Our experience with lens modeling has shown they are the 
simplest models that provide a good fit to the majority of strong lenses.

For this runner the `SLaMPipelineSourceParametric` customizes:

 - The `MassProfile` fitted by the pipeline (and the following `SLaMPipelineSourceInversion`..
 - 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).
"""

setup_light = al.SetupLightParametric()
setup_mass = al.SetupMassTotal(mass_prior_model=al.mp.EllipticalIsothermal)
setup_source = al.SetupSourceParametric(
    bulge_prior_model=al.lp.EllipticalSersic,
    disk_prior_model=None,
    envelope_prior_model=None,
)

pipeline_source_parametric = al.SLaMPipelineSourceParametric(
    setup_light=setup_light, setup_mass=setup_mass, setup_source=setup_source)
"""
__SLaMPipelineSourceInversion__

The Source inversion pipeline aims to initialize a robust model for the source galaxy using an `Inversion`.

_SLaMPipelineSourceInversion_ determines the `Inversion` used by the inversion source pipeline. A full description of all 
options can be found ? and ?.

By default, this again assumes `EllipticalIsothermal` profile for the lens `Galaxy`'s mass and an `EllipticalSersic` + 
`EllipticalExponential` model for the lens `Galaxy`'s light.
Exemplo n.º 8
0
setup_mass = al.SetupMassTotal(mass_prior_model=al.mp.EllipticalPowerLaw,
                               with_shear=False)
"""
Next, we create a `SetupSourceParametric` which customizes:

 - The `LightProfile`'s which fit different components of the source light, such as its `bulge` and `disk`.
 - The alignment of these components, for example if the `bulge` and `disk` centres are aligned.
 
In this example we fit the source light as one component, a `bulge` represented as an `EllipticalSersic`. We have 
included options of `SetupSourceParametric` with input values of `None`, illustrating how it could be edited to fit different models.
"""

setup_source = al.SetupSourceParametric(
    bulge_prior_model=al.lp.EllipticalSersic,
    disk_prior_model=None,
    envelope_prior_model=None,
    align_bulge_disk_centre=False,
    align_bulge_disk_elliptical_comps=False,
)
"""
_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
to different output folders and thus not clash with one another!

The `path_prefix` below specifies the path the pipeline results are written to, which is:
"""

# %%
"""
The `SetupSourceParametric` object works in exactly the same way as the `SetupLightParametric` object above, but 
instead for choosing the source model. This object makes it straight forward to fit parametric source models with many
different numbers of components (e.g. just a bulge, a bulge and disk, etc).

All inputs of `SetupSourceParametric` are identical to `SetupLightParametric`.
"""

# %%
setup_source = al.SetupSourceParametric(
    bulge_prior_model=al.lp.EllipticalCoreSersic,
    disk_prior_model=al.lp.EllipticalExponential,
    envelope_prior_model=None,
    align_bulge_disk_centre=True,
    align_bulge_disk_elliptical_comps=False,
    light_centre=None,
)

print(setup_source.bulge_prior_model)
print(setup_source.bulge_prior_model.cls)
print(setup_source.disk_prior_model)
print(setup_source.disk_prior_model.cls)

# %%
"""
The lens mass model is customized using the `SetupMassTotal` object, which customizes:

 - The `MassProfile` fitted by the pipeline.
 - If there is an `ExternalShear` in the mass model or not (this lens was not simulated with shear and