Esempio n. 1
0
    def deconvolve(dirty, psf, model, facet, gthreshold, msk=None):
        if prefix == '':
            lprefix = "facet %d" % facet
        else:
            lprefix = "%s, facet %d" % (prefix, facet)

        if nmoment > 0:
            moment0 = calculate_image_frequency_moments(dirty)
            this_peak = numpy.max(numpy.abs(
                moment0.data[0, ...])) / dirty.data.shape[0]
        else:
            ref_chan = dirty.data.shape[0] // 2
            this_peak = numpy.max(numpy.abs(dirty.data[ref_chan, ...]))

        if this_peak > 1.1 * gthreshold:
            kwargs['threshold'] = gthreshold
            result, _ = deconvolve_cube(dirty,
                                        psf,
                                        prefix=lprefix,
                                        mask=msk,
                                        **kwargs)

            if result.data.shape[0] == model.data.shape[0]:
                result.data += model.data
            return result
        else:
            return copy_image(model)
Esempio n. 2
0
 def load_invert_and_deconvolve(c):
     
     v1 = create_visibility_from_ms(input_vis[0], channum=[c])[0]
     v2 = create_visibility_from_ms(input_vis[1], channum=[c])[0]
     vf = append_visibility(v1, v2)
     vf = convert_visibility_to_stokes(vf)
     vf.configuration.diameter[...] = 35.0
     rows = vis_select_uvrange(vf, 0.0, uvmax=uvmax)
     v = create_visibility_from_rows(vf, rows)
     
     m = create_image_from_visibility(v, npixel=npixel, cellsize=cellsize,
                                      polarisation_frame=pol_frame)
     
     if context == '2d':
         d, sumwt = invert_2d(v, m, dopsf=False)
         p, sumwt = invert_2d(v, m, dopsf=True)
     else:
         d, sumwt = invert_list_serial_workflow([v], [m], context=context, dopsf=False,
                                                vis_slices=vis_slices)[0]
         p, sumwt = invert_list_serial_workflow([v], [m], context=context, dopsf=True,
                                                vis_slices=vis_slices)[0]
     c, resid = deconvolve_cube(d, p, m, threshold=0.01, fracthresh=0.01, window_shape='quarter',
                                niter=100, gain=0.1, algorithm='hogbom-complex')
     r = restore_cube(c, p, resid, psfwidth=psfwidth)
     return r
Esempio n. 3
0
 def deconvolve(d, p, m):
     import time
     c, resid = deconvolve_cube(d[0],
                                p[0],
                                m,
                                threshold=0.01,
                                fracthresh=0.01,
                                window_shape='quarter',
                                niter=100,
                                gain=0.1,
                                algorithm='hogbom-complex')
     r = restore_cube(c, p[0], resid)
     return r
Esempio n. 4
0
    def deconvolve(dirty, psf, model, facet, gthreshold):
        import time
        starttime = time.time()
        if prefix == '':
            lprefix = "facet %d" % facet
        else:
            lprefix = "%s, facet %d" % (prefix, facet)

        nmoments = get_parameter(kwargs, "nmoments", 0)

        if nmoments > 0:
            moment0 = calculate_image_frequency_moments(dirty)
            this_peak = numpy.max(numpy.abs(
                moment0.data[0, ...])) / dirty.data.shape[0]
        else:
            this_peak = numpy.max(numpy.abs(dirty.data[0, ...]))

        if this_peak > 1.1 * gthreshold:
            log.info(
                "deconvolve_list_arlexecute_workflow %s: cleaning - peak %.6f > 1.1 * threshold %.6f"
                % (lprefix, this_peak, gthreshold))
            kwargs['threshold'] = gthreshold
            result, _ = deconvolve_cube(dirty, psf, prefix=lprefix, **kwargs)

            if result.data.shape[0] == model.data.shape[0]:
                result.data += model.data
            else:
                log.warning(
                    "deconvolve_list_arlexecute_workflow %s: Initial model %s and clean result %s do not have the same shape"
                    % (lprefix, str(
                        model.data.shape[0]), str(result.data.shape[0])))

            flux = numpy.sum(result.data[0, 0, ...])
            log.info(
                '### %s, %.6f, %.6f, True, %.3f # cycle, facet, peak, cleaned flux, clean, time?'
                % (lprefix, this_peak, flux, time.time() - starttime))

            return result
        else:
            log.info(
                "deconvolve_list_arlexecute_workflow %s: Not cleaning - peak %.6f <= 1.1 * threshold %.6f"
                % (lprefix, this_peak, gthreshold))
            log.info(
                '### %s, %.6f, %.6f, False, %.3f # cycle, facet, peak, cleaned flux, clean, time?'
                % (lprefix, this_peak, 0.0, time.time() - starttime))

            return copy_image(model)
Esempio n. 5
0
 def deconvolve_subimage(dirty, psf):
     assert isinstance(dirty, Image)
     assert isinstance(psf, Image)
     comp = deconvolve_cube(dirty, psf, **kwargs)
     return comp[0]