def restore_list_serial_workflow_nosumwt(model_imagelist, psf_imagelist, residual_imagelist=None, **kwargs): """ Create a graph to calculate the restored image :param model_imagelist: Model list :param psf_imagelist: PSF list (without the sumwt term) :param residual_imagelist: Residual list (without the sumwt term) :param kwargs: Parameters for functions in components :return: """ if residual_imagelist is None: residual_imagelist = [] if len(residual_imagelist) > 0: return [ restore_cube(model_imagelist[i], psf_imagelist[i], residual_imagelist[i], **kwargs) for i, _ in enumerate(model_imagelist) ] else: return [ restore_cube(model_imagelist[i], psf_imagelist[i], **kwargs) for i, _ in enumerate(model_imagelist) ]
def restore_list_serial_workflow(model_imagelist, psf_imagelist, residual_imagelist, **kwargs): """ Create a graph to calculate the restored image :param model_imagelist: Model list :param psf_imagelist: PSF list :param residual_imagelist: Residual list :param kwargs: Parameters for functions in components :return: """ return [ restore_cube(model_imagelist[i], psf_imagelist[i][0], residual_imagelist[i][0], **kwargs) for i, _ in enumerate(model_imagelist) ]
def load_invert_and_deconvolve(c): v1 = create_visibility_from_ms(input_vis[0], channum=[c])[0] v2 = create_visibility_from_ms(input_vis[1], channum=[c])[0] vf = append_visibility(v1, v2) vf = convert_visibility_to_stokes(vf) vf.configuration.diameter[...] = 35.0 rows = vis_select_uvrange(vf, 0.0, uvmax=uvmax) v = create_visibility_from_rows(vf, rows) pol_frame = PolarisationFrame("stokesIQUV") m = create_image_from_visibility(v, npixel=npixel, cellsize=cellsize, polarisation_frame=pol_frame) if context == '2d': d, sumwt = invert_2d(v, m, dopsf=False) p, sumwt = invert_2d(v, m, dopsf=True) else: d, sumwt = invert_list_serial_workflow([v], [m], context=context, dopsf=False, vis_slices=vis_slices)[0] p, sumwt = invert_list_serial_workflow([v], [m], context=context, dopsf=True, vis_slices=vis_slices)[0] c, resid = deconvolve_cube(d, p, m, threshold=0.01, fracthresh=0.01, window_shape='quarter', niter=100, gain=0.1, algorithm='hogbom-complex') r = restore_cube(c, p, resid, psfwidth=psfwidth) return r
vt = convert_blockvisibility_to_visibility(bvt) vt = convert_visibility_to_stokes(vt) cellsize = 20.0 * numpy.pi / (180.0 * 3600.0) npixel = 512 model = create_image_from_visibility(vt, cellsize=cellsize, npixel=npixel, 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/compare_imaging_sim2_dirty.fits' % (results_dir)) 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