Exemple #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
Exemple #2
0
 def actualSetUp(self, freqwin=1, block=True, dopol=False, zerow=False):
     
     self.npixel = 1024
     self.low = create_named_configuration('LOWBD2', rmax=550.0)
     self.freqwin = freqwin
     self.blockvis_list = list()
     self.ntimes = 5
     self.cellsize = 0.0005
     # Choose the interval so that the maximum change in w is smallish
     integration_time = numpy.pi * (24 / (12 * 60))
     self.times = numpy.linspace(-integration_time * (self.ntimes // 2), integration_time * (self.ntimes // 2),
                                 self.ntimes)
     
     if freqwin > 1:
         self.frequency = numpy.linspace(0.8e8, 1.2e8, self.freqwin)
         self.channelwidth = numpy.array(freqwin * [self.frequency[1] - self.frequency[0]])
     else:
         self.frequency = numpy.array([1.0e8])
         self.channelwidth = numpy.array([4e7])
     
     if dopol:
         self.vis_pol = PolarisationFrame('linear')
         self.image_pol = PolarisationFrame('stokesIQUV')
         f = numpy.array([100.0, 20.0, -10.0, 1.0])
     else:
         self.vis_pol = PolarisationFrame('stokesI')
         self.image_pol = PolarisationFrame('stokesI')
         f = numpy.array([100.0])
     
     self.phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=-40.0 * u.deg, frame='icrs', equinox='J2000')
     self.blockvis_list = [rsexecute.execute(ingest_unittest_visibility)(self.low,
                                                                          [self.frequency[freqwin]],
                                                                          [self.channelwidth[freqwin]],
                                                                          self.times,
                                                                          self.vis_pol,
                                                                          self.phasecentre, block=block,
                                                                          zerow=zerow)
                           for freqwin, _ in enumerate(self.frequency)]
     self.blockvis_list = rsexecute.compute(self.blockvis_list, sync=True)
     self.vis_list = [rsexecute.execute(convert_blockvisibility_to_visibility)(bv) for bv in self.blockvis_list]
     self.vis_list = rsexecute.compute(self.vis_list, sync=True)
     
     self.skymodel_list = [rsexecute.execute(create_low_test_skymodel_from_gleam)
                           (npixel=self.npixel, cellsize=self.cellsize, frequency=[self.frequency[f]],
                            phasecentre=self.phasecentre,
                            polarisation_frame=PolarisationFrame("stokesI"),
                            flux_limit=0.6,
                            flux_threshold=1.0,
                            flux_max=5.0) for f, freq in enumerate(self.frequency)]
     
     self.skymodel_list = rsexecute.compute(self.skymodel_list, sync=True)
     assert isinstance(self.skymodel_list[0].image, Image), self.skymodel_list[0].image
     assert isinstance(self.skymodel_list[0].components[0], Skycomponent), self.skymodel_list[0].components[0]
     assert len(self.skymodel_list[0].components) == 35, len(self.skymodel_list[0].components)
     self.skymodel_list = expand_skymodel_by_skycomponents(self.skymodel_list[0])
     assert len(self.skymodel_list) == 36, len(self.skymodel_list)
     assert numpy.max(numpy.abs(self.skymodel_list[-1].image.data)) > 0.0, "Image is empty"
     self.vis_list = [copy_visibility(self.vis_list[0], zero=True) for i, _ in enumerate(self.skymodel_list)]
Exemple #3
0
    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 rascil.processing_components.image.operations import show_image
            # show_image(mask)
            # plt.show(block=False)

        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