def deconvolve(d, p, m):

        c, resid = deconvolve_cube(d[0],
                                   p[0],
                                   m,
                                   threshold=0.01,
                                   fracthresh=0.01,
                                   window_shape='quarter',
                                   niter=100,
                                   gain=0.1,
                                   algorithm='hogbom-complex')
        r = restore_cube(c, p[0], resid)
        return r
示例#2
0
if __name__ == '__main__':
    results_dir = rascil_path('test_results')

    bvt = create_blockvisibility_from_ms(rascil_path('data/vis/sim-2.ms'), start_chan=35, end_chan=39)[0]
    bvt.configuration.diameter[...] = 35.0
    vt = convert_blockvisibility_to_visibility(bvt)
    vt = convert_visibility_to_stokes(vt)

    a2r = numpy.pi / (180.0 * 3600.0)

    model = create_image_from_visibility(vt, cellsize=20.0 * a2r, npixel=512,
                                         polarisation_frame=PolarisationFrame('stokesIQUV'))
    dirty, sumwt = invert_list_serial_workflow([vt], [model], context='2d')[0]
    psf, sumwt = invert_list_serial_workflow([vt], [model], context='2d', dopsf=True)[0]
    export_image_to_fits(dirty, '%s/rascil_imaging_sim_2_dirty.fits' % (results_dir))
    export_image_to_fits(psf, '%s/rascil_imaging_sim_2_psf.fits' % (results_dir))

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

    restored = restore_cube(comp, psf, residual)

    print(qa_image(restored))
    export_image_to_fits(restored, '%s/rascil_imaging_sim_2_restored.fits' % (results_dir))
    export_image_to_fits(residual, '%s/rascil_imaging_sim_2_residual.fits' % (results_dir))