Пример #1
0
 def test_restored_list_facet(self):
     self.actualSetUp(zerow=True)
     
     centre = self.freqwin // 2
     psf_image_list = invert_list_rsexecute_workflow(self.vis_list, self.model_list, context='2d', dopsf=True)
     residual_image_list = residual_list_rsexecute_workflow(self.vis_list, self.model_list, context='2d')
     restored_4facets_image_list = restore_list_rsexecute_workflow(self.model_list, psf_image_list,
                                                                    residual_image_list,
                                                                    restore_facets=4, psfwidth=1.0)
     restored_4facets_image_list = rsexecute.compute(restored_4facets_image_list, sync=True)
     
     restored_1facets_image_list = restore_list_rsexecute_workflow(self.model_list, psf_image_list,
                                                                    residual_image_list,
                                                                    restore_facets=1, psfwidth=1.0)
     restored_1facets_image_list = rsexecute.compute(restored_1facets_image_list, sync=True)
     
     if self.persist: export_image_to_fits(restored_4facets_image_list[0],
                                           '%s/test_imaging_invert_%s_restored_4facets.fits' %
                                           (self.dir, rsexecute.type()))
     
     qa = qa_image(restored_4facets_image_list[centre])
     assert numpy.abs(qa.data['max'] - 99.43438263927833) < 1e-7, str(qa)
     assert numpy.abs(qa.data['min'] + 0.6328915148563354) < 1e-7, str(qa)
     
     restored_4facets_image_list[centre].data -= restored_1facets_image_list[centre].data
     if self.persist: export_image_to_fits(restored_4facets_image_list[centre],
                                           '%s/test_imaging_invert_%s_restored_4facets_error.fits' %
                                           (self.dir, rsexecute.type()))
     qa = qa_image(restored_4facets_image_list[centre])
     assert numpy.abs(qa.data['max']) < 1e-10, str(qa)
    def test_ical_pipeline_global(self):
        self.actualSetUp(add_errors=True)
        controls = create_calibration_controls()
        controls['T']['first_selfcal'] = 1
        controls['T']['timeslice'] = 'auto'
        
        clean, residual, restored, gt_list = \
            ical_list_serial_workflow(self.vis_list,
                                      model_imagelist=self.model_imagelist,
                                      context='2d',
                                      algorithm='mmclean', facets=1,
                                      scales=[0, 3, 10],
                                      niter=1000, fractional_threshold=0.1, threshold=0.1,
                                      nmoment=3,
                                      nmajor=5, gain=0.1,
                                      deconvolve_facets=4, deconvolve_overlap=32,
                                      deconvolve_taper='tukey', psf_support=64,
                                      restore_facets=4, psfwidth=1.0,
                                      calibration_context='T', controls=controls, do_selfcal=True,
                                      global_solution=True)
        
        centre = len(clean) // 2
        if self.persist:
            export_image_to_fits(clean[centre], '%s/test_pipelines_ical_global_pipeline_serial_clean.fits' % self.dir)
            export_image_to_fits(residual[centre][0], '%s/test_pipelines_ical_global_pipeline_serial_residual.fits' % self.dir)
            export_image_to_fits(restored[centre], '%s/test_pipelines_ical_global_pipeline_serial_restored.fits' % self.dir)
            export_gaintable_to_hdf5(gt_list[0]['T'],
                                     '%s/test_pipelines_ical_global_pipeline_serial_gaintable.hdf5' %
                                     self.dir)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 99.88268162471103) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] + 0.4016554844145119) < 1.0e-7, str(qa)
    def test_continuum_imaging_pipeline_pol(self):
        self.actualSetUp(add_errors=True, zerow=True, dopol=True)
        clean, residual, restored = \
            continuum_imaging_list_serial_workflow(self.vis_list,
                                                   model_imagelist=self.model_imagelist,
                                                   context='2d',
                                                   algorithm='mmclean', facets=1,
                                                   scales=[0, 3, 10],
                                                   niter=1000, fractional_threshold=0.1, threshold=0.1,
                                                   nmoment=3,
                                                   nmajor=5, gain=0.1,
                                                   deconvolve_facets=4, deconvolve_overlap=32,
                                                   deconvolve_taper='tukey', psf_support=64,
                                                   restore_facets=4, psfwidth=1.0)
        centre = len(clean) // 2
        if self.persist:
            export_image_to_fits(clean[centre],
                                 '%s/test_pipelines_continuum_imaging_pipeline_serial_clean.fits' % self.dir)
            export_image_to_fits(residual[centre][0],
                                 '%s/test_pipelines_continuum_imaging_pipeline_serial_residual.fits' % self.dir)
            export_image_to_fits(restored[centre],
                                 '%s/test_pipelines_continuum_imaging_pipeline_serial_restored.fits' % self.dir)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 99.88283258629198) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] + 0.4018872898913914) < 1.0e-7, str(qa)
    def test_continuum_imaging_pipeline_pol(self):
        self.actualSetUp(add_errors=False, zerow=True, dopol=True)
        continuum_imaging_list = \
            continuum_imaging_list_rsexecute_workflow(self.vis_list,
                                                      model_imagelist=self.model_imagelist,
                                                      context='2d',
                                                      algorithm='mmclean', facets=1,
                                                      scales=[0, 3, 10],
                                                      niter=1000, fractional_threshold=0.1, threshold=0.1,
                                                      nmoment=3,
                                                      nmajor=5, gain=0.1,
                                                      deconvolve_facets=4, deconvolve_overlap=32,
                                                      deconvolve_taper='tukey', psf_support=64,
                                                      restore_facets=4, psfwidth=1.0)
        clean, residual, restored = rsexecute.compute(continuum_imaging_list,
                                                      sync=True)
        centre = len(clean) // 2
        if self.persist:
            export_image_to_fits(
                clean[centre],
                '%s/test_pipelines_continuum_imaging_pol_pipeline_rsexecute_clean.fits'
                % self.dir)
            export_image_to_fits(
                residual[centre][0],
                '%s/test_pipelines_continuum_imaging_pipeline_pol_rsexecute_residual.fits'
                % self.dir)
            export_image_to_fits(
                restored[centre],
                '%s/test_pipelines_continuum_imaging_pipeline_pol_rsexecute_restored.fits'
                % self.dir)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 100.00806411666247) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] +
                         0.03519472493724841) < 1.0e-7, str(qa)
