Beispiel #1
0
    def test_create_low_test_beam(self):
        im = create_test_image(
            canonical=True,
            cellsize=0.002,
            frequency=numpy.array([1e8 - 5e7, 1e8, 1e8 + 5e7]),
            channel_bandwidth=numpy.array([5e7, 5e7, 5e7]),
            polarisation_frame=PolarisationFrame("stokesIQUV"),
            phasecentre=self.phasecentre)
        bm = create_low_test_beam(model=im)
        export_image_to_fits(bm,
                             '%s/test_test_support_low_beam.fits' % (self.dir))

        assert bm.data.shape[0] == 3
        assert bm.data.shape[1] == 4
        assert bm.data.shape[2] == im.data.shape[2]
        assert bm.data.shape[3] == im.data.shape[3]
        # Check to see if the beam scales as expected
        for i in [30, 40]:
            assert numpy.max(
                numpy.abs(bm.data[0, 0, 128, 128 - 2 * i] -
                          bm.data[1, 0, 128, 128 - i])) < 0.02
            assert numpy.max(
                numpy.abs(bm.data[0, 0, 128, 128 - 3 * i] -
                          bm.data[2, 0, 128, 128 - i])) < 0.02
            assert numpy.max(
                numpy.abs(bm.data[0, 0, 128 - 2 * i, 128] -
                          bm.data[1, 0, 128 - i, 128])) < 0.02
            assert numpy.max(
                numpy.abs(bm.data[0, 0, 128 - 3 * i, 128] -
                          bm.data[2, 0, 128 - i, 128])) < 0.02
