Exemple #1
0
    def solve(self, lensing_obj, source_plane_coordinate):

        coordinates_list = self.grid_peaks_from(
            lensing_obj=lensing_obj,
            grid=self.grid,
            source_plane_coordinate=source_plane_coordinate,
        )

        coordinates_list = self.grid_with_coordinates_from_mass_profile_centre_removed(
            lensing_obj=lensing_obj, grid=coordinates_list)

        coordinates_list = self.grid_with_points_below_magnification_threshold_removed(
            lensing_obj=lensing_obj, grid=coordinates_list)

        if not self.use_upscaling:

            return grids.GridIrregularGrouped(grid=coordinates_list)

        pixel_scale = self.grid.pixel_scale

        while pixel_scale > self.pixel_scale_precision:

            refined_coordinates_list = []

            for coordinate in coordinates_list:

                refined_coordinates = self.refined_coordinates_from_coordinate(
                    coordinate=coordinate,
                    pixel_scale=pixel_scale,
                    lensing_obj=lensing_obj,
                    source_plane_coordinate=source_plane_coordinate,
                )

                if refined_coordinates is not None:
                    refined_coordinates_list += refined_coordinates

            refined_coordinates_list = grid_remove_duplicates(
                grid=np.asarray(refined_coordinates_list))

            pixel_scale = pixel_scale / self.upscale_factor

            coordinates_list = refined_coordinates_list

        coordinates_list = self.grid_within_distance_of_source_plane_centre(
            lensing_obj=lensing_obj,
            grid=grids.GridIrregularGroupedUniform(grid=coordinates_list,
                                                   pixel_scales=(pixel_scale,
                                                                 pixel_scale)),
            source_plane_coordinate=source_plane_coordinate,
            distance=self.distance_from_source_centre,
        )

        coordinates_list = self.grid_with_points_below_magnification_threshold_removed(
            lensing_obj=lensing_obj, grid=coordinates_list)

        return grids.GridIrregularGrouped(grid=coordinates_list)
 def solve_from_tracer(self, tracer):
     """Needs work - idea is it solves for all image plane multiple image positions using the redshift distribution of
     the tracer."""
     return grids.GridIrregularGrouped(grid=[
         self.solve(lensing_obj=tracer, source_plane_coordinate=centre)
         for centre in tracer.light_profile_centres.in_grouped_list[-1]
     ])
Exemple #3
0
    def image_plane_multiple_image_positions_of_source_plane_centres(
        self,
    ) -> grids.GridIrregularGrouped:
        """Backwards ray-trace the source-plane centres (see above) to the image-plane via the mass model, to determine
        the multiple image position of the source(s) in the image-plane..

        These image-plane positions are used by the next phase in a pipeline if automatic position updating is turned
        on."""

        # TODO : In the future, the multiple image positions functioon wil use an in-built adaptive grid.

        grid = self.analysis.masked_dataset.mask.geometry.unmasked_grid_sub_1

        solver = pos.PositionsFinder(grid=grid, pixel_scale_precision=0.001)

        try:
            multiple_images = [
                solver.solve(
                    lensing_obj=self.max_log_likelihood_tracer,
                    source_plane_coordinate=centre,
                )
                for centre in self.source_plane_centres.in_grouped_list[0]
            ]
            return grids.GridIrregularGrouped(grid=multiple_images)
        except IndexError:
            return None
    def source_plane_centres(self) -> grids.GridIrregularGrouped:
        """Combine the source-plane light profile and inversion centres (see above) into a single list of source-plane
        centres.

        These centres are used by automatic position updating to determine the multiple-images of a best-fit lens model
        (and thus tracer) by back-tracing the centres to the image plane via the mass model."""

        centres = list(self.source_plane_light_profile_centres) + list(
            self.source_plane_inversion_centres)

        return grids.GridIrregularGrouped(grid=centres)
Exemple #5
0
    def mass_profile_centres(self):
        """
        Returns the mass profile centres of the tracer as a `GridIrregularGrouped` object, which structures the centres
            in lists according to which plane they come from.

            Fo example, if the tracer has two planes, the first with one mass profile and second with two mass profiles
            this returns:

            [[(y0, x0)], [(y0, x0), (y1, x1)]]

            This is used for visualization, for example plotting the centres of all mass profiles colored by their galaxy.

            The centres of mass-sheets are filtered out, as their centres are not relevant to lensing calculations

        """
        return grids.GridIrregularGrouped([
            list(plane.mass_profile_centres) for plane in self.planes
            if plane.has_mass_profile
        ])