Пример #5
0
 def test_residual_list(self):
     self.actualSetUp(zerow=True)
 
     centre = self.freqwin // 2
     residual_image_list = residual_list_serial_workflow(self.vis_list, self.model_list, context='2d')
     qa = qa_image(residual_image_list[centre][0])
     assert numpy.abs(qa.data['max'] - 0.35139716991480785) < 1.0, str(qa)
     assert numpy.abs(qa.data['min'] + 0.7681701460717593) < 1.0, str(qa)
    def test_restored_list_facet(self):
        self.actualSetUp(zerow=True)

        centre = self.freqwin // 2
        psf_image_list = invert_list_serial_workflow(self.bvis_list,
                                                     self.model_list,
                                                     context='2d',
                                                     dopsf=True)
        residual_image_list = residual_list_serial_workflow(self.bvis_list,
                                                            self.model_list,
                                                            context='2d')
        restored_4facets_image_list = restore_list_serial_workflow(
            self.model_list,
            psf_image_list,
            residual_image_list,
            restore_facets=4,
            psfwidth=1.0)

        restored_1facets_image_list = restore_list_serial_workflow(
            self.model_list,
            psf_image_list,
            residual_image_list,
            restore_facets=1,
            psfwidth=1.0)

        if self.persist:
            export_image_to_fits(
                restored_4facets_image_list[0],
                '%s/test_imaging_invert_serial_restored_4facets.fits' %
                (self.dir))

        qa = qa_image(restored_4facets_image_list[centre])
        assert numpy.abs(qa.data['max'] - 100.00291168642293) < 1e-7, str(qa)
        assert numpy.abs(qa.data['min'] + 0.1698056648051111) < 1e-7, str(qa)

        restored_4facets_image_list[
            centre].data -= restored_1facets_image_list[centre].data
        if self.persist:
            export_image_to_fits(
                restored_4facets_image_list[centre],
                '%s/test_imaging_invert_serial_restored_4facets_error.fits' %
                (self.dir))
        qa = qa_image(restored_4facets_image_list[centre])
        assert numpy.abs(qa.data['max']) < 1e-10, str(qa)
    def test_residual_list(self):
        self.actualSetUp(zerow=True)

        centre = self.freqwin // 2
        residual_image_list = residual_list_serial_workflow(self.bvis_list,
                                                            self.model_list,
                                                            context='2d')
        qa = qa_image(residual_image_list[centre][0])
        assert numpy.abs(qa.data['max'] - 0.32584463456508744) < 1.0, str(qa)
        assert numpy.abs(qa.data['min'] + 0.4559162232699305) < 1.0, str(qa)