Beispiel #2
0
    def test_create_gaintable_from_screen(self):
        screen = import_image_from_fits(
            arl_path('data/models/test_mpc_screen.fits'))
        beam = create_test_image(cellsize=0.0015,
                                 phasecentre=self.vis.phasecentre,
                                 frequency=self.frequency)

        beam = create_low_test_beam(beam)

        gleam_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.2)

        pb_gleam_components = apply_beam_to_skycomponent(
            gleam_components, beam)

        actual_components = filter_skycomponents_by_flux(pb_gleam_components,
                                                         flux_min=1.0)

        gaintables = create_gaintable_from_screen(self.vis, actual_components,
                                                  screen)
        assert len(gaintables) == len(actual_components), len(gaintables)
        assert gaintables[0].gain.shape == (3, 94, 1, 1,
                                            1), gaintables[0].gain.shape
    def test_partition_skycomponent_neighbours(self):
        all_components = create_low_test_skycomponents_from_gleam(
            flux_limit=0.1,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.5)

        bright_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.5)
        model = create_image(npixel=512,
                             cellsize=0.001,
                             phasecentre=self.phasecentre,
                             frequency=self.frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
        beam = create_low_test_beam(model)
        all_components = apply_beam_to_skycomponent(all_components, beam)
        all_components = filter_skycomponents_by_flux(all_components,
                                                      flux_min=0.1)
        bright_components = apply_beam_to_skycomponent(bright_components, beam)
        bright_components = filter_skycomponents_by_flux(bright_components,
                                                         flux_min=2.0)

        comps_lists = partition_skycomponent_neighbours(
            all_components, bright_components)
        assert len(comps_lists) == len(bright_components)
        assert len(comps_lists[0]) > 0
        assert len(comps_lists[-1]) > 0
    def test_expand_skymodel_by_skycomponents(self):
        beam = create_test_image(cellsize=0.0015,
                                 phasecentre=self.vis.phasecentre,
                                 frequency=self.frequency)

        beam = create_low_test_beam(beam, use_local=False)

        gleam_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.2)

        pb_gleam_components = apply_beam_to_skycomponent(
            gleam_components, beam)

        actual_components = filter_skycomponents_by_flux(pb_gleam_components,
                                                         flux_min=1.0)

        assert len(actual_components) == 37, len(actual_components)
        sm = SkyModel(image=self.model, components=actual_components)
        assert len(sm.components) == len(actual_components)

        scatter_sm = expand_skymodel_by_skycomponents(sm)
        assert len(scatter_sm) == len(actual_components) + 1
        assert len(scatter_sm[0].components) == 1
    def setUp(self):
        from data_models.parameters import arl_path
        self.dir = arl_path('test_results')
        self.niter = 1000
        self.lowcore = create_named_configuration('LOWBD2-CORE')
        self.nchan = 5
        self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7)
        self.frequency = numpy.linspace(0.9e8, 1.1e8, self.nchan)
        self.channel_bandwidth = numpy.array(
            self.nchan * [self.frequency[1] - self.frequency[0]])
        self.phasecentre = SkyCoord(ra=+0.0 * u.deg,
                                    dec=-45.0 * u.deg,
                                    frame='icrs',
                                    equinox='J2000')
        self.vis = create_visibility(
            self.lowcore,
            self.times,
            self.frequency,
            self.channel_bandwidth,
            phasecentre=self.phasecentre,
            weight=1.0,
            polarisation_frame=PolarisationFrame('stokesI'),
            zerow=True)
        self.vis.data['vis'] *= 0.0

        # Create model
        self.test_model = create_low_test_image_from_gleam(
            npixel=512,
            cellsize=0.001,
            phasecentre=self.vis.phasecentre,
            frequency=self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            flux_limit=1.0)
        beam = create_low_test_beam(self.test_model)
        export_image_to_fits(beam,
                             "%s/test_deconvolve_mmclean_beam.fits" % self.dir)
        self.test_model.data *= beam.data
        export_image_to_fits(
            self.test_model,
            "%s/test_deconvolve_mmclean_model.fits" % self.dir)
        self.vis = predict_2d(self.vis, self.test_model)
        assert numpy.max(numpy.abs(self.vis.vis)) > 0.0
        self.model = create_image_from_visibility(
            self.vis,
            npixel=512,
            cellsize=0.001,
            polarisation_frame=PolarisationFrame('stokesI'))
        self.dirty, sumwt = invert_2d(self.vis, self.model)
        self.psf, sumwt = invert_2d(self.vis, self.model, dopsf=True)
        export_image_to_fits(
            self.dirty, "%s/test_deconvolve_mmclean-dirty.fits" % self.dir)
        export_image_to_fits(self.psf,
                             "%s/test_deconvolve_mmclean-psf.fits" % self.dir)
        window = numpy.ones(shape=self.model.shape, dtype=numpy.bool)
        window[..., 129:384, 129:384] = True
        self.innerquarter = create_image_from_array(
            window,
            self.model.wcs,
            polarisation_frame=PolarisationFrame('stokesI'))
    def test_voronoi_decomposition(self):
        bright_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.5)
        model = create_image(npixel=512,
                             cellsize=0.001,
                             phasecentre=self.phasecentre,
                             frequency=self.frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
        beam = create_low_test_beam(model)
        bright_components = apply_beam_to_skycomponent(bright_components, beam)
        bright_components = filter_skycomponents_by_flux(bright_components,
                                                         flux_min=2.0)

        vor, vor_array = voronoi_decomposition(model, bright_components)
        assert len(bright_components) == (numpy.max(vor_array) + 1)
    def test_expand_skymodel_voronoi(self):
        self.model = create_image(
            npixel=256,
            cellsize=0.001,
            polarisation_frame=PolarisationFrame("stokesI"),
            frequency=self.frequency,
            channel_bandwidth=self.channel_bandwidth,
            phasecentre=self.phasecentre)
        beam = create_low_test_beam(self.model, use_local=False)

        gleam_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.1)

        pb_gleam_components = apply_beam_to_skycomponent(
            gleam_components, beam)

        actual_components = filter_skycomponents_by_flux(pb_gleam_components,
                                                         flux_min=1.0)
        _, actual_components = remove_neighbouring_components(
            actual_components, 0.05)

        for imask, mask in enumerate(
                image_voronoi_iter(self.model, actual_components)):
            mask.data *= beam.data
            assert isinstance(mask, Image)
            assert mask.data.dtype == "float"
            assert numpy.sum(mask.data) > 1
            # import matplotlib.pyplot as plt
            # from processing_components.image.operations import show_image
            # show_image(mask)
            # plt.show()

        assert len(actual_components) == 9, len(actual_components)
        sm = SkyModel(image=self.model, components=actual_components)
        assert len(sm.components) == len(actual_components)

        scatter_sm = expand_skymodel_by_skycomponents(sm)
        assert len(scatter_sm) == len(actual_components) + 1
        assert len(scatter_sm[0].components) == 1
    def test_image_voronoi_iter(self):
        bright_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.5)
        model = create_image(npixel=512,
                             cellsize=0.001,
                             phasecentre=self.phasecentre,
                             frequency=self.frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
        model.data[...] = 1.0
        beam = create_low_test_beam(model)
        bright_components = apply_beam_to_skycomponent(bright_components, beam)
        bright_components = filter_skycomponents_by_flux(bright_components,
                                                         flux_min=2.0)

        for im in image_voronoi_iter(model, bright_components):
            assert numpy.sum(im.data) > 1
Beispiel #9
0
    def test_grid_gaintable_to_screen(self):
        screen = import_image_from_fits(
            arl_path('data/models/test_mpc_screen.fits'))
        beam = create_test_image(cellsize=0.0015,
                                 phasecentre=self.vis.phasecentre,
                                 frequency=self.frequency)

        beam = create_low_test_beam(beam, use_local=False)

        gleam_components = create_low_test_skycomponents_from_gleam(
            flux_limit=1.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.2)

        pb_gleam_components = apply_beam_to_skycomponent(
            gleam_components, beam)

        actual_components = filter_skycomponents_by_flux(pb_gleam_components,
                                                         flux_min=1.0)

        gaintables = create_gaintable_from_screen(self.vis, actual_components,
                                                  screen)
        assert len(gaintables) == len(actual_components), len(gaintables)
        assert gaintables[0].gain.shape == (3, 94, 3, 1,
                                            1), gaintables[0].gain.shape

        newscreen = create_empty_image_like(screen)

        newscreen, weights = grid_gaintable_to_screen(self.vis, gaintables,
                                                      newscreen)
        assert numpy.max(numpy.abs(screen.data)) > 0.0
        if self.persist:
            export_image_to_fits(
                newscreen,
                arl_path('test_results/test_mpc_screen_gridded.fits'))
        if self.persist:
            export_image_to_fits(
                weights,
                arl_path('test_results/test_mpc_screen_gridded_weights.fits'))
    def test_remove_neighbouring_components(self):
        all_components = create_low_test_skycomponents_from_gleam(
            flux_limit=3.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.5)

        model = create_image(npixel=512,
                             cellsize=0.001,
                             phasecentre=self.phasecentre,
                             frequency=self.frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
        beam = create_low_test_beam(model)
        all_components = apply_beam_to_skycomponent(all_components, beam)
        all_components = filter_skycomponents_by_flux(all_components,
                                                      flux_min=0.1)

        idx, comps = remove_neighbouring_components(all_components, 0.1)
        assert idx == [0, 3, 5, 6, 7, 8, 10, 12, 14, 16, 19], idx
        assert comps[0].name == 'GLEAM J234118-581606', comps[0].name
    def test_remove_neighbouring_components(self):
        all_components = create_low_test_skycomponents_from_gleam(
            flux_limit=3.0,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=0.5)

        model = create_image(npixel=512,
                             cellsize=0.001,
                             phasecentre=self.phasecentre,
                             frequency=self.frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
        beam = create_low_test_beam(model, use_local=False)
        all_components = apply_beam_to_skycomponent(all_components, beam)
        all_components = filter_skycomponents_by_flux(all_components,
                                                      flux_min=0.1)

        idx, comps = remove_neighbouring_components(all_components, 0.1)
        assert idx == [
            0, 1, 3, 8, 12, 13, 17, 22, 25, 26, 29, 32, 35, 38, 41, 42, 46, 47,
            50, 52, 53, 56, 57, 58, 61, 63, 66, 68, 70
        ], idx
        assert comps[0].name == 'GLEAM J215739-661155', comps[0].name