How to use the autoarray.structures.grids.Grid function in autoarray

To help you get started, we’ve selected a few autoarray 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 / autolens / lens / positions_solver.py View on Github external
)

        trough_pixels = trough_pixels_from(
            array_2d=source_plane_squared_distances.in_2d, mask=self.initial_grid.mask
        )

        trough_mask = msk.Mask.from_pixel_coordinates(
            shape_2d=self.initial_grid.shape_2d,
            pixel_coordinates=trough_pixels,
            pixel_scales=self.initial_grid.pixel_scales,
            sub_size=self.initial_grid.sub_size,
            origin=self.initial_grid.origin,
            buffer=1,
        )

        trough_grid = grids.Grid.from_mask(mask=trough_mask)

        deflections = lensing_obj.deflections_from_grid(grid=trough_grid)
        source_plane_grid = trough_grid.grid_from_deflection_grid(
            deflection_grid=deflections
        )

        source_plane_squared_distances = source_plane_grid.squared_distances_from_coordinate(
            coordinate=source_plane_coordinate
        )
github Jammy2211 / PyAutoLens / autolens / dataset / imaging.py View on Github external
def __init__(
        self,
        imaging,
        mask,
        grid_class=grids.Grid,
        grid_inversion_class=grids.Grid,
        fractional_accuracy=0.9999,
        sub_steps=[2, 4, 8, 16],
        pixel_scales_interp=None,
        psf_shape_2d=None,
        inversion_pixel_limit=None,
        inversion_uses_border=True,
        inversion_stochastic=False,
        positions_threshold=None,
        renormalize_psf=True,
        preload_sparse_grids_of_planes=None,
    ):
        """
        The lens dataset is the collection of data (image, noise-map, PSF), a mask, grid, convolver \
        and other utilities that are used for modeling and fitting an image of a strong lens.

        Whilst the image, noise-map, etc. are loaded in 2D, the lens dataset creates reduced 1D arrays of each \
github Jammy2211 / PyAutoLens / autolens / pipeline / phase / settings.py View on Github external
def __init__(
        self,
        grid_class=grids.Grid,
        grid_inversion_class=grids.Grid,
        sub_size=2,
        fractional_accuracy=0.9999,
        sub_steps=None,
        signal_to_noise_limit=None,
        bin_up_factor=None,
        inversion_pixel_limit=None,
        psf_shape_2d=None,
        pixel_scales_interp=None,
        auto_positions_factor=None,
        positions_threshold=None,
        inversion_uses_border=True,
        inversion_stochastic=False,
        log_likelihood_cap=None,
    ):
github Jammy2211 / PyAutoLens / autolens / simulator / simulator.py View on Github external
def from_deflections_and_galaxies(self, deflections, galaxies):

        grid = grids.Grid.uniform(
            shape_2d=deflections.shape_2d,
            pixel_scales=deflections.pixel_scales,
            sub_size=1,
        )

        deflected_grid = grid - deflections.in_1d_binned

        image = sum(
            map(lambda g: g.profile_image_from_grid(grid=deflected_grid), galaxies)
        )

        return self.from_image(image=image)
github Jammy2211 / PyAutoLens / autolens / lens / positions_solver.py View on Github external
def mask_trough_from(self, lensing_obj, source_plane_coordinate, mask, buffer=1):

        grid = grids.Grid.from_mask(mask=mask)

        deflections = lensing_obj.deflections_from_grid(grid=grid)
        source_plane_grid = grid.grid_from_deflection_grid(deflection_grid=deflections)
        source_plane_squared_distances = source_plane_grid.squared_distances_from_coordinate(
            coordinate=source_plane_coordinate
        )

        trough_pixels = trough_pixels_from(
            array_2d=source_plane_squared_distances.in_2d, mask=mask
        )

        return msk.Mask.from_pixel_coordinates(
            shape_2d=grid.shape_2d,
            pixel_coordinates=trough_pixels,
            pixel_scales=grid.pixel_scales,
            sub_size=grid.sub_size,
github Jammy2211 / PyAutoLens / autolens / util / lens_util.py View on Github external
def plane_image_of_galaxies_from_grid(shape, grid, galaxies, buffer=1.0e-2):

    y_min = np.min(grid[:, 0]) - buffer
    y_max = np.max(grid[:, 0]) + buffer
    x_min = np.min(grid[:, 1]) - buffer
    x_max = np.max(grid[:, 1]) + buffer

    pixel_scales = (
        float((y_max - y_min) / shape[0]),
        float((x_max - x_min) / shape[1]),
    )
    origin = ((y_max + y_min) / 2.0, (x_max + x_min) / 2.0)

    uniform_grid = grids.Grid.uniform(
        shape_2d=shape, pixel_scales=pixel_scales, sub_size=1, origin=origin
    )

    image = sum(map(lambda g: g.profile_image_from_grid(grid=uniform_grid), galaxies))

    return pl.PlaneImage(array=image, grid=grid)
github Jammy2211 / PyAutoLens / autolens / pipeline / phase / settings.py View on Github external
def __init__(
        self,
        grid_class=grids.Grid,
        grid_inversion_class=grids.Grid,
        sub_size=2,
        fractional_accuracy=0.9999,
        sub_steps=None,
        pixel_scales_interp=None,
        signal_to_noise_limit=None,
        bin_up_factor=None,
        inversion_pixel_limit=None,
        transformer_class=transformer.TransformerNUFFT,
        primary_beam_shape_2d=None,
        auto_positions_factor=None,
        positions_threshold=None,
        inversion_uses_border=True,
        inversion_stochastic=False,
        log_likelihood_cap=None,
    ):
github Jammy2211 / PyAutoLens / autolens / dataset / interferometer.py View on Github external
def __init__(
        self,
        interferometer,
        visibilities_mask,
        real_space_mask,
        grid_class=grids.Grid,
        grid_inversion_class=grids.Grid,
        fractional_accuracy=0.9999,
        sub_steps=None,
        pixel_scales_interp=None,
        transformer_class=transformer.TransformerNUFFT,
        primary_beam_shape_2d=None,
        inversion_pixel_limit=None,
        inversion_uses_border=True,
        inversion_stochastic=False,
        positions_threshold=None,
        renormalize_primary_beam=True,
        preload_sparse_grids_of_planes=None,
    ):
        """
        The lens dataset is the collection of data (image, noise-map, primary_beam), a mask, grid, convolver \
        and other utilities that are used for modeling and fitting an image of a strong lens.
