Пример #1
0
    def test__figure_of_merit__matches_correct_fit_given_galaxy_profiles(
            self, positions_x2, positions_x2_noise_map):

        point_dataset = al.PointDataset(
            name="point_0",
            positions=positions_x2,
            positions_noise_map=positions_x2_noise_map,
        )

        point_dict = al.PointDict(point_dataset_list=[point_dataset])

        model = af.Collection(galaxies=af.Collection(lens=al.Galaxy(
            redshift=0.5, point_0=al.ps.Point(centre=(0.0, 0.0)))))

        solver = al.m.MockPointSolver(model_positions=positions_x2)

        analysis = al.AnalysisPoint(point_dict=point_dict, solver=solver)

        instance = model.instance_from_unit_vector([])
        analysis_log_likelihood = analysis.log_likelihood_function(
            instance=instance)

        tracer = analysis.tracer_via_instance_from(instance=instance)

        fit_positions = al.FitPositionsImage(
            name="point_0",
            positions=positions_x2,
            noise_map=positions_x2_noise_map,
            tracer=tracer,
            point_solver=solver,
        )

        assert fit_positions.chi_squared == 0.0
        assert fit_positions.log_likelihood == analysis_log_likelihood

        model_positions = al.Grid2DIrregular([(0.0, 1.0), (1.0, 2.0)])
        solver = al.m.MockPointSolver(model_positions=model_positions)

        analysis = al.AnalysisPoint(point_dict=point_dict, solver=solver)

        analysis_log_likelihood = analysis.log_likelihood_function(
            instance=instance)

        fit_positions = al.FitPositionsImage(
            name="point_0",
            positions=positions_x2,
            noise_map=positions_x2_noise_map,
            tracer=tracer,
            point_solver=solver,
        )

        assert fit_positions.residual_map.in_list == [1.0, 1.0]
        assert fit_positions.chi_squared == 2.0
        assert fit_positions.log_likelihood == analysis_log_likelihood
Пример #2
0
    def test__make_result__result_imaging_is_returned(self, point_dict):

        model = af.Collection(galaxies=af.Collection(lens=al.Galaxy(
            redshift=0.5, point_0=al.ps.Point(centre=(0.0, 0.0)))))

        search = al.m.MockSearch(name="test_search")

        solver = al.m.MockPointSolver(
            model_positions=point_dict["point_0"].positions)

        analysis = al.AnalysisPoint(point_dict=point_dict, solver=solver)

        result = search.fit(model=model, analysis=analysis)

        assert isinstance(result, ResultPoint)
all three lens galaxies where the priors on the centres have been paired to thei brightest pixels in the observed image,
alongside a source galaxy which is modeled as a point source.
"""
model_path = path.join("scripts", "clusters", "modeling", "models")
model_file = path.join(model_path, "lens_x3__source_x1.json")

model = af.Collection.from_json(file=model_file)
"""
__Search + Analysis + Model-Fit (Search 1)__

We are now able to model this dataset as a point source, using the exact same tools we used in the point source 
overview.
"""
search_1 = af.DynestyStatic(name="overview_clusters_group")

analysis = al.AnalysisPoint(point_dict=point_dict, solver=positions_solver)

result_1 = search_1.fit(model=model, analysis=analysis)
"""
__Full Image Fitting__

For group-scale lenses like this one, with a modest number of lens and source galaxies, **PyAutoLens** has all the
tools you need to perform extended surface-brightness fitting to the source's extended emission, including the use
of a pixelized source reconstruction.

This will extract a lot more information from the data than the point-source model and the source reconstruction means
that you can study the properties of the highly magnified source galaxy.