Пример #8
0
 def test_create_image_from_array(self):
     m31model_by_array = create_image_from_array(
         self.m31image.data, self.m31image.wcs,
         self.m31image.polarisation_frame)
     add_image(self.m31image, m31model_by_array)
     assert m31model_by_array.shape == self.m31image.shape
     log.debug(
         export_image_to_fits(self.m31image,
                              fitsfile='%s/test_model.fits' % (self.dir)))
     log.debug(qa_image(m31model_by_array,
                        context='test_create_from_image'))
Пример #9
0
    def test_random(self):

        error_dirty, sumwt = self.simulation(self.get_args(), '')

        qa = qa_image(error_dirty)

        numpy.testing.assert_almost_equal(qa.data['max'],
                                          2.2055849698035616e-06, 12)
        numpy.testing.assert_almost_equal(qa.data['min'],
                                          -6.838117387793031e-07, 12)
        numpy.testing.assert_almost_equal(qa.data['rms'],
                                          3.7224203394509413e-07, 12)
Пример #10
0
    def test_wind(self):

        error_dirty, sumwt = self.simulation(self.get_args(), 'wind')

        qa = qa_image(error_dirty)

        numpy.testing.assert_almost_equal(qa.data['max'],
                                          1.2440965953105578e-06, 12)
        numpy.testing.assert_almost_equal(qa.data['min'],
                                          -3.836051633637655e-06, 12)
        numpy.testing.assert_almost_equal(qa.data['rms'],
                                          5.840397284050296e-07, 12)
Пример #11
0
    def test_gravity(self):

        if os.path.isdir(rascil_path('models/interpolated')):

            error_dirty, sumwt = self.simulation(self.get_args(), 'gravity')

            qa = qa_image(error_dirty)

            numpy.testing.assert_almost_equal(qa.data['max'],
                                              2.2055849698035616e-06, 12)
            numpy.testing.assert_almost_equal(qa.data['min'],
                                              -6.838117387793031e-07, 12)
            numpy.testing.assert_almost_equal(qa.data['rms'],
                                              3.7224203394509413e-07, 12)
Пример #12
0
 def test_restored_list_noresidual(self):
     self.actualSetUp(zerow=True)
     
     centre = self.freqwin // 2
     psf_image_list = invert_list_rsexecute_workflow(self.vis_list, self.model_list, context='2d', dopsf=True)
     restored_image_list = restore_list_rsexecute_workflow(self.model_list, psf_image_list, psfwidth=1.0)
     restored_image_list = rsexecute.compute(restored_image_list, sync=True)
     if self.persist: export_image_to_fits(restored_image_list[centre],
                                           '%s/test_imaging_invert_%s_restored_noresidual.fits' %
                                           (self.dir, rsexecute.type()))
     
     qa = qa_image(restored_image_list[centre])
     assert numpy.abs(qa.data['max'] - 100.0) < 1e-7, str(qa)
     assert numpy.abs(qa.data['min']) < 1e-7, str(qa)
