Example #1
0
    def test_invert(self):

        uvfitsfile = arl_path("data/vis/ASKAP_example.fits")

        nchan_ave = 32
        nchan = 192
        for schan in range(0, nchan, nchan_ave):
            max_chan = min(nchan, schan + nchan_ave)
            bv = create_blockvisibility_from_uvfits(uvfitsfile,
                                                    range(schan, max_chan))[0]
            vis = convert_blockvisibility_to_visibility(bv)
            from processing_components.visibility.operations import convert_visibility_to_stokesI
            vis = convert_visibility_to_stokesI(vis)
            model = create_image_from_visibility(
                vis,
                npixel=256,
                polarisation_frame=PolarisationFrame('stokesI'))
            dirty, sumwt = invert_2d(vis, model, context='2d')
            assert (numpy.max(numpy.abs(dirty.data))) > 0.0
            assert dirty.shape == (nchan_ave, 1, 256, 256)
            import matplotlib.pyplot as plt
            from processing_components.image.operations import show_image
            show_image(dirty)
            plt.show()
            if self.persist:
                export_image_to_fits(
                    dirty, '%s/test_visibility_uvfits_dirty.fits' % self.dir)
                               global_solution=False,
                               psf_support=64,
                               do_selfcal=True)

    # In[ ]:

    log.info('About to run ical')
    result = arlexecute.compute(ical_list, sync=True)
    deconvolved = result[0][0]
    residual = result[1][0]
    restored = result[2][0]
    arlexecute.close()

    show_image(deconvolved,
               title='Clean image',
               cm='Greys',
               vmax=0.1,
               vmin=-0.01)
    print(qa_image(deconvolved, context='Clean image'))
    plt.show()
    export_image_to_fits(deconvolved,
                         '%s/gleam_ical_deconvolved.fits' % (results_dir))

    show_image(restored,
               title='Restored clean image',
               cm='Greys',
               vmax=0.1,
               vmin=-0.01)
    print(qa_image(restored, context='Restored clean image'))
    plt.show()
    export_image_to_fits(restored,
    vis_list = arlexecute.persist(vis_list)

    cellsize = 0.001
    npixel = 1024
    pol_frame = PolarisationFrame("stokesI")

    model_list = [
        arlexecute.execute(create_image_from_visibility)(
            v, npixel=npixel, cellsize=cellsize, polarisation_frame=pol_frame)
        for v in vis_list
    ]

    model_list = arlexecute.persist(model_list)

    dirty_list = invert_list_arlexecute_workflow(
        vis_list,
        template_model_imagelist=model_list,
        context='wstack',
        vis_slices=51)

    log.info('About to run invert_list_arlexecute_workflow')
    result = arlexecute.compute(dirty_list, sync=True)
    dirty, sumwt = result[centre]

    arlexecute.close()

    show_image(dirty, title='Dirty image', cm='Greys', vmax=0.1, vmin=-0.01)
    print(qa_image(dirty, context='Dirty image'))
    export_image_to_fits(
        dirty, '%s/ska-imaging_arlexecute_dirty.fits' % (results_dir))
Example #4
0
    def test_create_gradient(self):
        real_vp = import_image_from_fits(
            arl_path('data/models/MID_GRASP_VP_real.fits'))
        gradx, grady = image_gradients(real_vp)

        gradxx, gradxy = image_gradients(gradx)
        gradyx, gradyy = image_gradients(grady)

        gradx.data *= real_vp.data
        grady.data *= real_vp.data
        gradxx.data *= real_vp.data
        gradxy.data *= real_vp.data
        gradyx.data *= real_vp.data
        gradyy.data *= real_vp.data

        import matplotlib.pyplot as plt
        plt.clf()
        show_image(gradx, title='gradx')
        plt.show()
        plt.clf()
        show_image(grady, title='grady')
        plt.show()
        export_image_to_fits(gradx,
                             "%s/test_image_gradients_gradx.fits" % (self.dir))
        export_image_to_fits(grady,
                             "%s/test_image_gradients_grady.fits" % (self.dir))

        plt.clf()
        show_image(gradxx, title='gradxx')
        plt.show()
        plt.clf()
        show_image(gradxy, title='gradxy')
        plt.show()
        plt.clf()
        show_image(gradyx, title='gradyx')
        plt.show()
        plt.clf()
        show_image(gradyy, title='gradyy')
        plt.show()
        export_image_to_fits(
            gradxx, "%s/test_image_gradients_gradxx.fits" % (self.dir))
        export_image_to_fits(
            gradxy, "%s/test_image_gradients_gradxy.fits" % (self.dir))
        export_image_to_fits(
            gradyx, "%s/test_image_gradients_gradyx.fits" % (self.dir))
        export_image_to_fits(
            gradyy, "%s/test_image_gradients_gradyy.fits" % (self.dir))