How to use the autolens.GalaxyModel function in autolens

To help you get started, we’ve selected a few autolens examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jammy2211 / PyAutoLens / test / unit / model / galaxy / test_galaxy_model.py View on Github external
def test_make_galaxy_from_variable_profile(self):
        galaxy_model = al.GalaxyModel(
            redshift=0.5, profile=al.light_and_mass_profiles.EllipticalSersic
        )

        arguments = {
            galaxy_model.profile.mask_centre.centre_0: 1.0,
            galaxy_model.profile.mask_centre.centre_1: 0.2,
            galaxy_model.profile.axis_ratio: 0.4,
            galaxy_model.profile.phi: 0.5,
            galaxy_model.profile.intensity.value: 0.6,
            galaxy_model.profile.effective_radius.value: 0.7,
            galaxy_model.profile.sersic_index: 0.8,
            galaxy_model.profile.mass_to_light_ratio.value: 3.0,
        }

        galaxy = galaxy_model.instance_for_arguments(arguments)
github Jammy2211 / PyAutoLens / test_autolens / unit / model / galaxy / test_galaxy_model.py View on Github external
def test_make_galaxy_from_constant_profile(self, mass_and_light):
        prior = al.GalaxyModel(redshift=0.5, profile=mass_and_light)

        galaxy = prior.instance_for_arguments({})

        assert galaxy.light_profiles[0] == mass_and_light
        assert galaxy.mass_profiles[0] == mass_and_light
github Jammy2211 / PyAutoLens / test / unit / model / galaxy / test_galaxy_model.py View on Github external
def test_fixed_pixelization(self):
        galaxy_model = al.GalaxyModel(
            redshift=al.Redshift,
            pixelization=al.pixelizations.Rectangular(),
            regularization=al.regularization.Constant(),
        )

        arguments = {galaxy_model.redshift.redshift: 2.0}

        galaxy = galaxy_model.instance_for_arguments(arguments)

        assert galaxy.pixelization.shape[0] == 3
        assert galaxy.pixelization.shape[1] == 3
github Jammy2211 / PyAutoLens / test_autolens / unit / model / galaxy / test_galaxy_model.py View on Github external
def test_align_phis(self, galaxy_model):
        assert galaxy_model.light_profile.phi != galaxy_model.mass_profile.phi

        galaxy_model = al.GalaxyModel(
            redshift=al.Redshift,
            light_profile=al.light_profiles.EllipticalDevVaucouleurs,
            mass_profile=al.mass_profiles.EllipticalCoredIsothermal,
            align_orientations=True,
        )
        assert galaxy_model.light_profile.phi == galaxy_model.mass_profile.phi
github Jammy2211 / PyAutoLens / test_autolens / unit / model / galaxy / test_galaxy_model.py View on Github external
def test_multiple_galaxies(self, mapper):
        mapper.galaxy_1 = al.GalaxyModel(
            redshift=al.Redshift,
            light_profile=al.light_profiles.EllipticalDevVaucouleurs,
            mass_profile=al.mass_profiles.EllipticalCoredIsothermal,
        )
        mapper.galaxy_2 = al.GalaxyModel(
            redshift=al.Redshift,
            light_profile=al.light_profiles.EllipticalDevVaucouleurs,
            mass_profile=al.mass_profiles.EllipticalCoredIsothermal,
        )
        assert len(mapper.prior_model_tuples) == 2
github Jammy2211 / PyAutoLens / test_autolens / unit / pipeline / phase / interferometer / test_phase_interferometer.py View on Github external
def test__phase_can_receive_hyper_image_and_noise_maps(self, mask_7x7):

        phase_interferometer_7 = al.PhaseInterferometer(
            phase_name="test_phase",
            galaxies=dict(
                lens=al.GalaxyModel(redshift=al.Redshift),
                lens1=al.GalaxyModel(redshift=al.Redshift),
            ),
            hyper_background_noise=al.hyper_data.HyperBackgroundNoise,
            search=mock.MockSearch(),
            real_space_mask=mask_7x7,
        )

        instance = phase_interferometer_7.model.instance_from_vector([0.1, 0.2, 0.3])

        assert instance.galaxies[0].redshift == 0.1
        assert instance.galaxies[1].redshift == 0.2
        assert instance.hyper_background_noise.noise_scale == 0.3