github Jammy2211 / PyAutoLens / autolens / dataset / interferometer.py View on Github external
def from_deflections_and_galaxies(self, deflections, galaxies, name=None):

        grid = grids.Grid.uniform(
            shape_2d=deflections.shape_2d,
            pixel_scales=deflections.pixel_scales,
            sub_size=1,
        )

        deflected_grid = grid - deflections.in_1d_binned

        image = sum(map(lambda g: g.image_from_grid(grid=deflected_grid), galaxies))

        return self.from_image(image=image, name=name)
github Jammy2211 / PyAutoLens / autolens / dataset / interferometer.py View on Github external
def __init__(
        self,
        interferometer,
        visibilities_mask,
        real_space_mask,
        grid_class=grids.Grid,
        grid_inversion_class=grids.Grid,
        fractional_accuracy=0.9999,
        sub_steps=None,
        pixel_scales_interp=None,
        transformer_class=transformer.TransformerNUFFT,
        primary_beam_shape_2d=None,
        inversion_pixel_limit=None,
        inversion_uses_border=True,
        inversion_stochastic=False,
        positions_threshold=None,
        renormalize_primary_beam=True,
        preload_sparse_grids_of_planes=None,
    ):
        """
        The lens dataset is the collection of data (image, noise-map, primary_beam), a mask, grid, convolver \
        and other utilities that are used for modeling and fitting an image of a strong lens.