How to use the autoarray.array 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__signal_to_noise_limit_below_max_signal_to_noise__signal_to_noise_map_capped_to_limit(
            self
        ):
            image = aa.array.full(fill_value=20.0, shape_2d=(2,2))
            image[3] = 5.0

            noise_map_array = aa.array.full(fill_value=5.0, shape_2d=(2,2))
            noise_map_array[3] = 2.0

            imaging_data = al.ImagingData(
                image=image,
                psf=aa.kernel.zeros(shape_2d=(3,3)),
                noise_map=noise_map_array,
                background_noise_map=aa.array.full(fill_value=1.0, shape_2d=(2,2)),
                exposure_time_map=aa.array.full(fill_value=2.0, shape_2d=(2,2)),
                background_sky_map=aa.array.full(fill_value=3.0, shape_2d=(2,2)),
            )

            imaging_data_capped = imaging_data.signal_to_noise_limited_data_from_signal_to_noise_limit(
                signal_to_noise_limit=2.0
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_abstract_data.py View on Github external
def test__from_background_noise_map__covnerts_to_exposure_times(self):
        background_noise_map = aa.array.manual_2d([[1.0, 4.0, 8.0], [1.0, 4.0, 8.0]])

        exposure_time_map = al.ExposureTimeMap.from_exposure_time_and_inverse_noise_map(
            exposure_time=1.0,
            inverse_noise_map=background_noise_map,
        )

        assert (
            exposure_time_map.in_2d
            == np.array([[0.125, 0.5, 1.0], [0.125, 0.5, 1.0]])
        ).all()

        exposure_time_map = al.ExposureTimeMap.from_exposure_time_and_inverse_noise_map(
            exposure_time=3.0,
            inverse_noise_map=background_noise_map,
        )
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_abstract_data.py View on Github external
def test__same_as_above__but_image_has_negative_values__replaced_with_zeros(self):
        array = aa.array.manual_2d([[-1.0, 2.0], [3.0, -4.0]])

        noise_map = aa.array.manual_2d([[10.0, 10.0], [30.0, 4.0]])

        data = al.AbstractData(data=array, noise_map=noise_map)

        assert (data.signal_to_noise_map.in_2d == np.array([[0.0, 0.2], [0.1, 0.0]])).all()
        assert data.signal_to_noise_max == 0.2
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_uv_plane.py View on Github external
def test__setup_with_background_sky_on__noise_off__no_noise_in_image__noise_map_is_noise_value(
        self, transformer_7x7_7
    ):
        image = aa.array.manual_2d([[2.0, 0.0, 0.0], [0.0, 1.0, 0.0], [3.0, 0.0, 0.0]])

        exposure_time_map = aa.array.full(
            fill_value=1.0, pixel_scales=0.1, shape_2d=image.shape_2d
        )

        background_sky_map = aa.array.full(
            fill_value=2.0, pixel_scales=0.1, shape_2d=image.shape_2d
        )

        uv_plane_data_simulated = al.SimulatedUVPlaneData.from_image_and_exposure_arrays(
            image=image,
            pixel_scales=0.1,
            exposure_time=1.0,
            exposure_time_map=exposure_time_map,
            background_sky_map=background_sky_map,
            transformer=transformer_7x7_7,
            noise_sigma=None,
            noise_if_add_noise_false=0.2,
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__poisson_noise_map_from_image__include_convert_from_electrons(self):
        imaging_data = al.load_imaging_data_from_fits(
            pixel_scales=0.1,
            image_path=test_data_dir + "3x3_ones.fits",
            psf_path=test_data_dir + "3x3_twos.fits",
            noise_map_path=test_data_dir + "3x3_threes.fits",
            background_noise_map_path=test_data_dir + "3x3_fours.fits",
            poisson_noise_map_path=test_data_dir + "3x3_fives.fits",
            exposure_time_map_path=test_data_dir + "3x3_sixes.fits",
            background_sky_map_path=test_data_dir + "3x3_sevens.fits",
            renormalize_psf=False,
            poisson_noise_map_from_image=True,
            convert_from_electrons=True,
        )

        image = aa.array.ones(shape_2d=(3,3))

        poisson_noise_map_counts = al.PoissonNoiseMap.from_image_and_exposure_time_map(
            image=image,
            exposure_time_map=imaging_data.exposure_time_map,
            gain=None,
            convert_from_electrons=True,
        )

        poisson_noise_map_converted = poisson_noise_map_counts / 6.0

        assert (imaging_data.image.in_2d == np.ones((3, 3)) / 6.0).all()
        assert (imaging_data.psf.in_2d == 2.0 * np.ones((3, 3))).all()
        assert (imaging_data.noise_map.in_2d == 3.0 * np.ones((3, 3)) / 6.0).all()
        assert (
            imaging_data.background_noise_map.in_2d == 4.0 * np.ones((3, 3)) / 6.0
        ).all()
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_abstract_data.py View on Github external
def test__same_as_above__but_image_has_negative_values__replaced_with_zeros(self):
        array = aa.array.manual_2d([[-1.0, 2.0], [3.0, -4.0]])

        noise_map = aa.array.manual_2d([[10.0, 10.0], [30.0, 4.0]])

        data = al.AbstractData(data=array, noise_map=noise_map)

        assert (data.signal_to_noise_map.in_2d == np.array([[0.0, 0.2], [0.1, 0.0]])).all()
        assert data.signal_to_noise_max == 0.2
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__setup_image__correct_attributes(self):

            image = aa.array.manual_2d(
                array=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]],
            )
            psf = aa.kernel.full(fill_value=3.0, shape_2d=(3,3))
            noise_map = aa.array.manual_2d(
                array=5.0 * np.ones((3, 3)),
            )

            imaging_data = al.ImagingData(
                image=image,
                pixel_scales=0.1,
                noise_map=noise_map,
                psf=psf,
                background_noise_map=aa.array.full(fill_value=7.0, 
                    shape_2d=((3, 3)),
                ),
                poisson_noise_map=aa.array.full(fill_value=9.0,
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__same_as_above__use_different_values_in_different_array_elemets(self):
            imaging_data = aa.array.manual_2d([[1.0, 2.0], [2.0, 3.0]])
            background_noise_map = aa.array.manual_2d([[1.0, 1.0], [2.0, 3.0]])
            exposure_time_map = aa.array.manual_2d([[4.0, 3.0], [2.0, 1.0]])

            noise_map = al.NoiseMap.from_image_and_background_noise_map(
                image=imaging_data,
                background_noise_map=background_noise_map,
                gain=1.0,
                exposure_time_map=exposure_time_map,
            )

            assert (
                noise_map.in_2d
                == np.array(
                    [
                        [np.sqrt(20.0) / 4.0, np.sqrt(15.0) / 3.0],
                        [np.sqrt(20.0) / 2.0, np.sqrt(12.0)],
                    ]
github Jammy2211 / PyAutoLens / autolens / data / uv_plane.py View on Github external
add_noise: Bool
            If True poisson noise_maps is simulated and added to the image, based on the total counts in each image
            pixel
        noise_seed: int
            A seed for random noise_maps generation
        """

        if exposure_time_map is None:

            exposure_time_map = aa.array.full(
                fill_value=exposure_time, shape_2d=image.shape_2d, pixel_scales=pixel_scales
            )

        if background_sky_map is None:

            background_sky_map = aa.array.full(
                fill_value=background_sky_level, shape_2d=image.shape_2d, pixel_scales=pixel_scales
            )

        image += background_sky_map

        visibilities = transformer.visibilities_from_image(image=image)

        if noise_sigma is not None:
            noise_map_realization = gaussian_noise_map_from_shape_and_sigma(
                shape=visibilities.shape, sigma=noise_sigma, noise_seed=noise_seed
            )
            visibilities = visibilities + noise_map_realization
            noise_map = np.full(
                fill_value=noise_sigma, shape=visibilities.shape,
            )
        else: