Ejemplo n.º 1
0
    def test_griddata_invert_wterm(self):
        self.actualSetUp(zerow=False)
        gcf, cf = create_awterm_convolutionfunction(self.model,
                                                    nw=100,
                                                    wstep=8.0,
                                                    oversampling=8,
                                                    support=32,
                                                    use_aaf=True)

        cf_image = convert_convolutionfunction_to_image(cf)
        cf_image.data = numpy.real(cf_image.data)
        if self.persist:
            export_image_to_fits(cf_image,
                                 "%s/test_gridding_wterm_cf.fits" % self.dir)

        griddata = create_griddata_from_image(self.model, nw=1)
        griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                      griddata=griddata,
                                                      cf=cf)
        im = fft_griddata_to_image(griddata, gcf)
        im = normalize_sumwt(im, sumwt)
        if self.persist:
            export_image_to_fits(
                im, '%s/test_gridding_dirty_wterm.fits' % self.dir)
        self.check_peaks(im, 97.13215242859648)
Ejemplo n.º 2
0
    def test_griddata_invert_awterm(self):
        self.actualSetUp(zerow=False)
        make_pb = functools.partial(create_pb_generic,
                                    diameter=35.0,
                                    blockage=0.0,
                                    use_local=False)
        pb = make_pb(self.model)
        if self.persist:
            export_image_to_fits(pb,
                                 "%s/test_gridding_awterm_pb.fits" % self.dir)
        gcf, cf = create_awterm_convolutionfunction(self.model,
                                                    make_pb=make_pb,
                                                    nw=100,
                                                    wstep=8.0,
                                                    oversampling=16,
                                                    support=32,
                                                    use_aaf=True)
        cf_image = convert_convolutionfunction_to_image(cf)
        cf_image.data = numpy.real(cf_image.data)
        if self.persist:
            export_image_to_fits(cf_image,
                                 "%s/test_gridding_awterm_cf.fits" % self.dir)

        griddata = create_griddata_from_image(self.model, nw=100, wstep=8.0)
        griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                      griddata=griddata,
                                                      cf=cf)
        im = fft_griddata_to_image(griddata, gcf)
        im = normalize_sumwt(im, sumwt)
        if self.persist:
            export_image_to_fits(
                im, '%s/test_gridding_dirty_awterm.fits' % self.dir)
        self.check_peaks(im, 97.13240677427714)
Ejemplo n.º 3
0
 def test_griddata_invert_aterm_noover(self):
     self.actualSetUp(zerow=True)
     make_pb = functools.partial(create_pb_generic,
                                 diameter=35.0,
                                 blockage=0.0,
                                 use_local=False)
     pb = make_pb(self.model)
     if self.persist:
         export_image_to_fits(pb,
                              "%s/test_gridding_aterm_pb.fits" % self.dir)
     gcf, cf = create_awterm_convolutionfunction(self.model,
                                                 make_pb=make_pb,
                                                 nw=1,
                                                 oversampling=1,
                                                 support=16,
                                                 use_aaf=True)
     griddata = create_griddata_from_image(self.model)
     griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                   griddata=griddata,
                                                   cf=cf)
     im = fft_griddata_to_image(griddata, gcf)
     im = normalize_sumwt(im, sumwt)
     if self.persist:
         export_image_to_fits(
             im, '%s/test_gridding_dirty_aterm_noover.fits' % self.dir)
     self.check_peaks(im, 97.10594988491549)
Ejemplo n.º 4
0
def invert_2d(vis: Visibility,
              im: Image,
              dopsf: bool = False,
              normalize: bool = True,
              gcfcf=None,
              **kwargs) -> (Image, numpy.ndarray):
    """ Invert using 2D convolution function, using the specified convolution function

    Use the image im as a template. Do PSF in a separate call.

    This is at the bottom of the layering i.e. all transforms are eventually expressed in terms
    of this function. Any shifting needed is performed here.

    :param vis: Visibility to be inverted
    :param im: image template (not changed)
    :param dopsf: Make the psf instead of the dirty image
    :param normalize: Normalize by the sum of weights (True)
    :param gcfcf: (Grid correction function i.e. in image space, Convolution function i.e. in uv space)
    :return: resulting image

    """
    assert isinstance(vis, Visibility), vis

    svis = copy_visibility(vis)

    if dopsf:
        svis.data['vis'][...] = 1.0 + 0.0j

    svis = shift_vis_to_image(svis, im, tangent=True, inverse=False)

    if gcfcf is None:
        gcf, cf = create_pswf_convolutionfunction(
            im,
            support=get_parameter(kwargs, "support", 6),
            oversampling=get_parameter(kwargs, "oversampling", 128))
    else:
        gcf, cf = gcfcf

    griddata = create_griddata_from_image(im)
    griddata, sumwt = grid_visibility_to_griddata(svis,
                                                  griddata=griddata,
                                                  cf=cf)

    imaginary = get_parameter(kwargs, "imaginary", False)
    if imaginary:
        result0, result1 = fft_griddata_to_image(griddata,
                                                 gcf,
                                                 imaginary=imaginary)
        log.debug("invert_2d: retaining imaginary part of dirty image")
        if normalize:
            result0 = normalize_sumwt(result0, sumwt)
            result1 = normalize_sumwt(result1, sumwt)
        return result0, sumwt, result1
    else:
        result = fft_griddata_to_image(griddata, gcf)
        if normalize:
            result = normalize_sumwt(result, sumwt)
        return result, sumwt
Ejemplo n.º 5
0
 def test_griddata_invert_box(self):
     self.actualSetUp(zerow=True)
     gcf, cf = create_box_convolutionfunction(self.model)
     griddata = create_griddata_from_image(self.model)
     griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                   griddata=griddata,
                                                   cf=cf)
     im = fft_griddata_to_image(griddata, gcf)
     im = normalize_sumwt(im, sumwt)
     if self.persist:
         export_image_to_fits(im,
                              '%s/test_gridding_dirty_box.fits' % self.dir)
     self.check_peaks(im, 97.10594988491546, tol=1e-7)
Ejemplo n.º 6
0
 def test_griddata_invert_pswf_w(self):
     self.actualSetUp(zerow=False)
     gcf, cf = create_pswf_convolutionfunction(self.model)
     griddata = create_griddata_from_image(self.model, self.vis)
     griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                   griddata=griddata,
                                                   cf=cf)
     cim = fft_griddata_to_image(griddata, gcf)
     cim = normalize_sumwt(cim, sumwt)
     im = convert_polimage_to_stokes(cim)
     if self.persist:
         export_image_to_fits(
             im, '%s/test_gridding_dirty_pswf_w.fits' % self.dir)
     self.check_peaks(im, 97.13240718331633, tol=1e-7)
Ejemplo n.º 7
0
 def test_griddata_invert_pswf_stokesIQ(self):
     self.actualSetUp(zerow=True, image_pol=PolarisationFrame("stokesIQ"))
     gcf, cf = create_pswf_convolutionfunction(self.model)
     griddata = create_griddata_from_image(self.model, self.vis)
     griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                   griddata=griddata,
                                                   cf=cf)
     cim = fft_griddata_to_image(griddata, gcf)
     cim = normalize_sumwt(cim, sumwt)
     im = convert_polimage_to_stokes(cim)
     if self.persist:
         export_image_to_fits(im,
                              '%s/test_gridding_dirty_pswf.fits' % self.dir)
     self.check_peaks(im, 97.10594988491545, tol=1e-7)
Ejemplo n.º 8
0
 def test_griddata_invert_pswf_w(self):
     self.actualSetUp(zerow=False)
     gcf, cf = create_pswf_convolutionfunction(self.model,
                                               support=6,
                                               oversampling=32)
     griddata = create_griddata_from_image(self.model)
     griddata, sumwt = grid_visibility_to_griddata(self.vis,
                                                   griddata=griddata,
                                                   cf=cf)
     im = fft_griddata_to_image(griddata, gcf)
     im = normalize_sumwt(im, sumwt)
     if self.persist:
         export_image_to_fits(
             im, '%s/test_gridding_dirty_pswf_w.fits' % self.dir)
     self.check_peaks(im, 97.01838776845877, tol=1e-7)
Ejemplo n.º 9
0
 def test_griddata_weight(self):
     self.actualSetUp(zerow=True)
     gcf, cf = create_box_convolutionfunction(self.model)
     gd = create_griddata_from_image(self.model)
     gd_list = [
         grid_weight_to_griddata(self.vis, gd, cf) for i in range(10)
     ]
     gd, sumwt = griddata_merge_weights(gd_list, algorithm='uniform')
     self.vis = griddata_reweight(self.vis, gd, cf)
     gd, sumwt = grid_visibility_to_griddata(self.vis, griddata=gd, cf=cf)
     im = fft_griddata_to_image(gd, gcf)
     im = normalize_sumwt(im, sumwt)
     if self.persist:
         export_image_to_fits(
             im, '%s/test_gridding_dirty_2d_uniform.fits' % self.dir)
     self.check_peaks(im, 99.40822097133994)
Ejemplo n.º 10
0
 def test_griddata_visibility_weight_IQ(self):
     self.actualSetUp(zerow=True, image_pol=PolarisationFrame("stokesIQUV"))
     gcf, cf = create_pswf_convolutionfunction(self.model)
     gd = create_griddata_from_image(self.model, self.vis)
     gd_list = [
         grid_visibility_weight_to_griddata(self.vis, gd, cf)
         for i in range(10)
     ]
     gd, sumwt = griddata_merge_weights(gd_list, algorithm='uniform')
     self.vis = griddata_visibility_reweight(self.vis, gd, cf)
     gd, sumwt = grid_visibility_to_griddata(self.vis, griddata=gd, cf=cf)
     cim = fft_griddata_to_image(gd, gcf)
     cim = normalize_sumwt(cim, sumwt)
     im = convert_polimage_to_stokes(cim)
     if self.persist:
         export_image_to_fits(
             im, '%s/test_gridding_dirty_2d_IQ_uniform.fits' % self.dir)
     self.check_peaks(im, 99.40822097133994)