How to use the autoarray.grid.uniform 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 / test_autolens / unit / data / test_imaging.py View on Github external
def test__from_tracer__same_as_manual_tracer_input(self):
        psf = aa.kernel.manual_2d(
            array=np.array([[0.0, 1.0, 0.0], [1.0, 2.0, 1.0], [0.0, 1.0, 0.0]]),
            pixel_scales=1.0,
        )

        grid = aa.grid.uniform(
            shape_2d=(20, 20), pixel_scales=0.05, sub_size=1
        )

        lens_galaxy = al.Galaxy(
            redshift=0.5,
            light=al.light_profiles.EllipticalSersic(intensity=1.0),
            mass=al.mass_profiles.EllipticalIsothermal(einstein_radius=1.6),
        )

        source_galaxy = al.Galaxy(
            redshift=1.0, light=al.light_profiles.EllipticalSersic(intensity=0.3)
        )

        tracer = al.Tracer.from_galaxies(galaxies=[lens_galaxy, source_galaxy])

        imaging_data_simulated_via_tracer = al.SimulatedImagingData.from_tracer_grid_and_exposure_arrays(
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_uv_plane.py View on Github external
def test__from_tracer__same_as_manual_tracer_input(self, transformer_7x7_7):

        grid = aa.grid.uniform(
            shape_2d=(20, 20), pixel_scales=0.05, sub_size=1
        )

        lens_galaxy = al.Galaxy(
            redshift=0.5,
            light=al.light_profiles.EllipticalSersic(intensity=1.0),
            mass=al.mass_profiles.EllipticalIsothermal(einstein_radius=1.6),
        )

        source_galaxy = al.Galaxy(
            redshift=1.0, light=al.light_profiles.EllipticalSersic(intensity=0.3)
        )

        tracer = al.Tracer.from_galaxies(galaxies=[lens_galaxy, source_galaxy])

        uv_plane_data_simulated_via_tracer = al.SimulatedUVPlaneData.from_tracer_grid_and_exposure_arrays(
github Jammy2211 / PyAutoLens / autolens / simulate / simulator.py View on Github external
def from_deflections_and_galaxies(
        self,
        deflections,
        galaxies,
        name=None,
    ):

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

        deflected_grid = grid - deflections.in_1d_binned

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

        return self.from_image(
            image=image_2d,
            name=name,
        )
github Jammy2211 / PyAutoLens / autolens / data / imaging.py View on Github external
pixel_scales,
        galaxies,
        exposure_time,
        psf=None,
        exposure_time_map=None,
        background_sky_level=0.0,
        background_sky_map=None,
        add_noise=True,
        noise_if_add_noise_false=0.1,
        noise_seed=-1,
        name=None,
    ):

        shape = (deflections.mask.shape[0], deflections.mask.shape[1])

        grid = aa.grid.uniform(
            shape_2d=shape, pixel_scales=pixel_scales, sub_size=1
        )

        deflected_grid_1d = grid.in_1d - deflections.in_1d

        image_2d = sum(
            map(lambda g: g.profile_image_from_grid(grid=deflected_grid_1d), galaxies)
        )

        return cls.from_image_and_exposure_arrays(
            image=image_2d,
            pixel_scales=pixel_scales,
            exposure_time=exposure_time,
            psf=psf,
            exposure_time_map=exposure_time_map,
            background_sky_level=background_sky_level,
github Jammy2211 / PyAutoLens / autolens / data / uv_plane.py View on Github external
cls,
        deflections,
        pixel_scales,
        galaxies,
        exposure_time,
        transformer,
        primary_beam=None,
        exposure_time_map=None,
        background_sky_level=0.0,
        background_sky_map=None,
        noise_sigma=None,
        noise_if_add_noise_false=0.1,
        noise_seed=-1,
    ):

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

        deflected_grid_1d = grid.in_1d - deflections.in_1d

        image_2d = sum(
            map(lambda g: g.profile_image_from_grid(grid=deflected_grid_1d), galaxies)
        )

        return cls.from_image_and_exposure_arrays(
            image=image_2d,
            pixel_scales=pixel_scales,
            exposure_time=exposure_time,
            exposure_time_map=exposure_time_map,
            background_sky_level=background_sky_level,
            background_sky_map=background_sky_map,
github Jammy2211 / PyAutoLens / autolens / simulate / simulator.py View on Github external
"""Simulate Imaging data_type for this data_type, as follows:

        1)  Setup the image-plane al.ogrid of the Imaging arrays, which defines the coordinates used for the ray-tracing.

        2) Use this grid and the lens and source galaxies to setup a tracer, which generates the image of \
           the simulated Imaging data_type.

        3) Simulate the Imaging data_type, using a special image which ensures edge-effects don't
           degrade simulate of the telescope optics (e.g. the PSF convolution).

        4) Plot the image using Matplotlib, if the plot_imaging bool is True.

        5) Output the simulate to .fits format if a data_path and data_name are specified. Otherwise, return the simulated \
           imaging data_type instance."""

        grid = aa.grid.uniform(
            shape_2d=self.shape, pixel_scales=self.psf.pixel_scales, sub_size=sub_size
        )

        tracer = ray_tracing.Tracer.from_galaxies(galaxies=galaxies)

        imaging = self.from_tracer_and_grid(
            tracer=tracer,
            grid=grid,
        )

        if should_plot_imaging:
            imaging_plotters.subplot(imaging=imaging)

        return imaging