Пример #13
0
 def test_sum_invert_list(self):
     self.actualSetUp(zerow=True)
 
     residual_image_list = residual_list_rsexecute_workflow(self.vis_list, self.model_list, context='2d')
     residual_image_list = rsexecute.compute(residual_image_list, sync=True)
     route2 = sum_invert_results(residual_image_list)
     route1 = sum_invert_results_rsexecute(residual_image_list)
     route1 = rsexecute.compute(route1, sync=True)
     for r in route1, route2:
         assert len(r) == 2
         qa = qa_image(r[0])
         assert numpy.abs(qa.data['max'] - 0.35139716991480785) < 1.0, str(qa)
         assert numpy.abs(qa.data['min'] + 0.7681701460717593) < 1.0, str(qa)
         assert numpy.abs(r[1]-415950.0) < 1e-7, str(qa)
    def test_sum_invert_list(self):
        self.actualSetUp(zerow=True)

        residual_image_list = residual_list_rsexecute_workflow(self.bvis_list,
                                                               self.model_list,
                                                               context='2d')
        residual_image_list = rsexecute.compute(residual_image_list, sync=True)
        route2 = sum_invert_results(residual_image_list)
        route1 = sum_invert_results_rsexecute(residual_image_list)
        route1 = rsexecute.compute(route1, sync=True)
        for r in route1, route2:
            assert len(r) == 2
            qa = qa_image(r[0])
            assert numpy.abs(qa.data['max'] -
                             0.15513038832438183) < 1.0, str(qa)
            assert numpy.abs(qa.data['min'] +
                             0.4607090445091728) < 1.0, str(qa)
            assert numpy.abs(r[1] - 831900.) < 1e-7, r
    def test_ical_pipeline_pol(self):
        self.actualSetUp(add_errors=True, dopol=True)
        controls = create_calibration_controls()
        controls['T']['first_selfcal'] = 1
        controls['T']['timeslice'] = 'auto'

        ical_list = \
            ical_list_rsexecute_workflow(self.vis_list,
                                         model_imagelist=self.model_imagelist,
                                         context='2d',
                                         algorithm='mmclean', facets=1,
                                         scales=[0, 3, 10],
                                         niter=1000, fractional_threshold=0.1, threshold=0.1,
                                         nmoment=3,
                                         nmajor=5, gain=0.1,
                                         deconvolve_facets=4, deconvolve_overlap=32,
                                         deconvolve_taper='tukey', psf_support=64,
                                         restore_facets=4, psfwidth=1.0,
                                         calibration_context='T', controls=controls, do_selfcal=True,
                                         global_solution=False)
        clean, residual, restored, gt_list = rsexecute.compute(ical_list,
                                                               sync=True)
        centre = len(clean) // 2
        if self.persist:
            export_image_to_fits(
                clean[centre],
                '%s/test_pipelines_ical_pipeline_pol_rsexecute_clean.fits' %
                self.dir)
            export_image_to_fits(
                residual[centre][0],
                '%s/test_pipelines_ical_pipeline__polrsexecute_residual.fits' %
                self.dir)
            export_image_to_fits(
                restored[centre],
                '%s/test_pipelines_ical_pipeline_pol_rsexecute_restored.fits' %
                self.dir)
            export_gaintable_to_hdf5(
                gt_list[centre]['T'],
                '%s/test_pipelines_ical_pipeline_pol_rsexecute_gaintable.hdf5'
                % self.dir)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 88.18493789481009) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] + 2.0896642789962585) < 1.0e-7, str(qa)
Пример #16
0
 def test_continuum_imaging_pipeline(self):
     self.actualSetUp(add_errors=False, zerow=True)
     clean, residual, restored = \
         continuum_imaging_list_serial_workflow(self.vis_list,
                                                model_imagelist=self.model_imagelist,
                                                context='2d',
                                                algorithm='mmclean', facets=1,
                                                scales=[0, 3, 10],
                                                niter=1000, fractional_threshold=0.1, threshold=0.1,
                                                nmoment=3,
                                                nmajor=5, gain=0.1,
                                                deconvolve_facets=4, deconvolve_overlap=32,
                                                deconvolve_taper='tukey', psf_support=64)
     centre = len(clean) // 2
     if self.persist:
         export_image_to_fits(clean[centre], '%s/test_pipelines_continuum_imaging_pipeline_serial_clean.fits' % self.dir)
         export_image_to_fits(residual[centre][0],
                             '%s/test_pipelines_continuum_imaging_pipeline_serial_residual.fits' % self.dir)
         export_image_to_fits(restored[centre],
                             '%s/test_pipelines_continuum_imaging_pipeline_serial_restored.fits' % self.dir)
     
     qa = qa_image(restored[centre])
     assert numpy.abs(qa.data['max'] - 100.13762476849081) < 1.0, str(qa)
     assert numpy.abs(qa.data['min'] + 0.03627273884170454) < 1.0, str(qa)
