Ejemplo n.º 1
0
def wproject(vis, npixel_advice, cell_advice, channel, results_dir):
    """Do w-projected imaging of visibility data.
    
    Args:
    vis (obj): ARL visibility data.
    npixel_advice (float): number of pixels in output image.
    cell_advice (float): cellsize in output image.
    channel (int): channel number to be imaged (affects output filename).
    results_dir (str): directory to save results.
    
    Returns:
    dirty: dirty image.
    psf: image of psf.
    """
    try:
        vis_slices = len(np.unique(vis.time))
        print("There are %d timeslices" % vis_slices)
        # Obtain advice on w-proj parameters:
        advice = advise_wide_field(vis)
        # Create a model image:
        model = create_image_from_visibility(vis, cellsize=cell_advice,
                                             npixel=npixel_advice,
                                             polarisation_frame=PolarisationFrame('stokesIQUV'))
        # Weight the visibilities:
        vis, _, _ = weight_visibility(vis, model)
        # Create a dirty image:
        dirty, sumwt = create_invert_graph([vis], model, kernel='wprojection',
                                           wstep=advice['w_sampling_primary_beam'],
                                           oversampling=2).compute()
        # Create the psf:
        psf, sumwt = create_invert_graph([vis], model, dopsf=True, kernel='wprojection',
                                         wstep=advice['w_sampling_primary_beam'],
                                         oversampling=2).compute()
        # Save to disk:
        export_image_to_fits(dirty, '%s/imaging_dirty_WProj-%s.fits'
                             % (results_dir, channel))
        export_image_to_fits(psf, '%s/imaging_psf_WProj-%s.fits'
                             % (results_dir, channel))
    except:
        print("Unexpected error:", sys.exc_info()[0])
        raise
    return dirty, psf
Ejemplo n.º 2
0
 def test_invert_graph(self):
 
     dirty_graph = create_invert_graph(self.vis_graph_list, self.model_graph,
                                       dopsf=False, normalize=True)
 
     if self.compute:
         dirty = dirty_graph.compute()
         export_image_to_fits(dirty[0], '%s/test_imaging_invert_graph_dirty.fits' % (self.results_dir))
         qa = qa_image(dirty[0])
     
         assert numpy.abs(qa.data['max'] - 101.7) < 1.0, str(qa)
         assert numpy.abs(qa.data['min'] + 3.5) < 1.0, str(qa)