Example #1
0
    def _invert_base(self,
                     context,
                     extra='',
                     fluxthreshold=1.0,
                     positionthreshold=1.0,
                     check_components=True,
                     facets=1,
                     vis_slices=1,
                     **kwargs):

        dirty = invert_component(self.vis_list,
                                 self.model_graph,
                                 context=context,
                                 dopsf=False,
                                 normalize=True,
                                 facets=facets,
                                 vis_slices=vis_slices,
                                 **kwargs)[0]
        dirty = arlexecute.compute(dirty, sync=True)

        export_image_to_fits(
            dirty[0], '%s/test_imaging_invert_%s%s_%s_dirty.fits' %
            (self.dir, context, extra, arlexecute.type()))

        assert numpy.max(numpy.abs(dirty[0].data)), "Image is empty"

        if check_components:
            self._checkcomponents(dirty[0], fluxthreshold, positionthreshold)
Example #2
0
    def _predict_base(self,
                      context='2d',
                      extra='',
                      fluxthreshold=1.0,
                      facets=1,
                      vis_slices=1,
                      **kwargs):
        vis_list = zero_vislist_component(self.vis_list)
        vis_list = predict_component(vis_list,
                                     self.model_graph,
                                     context=context,
                                     vis_slices=vis_slices,
                                     facets=facets,
                                     **kwargs)
        vis_list = subtract_vislist_component(self.vis_list, vis_list)[0]

        vis_list = arlexecute.compute(vis_list, sync=True)

        dirty = invert_component([vis_list], [self.model_graph[0]],
                                 context='2d',
                                 dopsf=False,
                                 normalize=True)[0]
        dirty = arlexecute.compute(dirty, sync=True)

        assert numpy.max(numpy.abs(dirty[0].data)), "Residual image is empty"
        export_image_to_fits(
            dirty[0], '%s/test_imaging_predict_%s%s_%s_dirty.fits' %
            (self.dir, context, extra, arlexecute.type()))

        maxabs = numpy.max(numpy.abs(dirty[0].data))
        assert maxabs < fluxthreshold, "Error %.3f greater than fluxthreshold %.3f " % (
            maxabs, fluxthreshold)
 def test_deconvolve_spectral(self):
     self.actualSetUp(add_errors=True)
     dirty_imagelist = invert_component(self.vis_list, self.model_imagelist,
                                        context='2d',
                                        dopsf=False, normalize=True)
     psf_imagelist = invert_component(self.vis_list, self.model_imagelist,
                                      context='2d',
                                      dopsf=True, normalize=True)
     deconvolved, _ = deconvolve_component(dirty_imagelist, psf_imagelist, self.model_imagelist, niter=1000,
                                           fractional_threshold=0.1, scales=[0, 3, 10],
                                           threshold=0.1, gain=0.7)
     deconvolved = arlexecute.compute(deconvolved, sync=True)
     
     export_image_to_fits(deconvolved[0], '%s/test_imaging_%s_deconvolve_spectral.fits' %
                          (self.dir, arlexecute.type()))
Example #4
0
    def test_weighting(self):

        self.actualSetUp()

        context = 'wstack'
        vis_slices = 41
        facets = 1

        dirty_graph = invert_component(self.vis_list,
                                       self.model_graph,
                                       context=context,
                                       dopsf=False,
                                       normalize=True,
                                       facets=facets,
                                       vis_slices=vis_slices)
        dirty = arlexecute.compute(dirty_graph[0], sync=True)
        export_image_to_fits(
            dirty[0], '%s/test_imaging_noweighting_%s_dirty.fits' %
            (self.dir, arlexecute.type()))
 def test_deconvolve_and_restore_cube_mmclean_facets(self):
     self.actualSetUp(add_errors=True)
     dirty_imagelist = invert_component(self.vis_list, self.model_imagelist,
                                        context='2d', dopsf=False, normalize=True)
     psf_imagelist = invert_component(self.vis_list, self.model_imagelist,
                                      context='2d', dopsf=True, normalize=True)
     dec_imagelist, _ = deconvolve_component(dirty_imagelist, psf_imagelist, self.model_imagelist, niter=1000,
                                             fractional_threshold=0.1, scales=[0, 3, 10],
                                             algorithm='mmclean', nmoments=3, nchan=self.freqwin,
                                             threshold=0.01, gain=0.7, deconvolve_facets=8,
                                             deconvolve_overlap=8, deconvolve_taper='tukey')
     residual_imagelist = residual_component(self.vis_list, model_imagelist=dec_imagelist,
                                             context='2d')
     restored = restore_component(model_imagelist=dec_imagelist, psf_imagelist=psf_imagelist,
                                  residual_imagelist=residual_imagelist,
                                  empty=self.model_imagelist)[0]
     
     restored = arlexecute.compute(restored, sync=True)
     
     export_image_to_fits(restored, '%s/test_imaging_%s_overlap_mmclean_restored.fits'
                          % (self.dir, arlexecute.type()))
Example #6
0
    def test_calskymodel_solve_component(self):

        self.actualSetup(doiso=True)

        self.skymodel_list = [
            arlexecute.execute(SkyModel, nout=1)(components=[cm])
            for cm in self.components
        ]

        calskymodel_list = calskymodel_solve_component(
            self.vis, skymodel_list=self.skymodel_list, niter=30, gain=0.25)
        skymodel, residual_vis = arlexecute.compute(calskymodel_list,
                                                    sync=True)

        residual_vis = convert_blockvisibility_to_visibility(residual_vis)
        residual_vis, _, _ = weight_visibility(residual_vis, self.beam)
        dirty, sumwt = invert_function(residual_vis, self.beam, context='2d')
        export_image_to_fits(
            dirty, "%s/test_calskymodel-%s-final-iso-residual.fits" %
            (self.dir, arlexecute.type()))

        qa = qa_image(dirty)
        assert qa.data['rms'] < 3.2e-3, qa