Пример #17
0
blockvis = predict_skycomponent_visibility(blockvis, components)
#blockvis = dft_skycomponent_visibility(blockvis, components)

blockvis1 = copy_visibility(blockvis)
vis1 = convert_blockvisibility_to_visibility(blockvis1)

# Calculate the model convolved with a Gaussian.

cmodel = smooth_image(model)
if persist: export_image_to_fits(model, '%s/test_imaging_2d_model.fits' % rdir)
if persist:
    export_image_to_fits(cmodel, '%s/test_imaging_2d_cmodel.fits' % rdir)

# In[4]:

print(qa_image(model))

# In[5]:

plt.rcParams['figure.figsize'] = 10, 10
show_image(cmodel)
plt.savefig("cmodel.png")

# In[6]:

# Find nw based on w_min, w_max
w_min = numpy.amin(vis.data['uvw'][:, 2])
w_max = numpy.amax(vis.data['uvw'][:, 2])

w_range = 2 * numpy.amax((numpy.abs(w_min), numpy.abs(w_max)))
wstep = 3.0
Пример #18
0
        export_image_to_fits(
            psf, '%s/compare_imaging_sim2_psf.fits' % (results_dir))

        # Deconvolve using clean
        comp, residual = deconvolve_cube(dirty,
                                         psf,
                                         niter=10000,
                                         threshold=0.001,
                                         fractional_threshold=0.001,
                                         window_shape='quarter',
                                         gain=0.7,
                                         scales=[0, 3, 10, 30])

        restored = restore_cube(comp, psf, residual)
        export_image_to_fits(
            restored, '%s/compare_imaging_sim2_restored.fits' % (results_dir))
        export_image_to_fits(
            residual, '%s/compare_imaging_sim2_residual.fits' % (results_dir))

        qa = qa_image(restored)

        assert numpy.abs(qa.data['max'] - 1.006140596404203) < 1e-7, qa
        assert numpy.abs(qa.data['maxabs'] - 1.006140596404203) < 1e-7, qa
        assert numpy.abs(qa.data['min'] + 0.23890808520954754) < 1e-7, qa
        assert numpy.abs(qa.data['rms'] - 0.007366519782047875) < 1e-7, qa
        assert numpy.abs(qa.data['medianabs'] -
                         0.0005590537883509844) < 1e-7, qa
    except ModuleNotFoundError as error:
        print(error.__class__.__name__ + ": " + error.msg)
        pass
                                              edge=0.03162278, padding=2, use_local=True)

    key_nolls = [3, 5, 6, 7]
    for noll in key_nolls:
        zernike = {'coeff': 1.0, 'noll': noll}
        zernike['vp'] = create_vp_generic_numeric(model, pointingcentre=None, diameter=15.0, blockage=0.0,
                                                  taper='gaussian',
                                                  edge=0.03162278, zernikes=[zernike], padding=2, use_local=True)
        zernikes.append(zernike)
    
    for trial in range(ntrials):
        coeffs = numpy.random.normal(0.0, 0.03, len(key_nolls))
        vp = copy_image(default_vp)
        for i in range(len(key_nolls)):
            vp.data += coeffs[i] * zernikes[i]['vp'].data
        
        vp.data = vp.data / numpy.max(numpy.abs(vp.data))
        vp_data = vp.data / numpy.max(numpy.abs(vp.data))
        vp.data = numpy.real(vp_data)
        print(trial, qa_image(vp))
        export_image_to_fits(vp, "%s/test_voltage_pattern_real_%s_trial%d.fits" % (dir, 'MID_RANDOM_ZERNIKES', trial))
        row = (trial - 1) // 4
        col = (trial - 1) - 4 * row
        ax = axs[row, col]
        ax.imshow(vp.data[0, 0], vmax=0.01, vmin=-0.001)
        # ax.set_title('Noll %d' % noll)
        ax.axis('off')
    
    plt.savefig("random_zernikes.png")
    plt.show()