github Jammy2211 / PyAutoLens / test / unit / pipeline / phase / test_phase_imaging.py View on Github external
def test__fit_using_imaging(self, imaging_data_7x7, mask_function_7x7):
        clean_images()

        phase_imaging_7x7 = al.PhaseImaging(
            optimizer_class=mock_pipeline.MockNLO,
            galaxies=dict(
                lens=al.GalaxyModel(
                    redshift=0.5, light=al.light_profiles.EllipticalSersic
                ),
                source=al.GalaxyModel(
                    redshift=1.0, light=al.light_profiles.EllipticalSersic
                ),
            ),
            mask_function=mask_function_7x7,
            phase_name="test_phase_test_fit",
        )

        result = phase_imaging_7x7.run(data=imaging_data_7x7)
        assert isinstance(result.constant.galaxies[0], al.Galaxy)
        assert isinstance(result.constant.galaxies[0], al.Galaxy)
github Jammy2211 / PyAutoLens / test_autolens / unit / pipeline / phase / test_phase_dataset.py View on Github external
def test__check_if_phase_uses_cluster_inversion(self):
        phase_imaging_7x7 = al.PhaseImaging(
            phase_name="test_phase",
            galaxies=dict(
                lens=al.GalaxyModel(redshift=0.5), source=al.GalaxyModel(redshift=1.0)
            ),
        )

        assert phase_imaging_7x7.meta_dataset.uses_cluster_inversion is False

        phase_imaging_7x7 = al.PhaseImaging(
            phase_name="test_phase",
            galaxies=dict(
                lens=al.GalaxyModel(
                    redshift=0.5,
                    pixelization=al.pix.Rectangular,
                    regularization=al.reg.Constant,
                ),
                source=al.GalaxyModel(redshift=1.0),
            ),
        )
        assert phase_imaging_7x7.meta_dataset.uses_cluster_inversion is False

        source = al.GalaxyModel(
            redshift=1.0,
            pixelization=al.pix.VoronoiBrightnessImage,
            regularization=al.reg.Constant,
        )

        phase_imaging_7x7 = al.PhaseImaging(
github Jammy2211 / PyAutoLens / test / unit / model / galaxy / test_galaxy_model.py View on Github external
def test_pixelization(self):
        galaxy_model = al.GalaxyModel(
            redshift=al.Redshift,
            pixelization=al.pixelizations.Rectangular,
            regularization=al.regularization.Constant,
        )

        arguments = {
            galaxy_model.redshift.redshift: 2.0,
            galaxy_model.pixelization.shape_0: 24.0,
            galaxy_model.pixelization.shape_1: 23.0,
            galaxy_model.regularization.coefficient: 0.5,
        }

        galaxy = galaxy_model.instance_for_arguments(arguments)

        assert galaxy.pixelization.shape[0] == 24
        assert galaxy.pixelization.shape[1] == 23
github Jammy2211 / PyAutoLens / howtolens / chapter_2_lens_modeling / scripts / tutorial_8_results.py View on Github external
imaging = al.Imaging.from_fits(
    image_path=f"{dataset_path}/image.fits",
    noise_map_path=f"{dataset_path}/noise_map.fits",
    psf_path=f"{dataset_path}/psf.fits",
    pixel_scales=0.1,
)

mask = al.Mask.circular(
    shape_2d=imaging.shape_2d, pixel_scales=imaging.pixel_scales, radius=3.0
)

phase = al.PhaseImaging(
    phase_name="phase_t1_non_linear_search",
    settings=al.PhaseSettingsImaging(grid_class=al.Grid, sub_size=2),
    galaxies=dict(
        lens_galaxy=al.GalaxyModel(redshift=0.5, mass=al.mp.SphericalIsothermal),
        source_galaxy=al.GalaxyModel(redshift=1.0, light=al.lp.SphericalExponential),
    ),
    search=af.DynestyStatic(n_live_points=40),
)

# result =  phase.run(dataset=imaging, mask=mask)

# %%
"""
In the previous tutorials, we saw that this result contains the maximum log likelihood tracer and fit, which provide
a fast way to visualize the result.

(Uncomment the line below to pllot the tracer).
"""
# aplt.Tracer.subplot_tracer(
#    tracer=result.max_log_likelihood_tracer, grid=mask.geometry.unmasked_grid