This type of modeling uses a lot of **PyAutoLens**'s advanced model-fitting features which are described in chapters 3
and 4 of the **HowToLens** tutorials. An example performing this analysis to the lens above can be found in the 
notebook `clusters/modeling/chaining/lens_x3__source_x1.ipynb`.
Пример #4
0
    def test__figure_of_merit__includes_fit_fluxes(self, positions_x2,
                                                   positions_x2_noise_map,
                                                   fluxes_x2,
                                                   fluxes_x2_noise_map):

        point_dataset = al.PointDataset(
            name="point_0",
            positions=positions_x2,
            positions_noise_map=positions_x2_noise_map,
            fluxes=fluxes_x2,
            fluxes_noise_map=fluxes_x2_noise_map,
        )

        point_dict = al.PointDict(point_dataset_list=[point_dataset])

        model = af.Collection(galaxies=af.Collection(lens=al.Galaxy(
            redshift=0.5,
            sis=al.mp.SphIsothermal(einstein_radius=1.0),
            point_0=al.ps.PointFlux(flux=1.0),
        )))

        solver = al.m.MockPointSolver(model_positions=positions_x2)

        analysis = al.AnalysisPoint(point_dict=point_dict, solver=solver)

        instance = model.instance_from_unit_vector([])

        analysis_log_likelihood = analysis.log_likelihood_function(
            instance=instance)

        tracer = analysis.tracer_via_instance_from(instance=instance)

        fit_positions = al.FitPositionsImage(
            name="point_0",
            positions=positions_x2,
            noise_map=positions_x2_noise_map,
            tracer=tracer,
            point_solver=solver,
        )

        fit_fluxes = al.FitFluxes(
            name="point_0",
            fluxes=fluxes_x2,
            noise_map=fluxes_x2_noise_map,
            positions=positions_x2,
            tracer=tracer,
        )

        assert (fit_positions.log_likelihood +
                fit_fluxes.log_likelihood == analysis_log_likelihood)

        model_positions = al.Grid2DIrregular([(0.0, 1.0), (1.0, 2.0)])
        solver = al.m.MockPointSolver(model_positions=model_positions)

        analysis = al.AnalysisPoint(point_dict=point_dict, solver=solver)

        instance = model.instance_from_unit_vector([])
        analysis_log_likelihood = analysis.log_likelihood_function(
            instance=instance)

        fit_positions = al.FitPositionsImage(
            name="point_0",
            positions=positions_x2,
            noise_map=positions_x2_noise_map,
            tracer=tracer,
            point_solver=solver,
        )

        fit_fluxes = al.FitFluxes(
            name="point_0",
            fluxes=fluxes_x2,
            noise_map=fluxes_x2_noise_map,
            positions=positions_x2,
            tracer=tracer,
        )

        assert fit_positions.residual_map.in_list == [1.0, 1.0]
        assert fit_positions.chi_squared == 2.0
        assert (fit_positions.log_likelihood +
                fit_fluxes.log_likelihood == analysis_log_likelihood)
Пример #5
0
"""
__Non-linear Search__

We again choose the non-linear search `dynesty` (https://github.com/joshspeagle/dynesty).
"""
search = af.DynestyStatic(name="overview_point_source")
"""
__Analysis__

Whereas we previously used an `AnalysisImaging` object, we instead use an `AnalysisPoint` object which fits the
lens model in the correct way for a point source dataset.

This includes mapping the `name`'s of each dataset in the `PointDict` to the names of the point sources in the
lens model.
"""
analysis = al.AnalysisPoint(point_dict=point_dict, solver=solver)
"""
__Model-Fit__

We can now begin the model-fit by passing the model and analysis object to the search, which performs a non-linear
search to find which models fit the data with the highest likelihood.

The results can be found in the `output/overview_point_source` folder in the `autolens_workspace`.
"""
result = search.fit(model=model, analysis=analysis)
"""
__Result__

The **PyAutoLens** visualization library and `FitPoint` object includes specific methods for plotting the results.
"""
"""
Пример #6
0
def make_analysis_point_x2():
    return al.AnalysisPoint(
        point_dict=make_point_dict(),
        solver=MockPointSolver(model_positions=make_positions_x2()),
    )