Пример #20
0
                vis_comp_chunk_dirty_list = create_vis_list_with_errors(
                    chunk_bvis[ivis_chunk],
                    chunk_components[icomp_chunk],
                    sub_model_list=future_model_list,
                    vp_list=vp_list,
                    vp_coeffs=scaled_vp_coeffs,
                    use_radec=use_radec)
                this_result = rsexecute.compute(vis_comp_chunk_dirty_list,
                                                sync=True)
                for r in this_result:
                    error_dirty_list.append(r)

        error_dirty, sumwt = sum_invert_results(error_dirty_list)
        print("Dirty image sumwt", sumwt)
        del error_dirty_list
        print(qa_image(error_dirty))

        if show:
            show_image(error_dirty, cm='gray_r')
            plt.savefig('%s.png' % file_name)
            plt.show(block=False)

        qa = qa_image(error_dirty)
        _, _, ny, nx = error_dirty.shape
        for field in ['maxabs', 'rms', 'medianabs']:
            result["onsource_" + field] = qa.data[field]
        result['onsource_abscentral'] = numpy.abs(error_dirty.data[0, 0,
                                                                   ny // 2,
                                                                   nx // 2])

        qa_psf = qa_image(psf)
                        default=None,
                        help='Second image')
    parser.add_argument('--outimage',
                        type=str,
                        default=None,
                        help='Second image')
    parser.add_argument('--mode',
                        type=str,
                        default='pipeline',
                        help='Imaging mode')

    args = parser.parse_args()

    pp.pprint(vars(args))

    im1 = import_image_from_fits(args.image1)
    im2 = import_image_from_fits(args.image2)
    print(qa_image(im1, context='Image 1'))
    print(qa_image(im2, context='Image 2'))

    outim = copy_image(im1)
    outim.data -= im2.data

    print(qa_image(outim, context='Difference image'))
    export_image_to_fits(outim, args.outimage)

    plt.clf()
    show_image(outim)
    plt.savefig(args.outimage.replace('.fits', '.jpg'))
    plt.show(block=False)
Пример #22
0
    def test_apply_voltage_pattern_image_pointsource(self):
        self.createVis(rmax=1e3)
        telescope = 'MID_FEKO_B2'
        vpol = PolarisationFrame("linear")
        self.times = numpy.linspace(-4, +4, 8) * numpy.pi / 12.0
        bvis = create_blockvisibility(self.config,
                                      self.times,
                                      self.frequency,
                                      channel_bandwidth=self.channel_bandwidth,
                                      phasecentre=self.phasecentre,
                                      weight=1.0,
                                      polarisation_frame=vpol,
                                      zerow=True)
        cellsize = advise_wide_field(bvis)['cellsize']

        pbmodel = create_image_from_visibility(
            bvis,
            cellsize=self.cellsize,
            npixel=self.npixel,
            override_cellsize=False,
            polarisation_frame=PolarisationFrame("stokesIQUV"))
        vpbeam = create_vp(pbmodel, telescope=telescope, use_local=False)
        vpbeam.wcs.wcs.ctype[0] = 'RA---SIN'
        vpbeam.wcs.wcs.ctype[1] = 'DEC--SIN'
        vpbeam.wcs.wcs.crval[0] = pbmodel.wcs.wcs.crval[0]
        vpbeam.wcs.wcs.crval[1] = pbmodel.wcs.wcs.crval[1]

        s3_components = create_test_skycomponents_from_s3(
            flux_limit=0.1,
            phasecentre=self.phasecentre,
            frequency=self.frequency,
            polarisation_frame=PolarisationFrame('stokesI'),
            radius=1.5 * numpy.pi / 180.0)

        for comp in s3_components:
            comp.polarisation_frame = PolarisationFrame('stokesIQUV')
            comp.flux = numpy.array([[comp.flux[0, 0], 0.0, 0.0, 0.0]])

        s3_components = filter_skycomponents_by_flux(s3_components, 0.0, 10.0)

        from rascil.processing_components.image import show_image
        import matplotlib.pyplot as plt
        plt.clf()
        show_image(vpbeam, components=s3_components)
        plt.show(block=False)

        vpcomp = apply_voltage_pattern_to_skycomponent(s3_components, vpbeam)
        bvis.data['vis'][...] = 0.0 + 0.0j
        bvis = dft_skycomponent_visibility(bvis, vpcomp)

        rec_comp = idft_visibility_skycomponent(bvis, vpcomp)[0]

        stokes_comp = list()
        for comp in rec_comp:
            stokes_comp.append(
                convert_pol_frame(comp.flux[0], PolarisationFrame("linear"),
                                  PolarisationFrame("stokesIQUV")))

        stokesI = numpy.abs(
            numpy.array([comp_flux[0] for comp_flux in stokes_comp]).real)
        stokesQ = numpy.abs(
            numpy.array([comp_flux[1] for comp_flux in stokes_comp]).real)
        stokesU = numpy.abs(
            numpy.array([comp_flux[2] for comp_flux in stokes_comp]).real)
        stokesV = numpy.abs(
            numpy.array([comp_flux[3] for comp_flux in stokes_comp]).real)
        plt.clf()
        plt.loglog(stokesI, stokesQ, '.', label='Q')
        plt.loglog(stokesI, stokesU, '.', label='U')
        plt.loglog(stokesI, stokesV, '.', label='V')
        plt.xlabel("Stokes Flux I (Jy)")
        plt.ylabel("Flux (Jy)")
        plt.legend()
        plt.savefig('%s/test_primary_beams_pol_rsexecute_stokes_errors.png' %
                    self.dir)
        plt.show(block=False)

        split_times = False
        if split_times:
            bvis_list = list()
            for rows in vis_timeslice_iter(bvis, vis_slices=8):
                bvis_list.append(create_visibility_from_rows(bvis, rows))
        else:
            bvis_list = [bvis]

        bvis_list = rsexecute.scatter(bvis_list)

        model_list = \
            [rsexecute.execute(create_image_from_visibility, nout=1)(bv, cellsize=cellsize, npixel=4096,
                                                                     phasecentre=self.phasecentre,
                                                                     override_cellsize=False,
                                                                     polarisation_frame=PolarisationFrame("stokesIQUV"))
             for bv in bvis_list]

        model_list = rsexecute.persist(model_list)
        bvis_list = weight_list_rsexecute_workflow(bvis_list, model_list)

        continuum_imaging_list = \
            continuum_imaging_list_rsexecute_workflow(bvis_list, model_list,
                                                      context='2d',
                                                      algorithm='hogbom',
                                                      facets=1,
                                                      niter=1000,
                                                      fractional_threshold=0.1,
                                                      threshold=1e-4,
                                                      nmajor=5, gain=0.1,
                                                      deconvolve_facets=4,
                                                      deconvolve_overlap=32,
                                                      deconvolve_taper='tukey',
                                                      psf_support=64,
                                                      restore_facets=4, psfwidth=1.0)
        clean, residual, restored = rsexecute.compute(continuum_imaging_list,
                                                      sync=True)
        centre = 0
        if self.persist:
            export_image_to_fits(
                clean[centre],
                '%s/test_primary_beams_pol_rsexecute_clean.fits' % self.dir)
            export_image_to_fits(
                residual[centre][0],
                '%s/test_primary_beams_pol_rsexecute_residual.fits' % self.dir)
            export_image_to_fits(
                restored[centre],
                '%s/test_primary_beams_pol_rsexecute_restored.fits' % self.dir)

        plt.clf()
        show_image(restored[centre])
        plt.show(block=False)

        qa = qa_image(restored[centre])
        assert numpy.abs(qa.data['max'] - 0.9953017707113947) < 1.0e-7, str(qa)
        assert numpy.abs(qa.data['min'] +
                         0.0036396480874570846) < 1.0e-7, str(qa)