Example #1
0
 def write_image(im, im_type="restored", index=0, axis='spw'):
     filename_root = \
         "{results_directory}/{project:s}_{source:s}_{pipeline}_{im_type:s}_{axis}{index:d}".format(
             results_directory=results_directory,
             project=erp_params["configure"]["project"],
             source=erp_params["ingest"]["source"],
             im_type=im_type,
             pipeline=pipeline,
             axis=axis,
             index=index)
     log.info(qa_image(im, context=filename_root))
     plt.clf()
     show_image(im, title=filename_root)
     plotfile = "{0}.png".format(filename_root)
     plt.savefig(plotfile)
     plt.show(block=False)
     filename = "{0}.fits".format(filename_root)
     export_image_to_fits(im, filename)
    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
                                         npixels=12)
    for comp in all_components[:args.ninitial]:
        ical_components.append(comp)

    # ### Remove weaker of components that are too close (0.02 rad)
    idx, ical_components = remove_neighbouring_components(
        ical_components, 0.02)
    ical_components = sorted(ical_components,
                             key=lambda comp: numpy.max(comp.flux),
                             reverse=True)
    print("Voronoi decomposition based on %d point sources" %
          len(ical_components))

    print(qa_image(ical_restored, context='ICAL restored image'))
    show_image(ical_restored,
               title='ICAL restored image',
               vmax=0.3,
               vmin=-0.03)
    show_image(ical_restored,
               title='ICAL restored image',
               components=ical_components,
               vmax=0.3,
               vmin=-0.03)
    plt.show(block=block_plots)

    gaintable = create_gaintable_from_blockvisibility(block_vis)
    mpccal_skymodel = initialize_skymodel_voronoi(model, ical_components,
                                                  ical_skymodel[0].gaintable)

    ical_fluxes = [comp.flux[0, 0] for comp in ical_components]
    plt.clf()
    plt.semilogy(numpy.arange(len(all_fluxes)), all_fluxes, marker='.')
Example #4
0
                                                      dopsf=True,
                                                      verbosity=0,
                                                      nthreads=nthreads,
                                                      do_wstacking=not zerow)

        psf_list = rsexecute.compute(psf_list, sync=True)
        psf, sumwt = sum_invert_results(psf_list)
        print("PSF sumwt ", sumwt)
        print(qa_image(psf, context='PSF'))

        if export_images:
            export_image_to_fits(psf, 'PSF_rascil.fits')
        if show:
            show_image(psf,
                       cm='gray_r',
                       title='%s PSF' % basename,
                       vmin=-0.01,
                       vmax=0.1)
            plt.savefig('PSF_rascil.png')
            plt.show(block=False)
        del psf_list
        del future_psf_list

    if context == "s3sky":
        pb_list = [
            rsexecute.execute(create_image_from_visibility)(
                bv,
                npixel=pb_npixel,
                frequency=frequency,
                nchan=nfreqwin,
                cellsize=pb_cellsize,
Example #5
0
uvdist = numpy.sqrt(vt.data['uvw'][:, 0]**2 + vt.data['uvw'][:, 1]**2)
plt.clf()
plt.plot(uvdist, numpy.abs(vt.data['vis']), '.')
plt.xlabel('uvdist')
plt.ylabel('Amp Visibility')
plt.show()

model = create_image_from_visibility(
    vt,
    cellsize=cellsize,
    npixel=1024,
    polarisation_frame=PolarisationFrame('stokesIV'))
dirty, sumwt = invert_2d(vt, model, context='2d')
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,
Example #6
0
        del bvis_list

    print("Inverting to get PSF")
    psf_list = invert_list_rsexecute_workflow(future_vis_list,
                                              future_psf_list,
                                              args.imaging_context,
                                              dopsf=True)
    psf_list = rsexecute.compute(psf_list, sync=True)
    psf, sumwt = sum_invert_results(psf_list)
    print("PSF sumwt ", sumwt)
    if export_images:
        export_image_to_fits(psf, 'PSF_rascil.fits')
    if show:
        show_image(psf,
                   cm='gray_r',
                   title='%s PSF' % basename,
                   vmin=-0.01,
                   vmax=0.1)
        plt.savefig('PSF_rascil.png')
        plt.show(block=False)
    del psf_list
    del future_psf_list

    # ### Calculate the voltage pattern without errors
    vp_list = [
        rsexecute.execute(create_image_from_visibility)(
            bv,
            npixel=pb_npixel,
            frequency=frequency,
            nchan=nfreqwin,
            cellsize=pb_cellsize,
Example #7
0
        log.info("Processing took %.2f (s)" % run_time)

        pp.pprint(result)
        deconvolved = result[0][0]
        residual = result[1][0][0]
        restored = result[2][0]

        print(qa_image(restored))

        restored_name = target_ms.split('/')[-1].replace(
            msext, '_cip_restored.fits')
        log.info("Writing restored image to %s" % restored_name)
        export_image_to_fits(restored, restored_name)

        title = target_ms.split('/')[-1].replace(msext, ' cip restored image')
        show_image(restored, vmax=0.03, vmin=-0.003, title=title)
        plot_name = target_ms.split('/')[-1].replace(msext,
                                                     '_cip_restored.jpg')
        plt.savefig(plot_name)
        plt.show(block=False)

        deconvolved_name = target_ms.split('/')[-1].replace(
            msext, '_cip_deconvolved.fits')
        log.info("Writing cip deconvolved image to %s" % deconvolved_name)
        export_image_to_fits(deconvolved, deconvolved_name)

        residual_name = target_ms.split('/')[-1].replace(
            msext, '_cip_residual.fits')
        log.info("Writing residual image to %s" % residual_name)
        export_image_to_fits(residual, residual_name)