Пример #1
0
    def test_mpccal_ICAL_onesource(self):

        self.actualSetup(nsources=1, nvoronoi=1)

        model = create_empty_image_like(self.theta_list[0].image)

        if rsexecute.using_dask:
            progress = None
        else:
            progress = self.progress

        future_vis = rsexecute.scatter(self.all_skymodel_noniso_vis)
        future_model = rsexecute.scatter(model)
        future_theta_list = rsexecute.scatter(self.theta_list)
        result = mpccal_skymodel_list_rsexecute_workflow(future_vis, future_model, future_theta_list,
                                                         mpccal_progress=progress,
                                                         nmajor=5,
                                                         context='2d',
                                                         algorithm='hogbom',
                                                         scales=[0, 3, 10],
                                                         fractional_threshold=0.15, threshold=0.05,
                                                         gain=0.1, niter=1000, psf_support=256,
                                                         deconvolve_facets=8, deconvolve_overlap=16,
                                                         deconvolve_taper='tukey')

        (self.theta_list, residual) = rsexecute.compute(result, sync=True)

        combined_model = calculate_skymodel_equivalent_image(self.theta_list)

        psf_obs = invert_list_rsexecute_workflow([self.all_skymodel_noniso_vis], [model], context='2d', dopsf=True)
        result = restore_list_rsexecute_workflow([combined_model], psf_obs, [(residual, 0.0)])
        result = rsexecute.compute(result, sync=True)

        if self.persist: export_image_to_fits(residual,
                                              rascil_path('test_results/test_mpccal_ical_onesource_residual.fits'))
        if self.persist: export_image_to_fits(result[0],
                                              rascil_path('test_results/test_mpccal_ical_onesource_restored.fits'))
        if self.persist: export_image_to_fits(combined_model,
                                              rascil_path('test_results/test_mpccal_ical_onesource_deconvolved.fits'))

        recovered_mpccal_components = find_skycomponents(result[0], fwhm=2, threshold=0.32, npixels=12)

        def max_flux(elem):
            return numpy.max(elem.flux)

        recovered_mpccal_components = sorted(recovered_mpccal_components, key=max_flux, reverse=True)

        assert recovered_mpccal_components[0].name == 'Segment 0', recovered_mpccal_components[0].name
        assert numpy.abs(recovered_mpccal_components[0].flux[0, 0] - 1.138095494391862) < 1e-6, \
            recovered_mpccal_components[0].flux[0, 0]

        newscreen = create_empty_image_like(self.screen)
        gaintables = [th.gaintable for th in self.theta_list]
        newscreen, weights = grid_gaintable_to_screen(self.all_skymodel_noniso_blockvis, gaintables, newscreen)
        if self.persist: export_image_to_fits(newscreen,
                                              rascil_path('test_results/test_mpccal_ical_onesource_screen.fits'))
        if self.persist: export_image_to_fits(weights,
                                              rascil_path('test_results/test_mpccal_ical_onesource_screenweights.fits'))

        rsexecute.close()
Пример #2
0
    def progress(res, tl_list, gt_list, it, context='MPCCAL'):
        print('Iteration %d' % it)

        print(
            qa_image(res,
                     context='%s residual image: iteration %d' %
                     (context, it)))
        export_image_to_fits(
            res,
            rascil_path(
                "test_results/low-sims-mpc-%s-residual_iteration%d_rmax%.1f.fits"
                % (context, it, rmax)))
        show_image(res,
                   title='%s residual image: iteration %d' % (context, it))
        plt.show(block=block_plots)

        combined_model = calculate_skymodel_equivalent_image(tl_list)
        print(
            qa_image(combined_model,
                     context='Combined model: iteration %d' % it))
        export_image_to_fits(
            combined_model,
            rascil_path(
                "test_results/low-sims-mpc-%s-model_iteration%d_rmax%.1f.fits"
                % (context, it, rmax)))

        plt.clf()
        for i in range(len(tl_list)):
            plt.plot(
                numpy.angle(tl_list[i].gaintable.gain[:, :, 0, 0,
                                                      0]).flatten(),
                numpy.angle(gt_list[i]['T'].gain[:, :, 0, 0, 0]).flatten(),
                '.')
        plt.xlabel('Current phase')
        plt.ylabel('Update to phase')
        plt.title("%s iteration%d: Change in phase" % (context, it))
        plt.savefig(
            rascil_path(
                "test_results/low-sims-mpc-%s-skymodel-phase-change_iteration%d.jpg"
                % (context, it)))
        plt.show(block=block_plots)
        return tl_list
Пример #3
0
                                                     algorithm='hogbom',
                                                     fractional_threshold=0.3,
                                                     threshold=0.1,
                                                     gain=0.1,
                                                     niter=1000,
                                                     psf_support=512,
                                                     deconvolve_facets=8,
                                                     deconvolve_overlap=16,
                                                     deconvolve_taper='tukey')

    (ical_skymodel, residual) = rsexecute.compute(result, sync=True)
    print(qa_image(residual, context='ICAL residual image'))

    print('ical finished')

    combined_model = calculate_skymodel_equivalent_image(ical_skymodel)
    print(qa_image(combined_model, context='ICAL combined model'))
    psf_obs = invert_list_rsexecute_workflow([future_vis], [future_model],
                                             context='2d',
                                             dopsf=True)
    result = restore_list_rsexecute_workflow([combined_model], psf_obs,
                                             [(residual, 0.0)])
    result = rsexecute.compute(result, sync=True)
    ical_restored = result[0]

    export_image_to_fits(
        ical_restored,
        rascil_path('test_results/low-sims-mpc-ical-restored_%.1frmax.fits' %
                    rmax))

    #######################################################################################################