def test_deconvolve_and_restore_cube_mmclean_facets(self): self.actualSetUp(add_errors=True) dirty_imagelist = invert_list_serial_workflow(self.vis_list, self.model_imagelist, context='2d', dopsf=False, normalize=True) psf_imagelist = invert_list_serial_workflow(self.vis_list, self.model_imagelist, context='2d', dopsf=True, normalize=True) dec_imagelist = deconvolve_list_serial_workflow( dirty_imagelist, psf_imagelist, self.model_imagelist, niter=1000, fractional_threshold=0.1, scales=[0, 3, 10], algorithm='mmclean', nmoment=3, nchan=self.freqwin, threshold=0.01, gain=0.7, deconvolve_facets=8, deconvolve_overlap=8, deconvolve_taper='tukey') residual_imagelist = residual_list_serial_workflow( self.vis_list, model_imagelist=dec_imagelist, context='2d') restored = restore_list_serial_workflow( model_imagelist=dec_imagelist, psf_imagelist=psf_imagelist, residual_imagelist=residual_imagelist, empty=self.model_imagelist)[0] if self.persist: export_image_to_fits( restored, '%s/test_imaging_serial_overlap_mmclean_restored.fits' % (self.dir))
def test_deconvolve_spectral(self): self.actualSetUp(add_errors=True) dirty_imagelist = invert_list_serial_workflow(self.vis_list, self.model_imagelist, context='2d', dopsf=False, normalize=True) psf_imagelist = invert_list_serial_workflow(self.vis_list, self.model_imagelist, context='2d', dopsf=True, normalize=True) deconvolved = deconvolve_list_serial_workflow(dirty_imagelist, psf_imagelist, self.model_imagelist, niter=1000, fractional_threshold=0.1, scales=[0, 3, 10], threshold=0.1, gain=0.7) if self.persist: export_image_to_fits( deconvolved[0], '%s/test_imaging_serial_deconvolve_spectral.fits' % (self.dir))
def ical_list_serial_workflow(vis_list, model_imagelist, context, vis_slices=1, facets=1, gcfcf=None, calibration_context='TG', do_selfcal=True, **kwargs): """Run ICAL pipeline :param vis_list: :param model_imagelist: :param context: imaging context e.g. '2d' :param calibration_context: Sequence of calibration steps e.g. TGB :param do_selfcal: Do the selfcalibration? :param kwargs: Parameters for functions in components :return: """ gt_list = list() if gcfcf is None: gcfcf = [create_pswf_convolutionfunction(model_imagelist[0])] psf_imagelist = invert_list_serial_workflow(vis_list, model_imagelist, dopsf=True, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) model_vislist = [copy_visibility(v, zero=True) for v in vis_list] if do_selfcal: cal_vis_list = [copy_visibility(v) for v in vis_list] else: cal_vis_list = vis_list if do_selfcal: # Make the predicted visibilities, selfcalibrate against it correcting the gains, then # form the residual visibility, then make the residual image model_vislist = predict_list_serial_workflow(model_vislist, model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) cal_vis_list, gt_list = calibrate_list_serial_workflow( cal_vis_list, model_vislist, calibration_context=calibration_context, **kwargs) residual_vislist = subtract_list_serial_workflow( cal_vis_list, model_vislist) residual_imagelist = invert_list_serial_workflow(residual_vislist, model_imagelist, context=context, dopsf=False, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, iteration=0, **kwargs) else: # If we are not selfcalibrating it's much easier and we can avoid an unnecessary round of gather/scatter # for visibility partitioning such as timeslices and wstack. residual_imagelist = residual_list_serial_workflow( cal_vis_list, model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) deconvolve_model_imagelist = deconvolve_list_serial_workflow( residual_imagelist, psf_imagelist, model_imagelist, prefix='cycle 0', **kwargs) nmajor = get_parameter(kwargs, "nmajor", 5) if nmajor > 1: for cycle in range(nmajor): if do_selfcal: model_vislist = predict_list_serial_workflow( model_vislist, deconvolve_model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) cal_vis_list = [copy_visibility(v) for v in vis_list] cal_vis_list, gt_list = calibrate_list_serial_workflow( cal_vis_list, model_vislist, calibration_context=calibration_context, iteration=cycle, **kwargs) residual_vislist = subtract_list_serial_workflow( cal_vis_list, model_vislist) residual_imagelist = invert_list_serial_workflow( residual_vislist, model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) else: residual_imagelist = residual_list_serial_workflow( cal_vis_list, deconvolve_model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) prefix = "cycle %d" % (cycle + 1) deconvolve_model_imagelist = deconvolve_list_serial_workflow( residual_imagelist, psf_imagelist, deconvolve_model_imagelist, prefix=prefix, **kwargs) residual_imagelist = residual_list_serial_workflow( cal_vis_list, deconvolve_model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) restore_imagelist = restore_list_serial_workflow( deconvolve_model_imagelist, psf_imagelist, residual_imagelist) return deconvolve_model_imagelist, residual_imagelist, restore_imagelist, gt_list
def continuum_imaging_list_serial_workflow(vis_list, model_imagelist, context, gcfcf=None, vis_slices=1, facets=1, **kwargs): """ Create graph for the continuum imaging pipeline. Same as ICAL but with no selfcal. :param vis_list: :param model_imagelist: :param context: Imaging context :param kwargs: Parameters for functions in components :return: """ if gcfcf is None: gcfcf = [create_pswf_convolutionfunction(model_imagelist[0])] psf_imagelist = invert_list_serial_workflow(vis_list, model_imagelist, context=context, dopsf=True, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) residual_imagelist = residual_list_serial_workflow(vis_list, model_imagelist, context=context, gcfcf=gcfcf, vis_slices=vis_slices, facets=facets, **kwargs) deconvolve_model_imagelist = deconvolve_list_serial_workflow( residual_imagelist, psf_imagelist, model_imagelist, prefix='cycle 0', **kwargs) nmajor = get_parameter(kwargs, "nmajor", 5) if nmajor > 1: for cycle in range(nmajor): prefix = "cycle %d" % (cycle + 1) residual_imagelist = residual_list_serial_workflow( vis_list, deconvolve_model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) deconvolve_model_imagelist = deconvolve_list_serial_workflow( residual_imagelist, psf_imagelist, deconvolve_model_imagelist, prefix=prefix, **kwargs) residual_imagelist = residual_list_serial_workflow( vis_list, deconvolve_model_imagelist, context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf, **kwargs) restore_imagelist = restore_list_serial_workflow( deconvolve_model_imagelist, psf_imagelist, residual_imagelist) return (deconvolve_model_imagelist, residual_imagelist, restore_imagelist)