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
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))
psf, sumwt = invert_2d(vt, model, context='2d', dopsf=True) dirty = show_image(dirty) dirty.show() show_image(psf) # print("Max, min in dirty image = %.6f, %.6f, sumwt = %f" % (dirty.data.max(), dirty.data.min(), sumwt)) # print("Max, min in PSF = %.6f, %.6f, sumwt = %f" % (psf.data.max(), psf.data.min(), sumwt)) # export_image_to_fits(dirty, '%s/imaging_dirty.fits'%(results_dir)) # export_image_to_fits(psf, '%s/imaging_psf.fits'%(results_dir)) comp, residual = deconvolve_cube(dirty, psf, niter=100, threshold=0.001, fractional_threshold=0.001, gain=0.2, algorithm='msclean', scales=[0, 3, 10, 30, 50, 100]) restored = restore_cube(comp, psf, residual) # Show the results fig = show_image(comp) plt.title('Solution') fig = show_image(residual) plt.title('Residual') fig = show_image(restored) plt.title('Restored')