Ejemplo n.º 1
0
    def setup_deconvolver(self,imagename=''):
        """
        Cube or MFS minor cycles. 
        """
        params = ImagerParameters(msname=self.vis, field=self.field,spw=self.spw,timestr=self.timestr,
                                  imagename=imagename,
                                  imsize=self.imsize, cell=self.cell, phasecenter=self.phasecenter, 
                                  weighting=self.weighting,
                                  gridder=self.gridder, pblimit=self.pblimit,wprojplanes=self.wprojplanes,
                                  specmode=self.specmode,nchan=self.nchan,start=self.start, 
                                  reffreq=self.reffreq, width=self.width,interpolation=self.interpolation,
                                  deconvolver=self.deconvolver, scales=self.scales,nterms=self.nterms,
                                  niter=self.niter,cycleniter=self.cycleniter, threshold=self.threshold,
                                  mask=self.mask,interactive=False,datacolumn=self.datacolumn)
        
        self.deconvolvertool = PySynthesisImager(params=params)

        ## Why are we initializing these ? 
        self.deconvolvertool.initializeImagers()
        self.deconvolvertool.initializeNormalizers()
        self.deconvolvertool.setWeighting()

        
        ### These three should be unncessary.  Need a 'makeimage' method for csys generation. 
        self.deconvolvertool.makePSF() ## Make this to get a coordinate system
        self.deconvolvertool.makePB()  ## Make this to turn .weight into .pb maps
        self.deconvolvertool.runMajorCycle() ## Make this to make template residual images.

        ## Initialize deconvolvers. ( Order is important. This cleans up a leftover tablecache image.... FIX!)
        self.deconvolvertool.initializeDeconvolvers()
        self.deconvolvertool.initializeIterationControl()
Ejemplo n.º 2
0
def make_paramList(niter=0, mask=''):
    """
     Return paramList object with my default wproject
     parameters, except niter and mask, which I'll update
     after running Pybdsf.
     """
    return ImagerParameters(
         msname=msfile,\
         field='2',\
         phasecenter=2,\
         gridder='awproject',\
         wbawp=True,\
         conjbeams=True,\
         aterm=True,\
         psterm=False,\
         cfcache='3k_wbawp_w16.cf',\
         wprojplanes=16,\
         deconvolver='mtmfs',\
         nterms=2,\
         scales=[0,5,15,20],\
         weighting='briggs',\
         usemask='user',\
         mask=mask,\
         robust=0.7,\
         niter=niter,\
         cell='5arcsec',\
         pblimit = 0.0001,\
         imsize=3000,\
         interactive=False,\
         imagename=imname,\
         parallel=True)
Ejemplo n.º 3
0
    def setup_imager(self, imagename=''):
        """
        Cube imaging for major cycles.
        """
        params = ImagerParameters(msname=self.vis,
                                  field=self.field,
                                  spw=self.spw,
                                  imagename=imagename,
                                  imsize=self.imsize,
                                  cell=self.cell,
                                  phasecenter=self.phasecenter,
                                  weighting=self.weighting,
                                  gridder=self.gridder,
                                  pblimit=self.pblimit,
                                  wprojplanes=self.wprojplanes,
                                  specmode='cube',
                                  nchan=self.nchan,
                                  reffreq=self.reffreq,
                                  width=self.width,
                                  interpolation=self.interpolation,
                                  deconvolver='hogbom',
                                  niter=0,
                                  wbawp=True)

        self.imagertool = PySynthesisImager(params=params)
        self.imagertool.initializeImagers()
        self.imagertool.initializeNormalizers()
        self.imagertool.setWeighting()

        self.imagertool.makePSF()
        self.imagertool.makePB()
        self.imagertool.runMajorCycle()

        self.lib.copy_restoringbeam(fromthis=imagename + '.psf',
                                    tothis=imagename + '.residual')
Ejemplo n.º 4
0
def tclean(
        ####### Data Selection
        vis,  #='', 
        selectdata,
        field,  #='', 
        spw,  #='',
        timerange,  #='',
        uvrange,  #='',
        antenna,  #='',
        scan,  #='',
        observation,  #='',
        intent,  #='',
        datacolumn,  #='corrected',

        ####### Image definition
    imagename,  #='',
        imsize,  #=[100,100],
        cell,  #=['1.0arcsec','1.0arcsec'],
        phasecenter,  #='J2000 19:59:28.500 +40.44.01.50',
        stokes,  #='I',
        projection,  #='SIN',
        startmodel,  #='',

        ## Spectral parameters
    specmode,  #='mfs',
        reffreq,  #='',
        nchan,  #=1,
        start,  #='',
        width,  #='',
        outframe,  #='LSRK',
        veltype,  #='',
        restfreq,  #=[''],
        #    sysvel,#='',
        #    sysvelframe,#='',
    interpolation,  #='',
        ##
        ####### Gridding parameters
    gridder,  #='ft', 
        facets,  #=1,
        chanchunks,  #=1,
        wprojplanes,  #=1,

        ### PB
    vptable,
        aterm,  #=True,
        psterm,  #=True,
        wbawp,  #= True,
        conjbeams,  #= True,
        cfcache,  #= "",
        computepastep,  #=360.0,
        rotatepastep,  #=360.0,
        pblimit,  #=0.01,
        normtype,  #='flatnoise',

        ####### Deconvolution parameters
    deconvolver,  #='hogbom',
        scales,  #=[],
        nterms,  #=1,
        smallscalebias,  #=0.6

        ### restoration options
    restoration,
        restoringbeam,  #=[],
        pbcor,

        ##### Outliers
        outlierfile,  #='',

        ##### Weighting
    weighting,  #='natural',
        robust,  #=0.5,
        npixels,  #=0,
        #    uvtaper,#=False,
    uvtaper,  #=[],

        ##### Iteration control
    niter,  #=0, 
        gain,  #=0.1,
        threshold,  #=0.0, 
        cycleniter,  #=0, 
        cyclefactor,  #=1.0,
        minpsffraction,  #=0.1,
        maxpsffraction,  #=0.8,
        interactive,  #=False, 

        ##### (new) Mask parameters
    usemask,  #='user',
        mask,  #='',
        pbmask,  #='',
        maskthreshold,  #='',
        maskresolution,  #='',
        nmask,  #=0,

        ##### automask by multithresh
    sidelobethreshold,  #=5.0,
        noisethreshold,  #=3.0,
        lownoisethreshold,  #=3.0,
        negativethreshold,  #=0.0,
        smoothfactor,  #=1.0,
        minbeamfrac,  #=0.3, 
        cutthreshold,  #=0.01,
        growiterations,  #=100

        ## Misc
    restart,  #=True,
        savemodel,  #="none",

        #    makeimages,#="auto"
    calcres,  #=True,
        calcpsf,  #=True,

        ####### State parameters
    parallel):  #=False):

    #####################################################
    #### Sanity checks and controls
    #####################################################

    ### Move these checks elsewhere ?

    if specmode == 'cont':
        specmode = 'mfs'

    if specmode == 'mfs' and nterms == 1 and deconvolver == "mtmfs":
        casalog.post(
            "The MTMFS deconvolution algorithm (deconvolver='mtmfs') needs nterms>1.Please set nterms=2 (or more). ",
            "WARN", "task_tclean")
        return

    if specmode != 'mfs' and deconvolver == "mtmfs":
        casalog.post(
            "The MSMFS algorithm (deconvolver='mtmfs') applies only to specmode='mfs'.",
            "WARN", "task_tclean")
        return

    #####################################################
    #### Construct ImagerParameters object
    #####################################################

    imager = None
    paramList = None

    # Put all parameters into dictionaries and check them.
    paramList = ImagerParameters(
        msname=vis,
        field=field,
        spw=spw,
        timestr=timerange,
        uvdist=uvrange,
        antenna=antenna,
        scan=scan,
        obs=observation,
        state=intent,
        datacolumn=datacolumn,

        ### Image....
        imagename=imagename,
        #### Direction Image Coords
        imsize=imsize,
        cell=cell,
        phasecenter=phasecenter,
        stokes=stokes,
        projection=projection,
        startmodel=startmodel,

        ### Spectral Image Coords
        specmode=specmode,
        reffreq=reffreq,
        nchan=nchan,
        start=start,
        width=width,
        outframe=outframe,
        veltype=veltype,
        restfreq=restfreq,
        sysvel='',  #sysvel,
        sysvelframe='',  #sysvelframe,
        interpolation=interpolation,
        gridder=gridder,
        #        ftmachine=ftmachine,
        facets=facets,
        chanchunks=chanchunks,
        wprojplanes=wprojplanes,
        vptable=vptable,

        ### Gridding....
        aterm=aterm,
        psterm=psterm,
        wbawp=wbawp,
        cfcache=cfcache,
        conjbeams=conjbeams,
        computepastep=computepastep,
        rotatepastep=rotatepastep,
        pblimit=pblimit,
        normtype=normtype,
        outlierfile=outlierfile,
        restart=restart,
        weighting=weighting,
        robust=robust,
        npixels=npixels,
        uvtaper=uvtaper,

        ### Deconvolution
        niter=niter,
        cycleniter=cycleniter,
        loopgain=gain,
        threshold=threshold,
        cyclefactor=cyclefactor,
        minpsffraction=minpsffraction,
        maxpsffraction=maxpsffraction,
        interactive=interactive,
        deconvolver=deconvolver,
        scales=scales,
        nterms=nterms,
        scalebias=smallscalebias,
        restoringbeam=restoringbeam,

        ### new mask params
        usemask=usemask,
        mask=mask,
        pbmask=pbmask,
        maskthreshold=maskthreshold,
        maskresolution=maskresolution,
        nmask=nmask,

        ### automask multithresh params
        sidelobethreshold=sidelobethreshold,
        noisethreshold=noisethreshold,
        lownoisethreshold=lownoisethreshold,
        negativethreshold=negativethreshold,
        smoothfactor=smoothfactor,
        minbeamfrac=minbeamfrac,
        cutthreshold=cutthreshold,
        growiterations=growiterations,
        savemodel=savemodel)

    #paramList.printParameters()

    pcube = False
    concattype = ''
    if parallel == True and specmode != 'mfs':
        pcube = True
        parallel = False

    # catch non operational case (parallel cube tclean with interative=T)
    if pcube and interactive:
        casalog.post(
            "Interactive mode is not currently supported with parallel cube CLEANing, please restart by setting interactive=F",
            "WARN", "task_tclean")
        return False

    ## Setup Imager objects, for different parallelization schemes.
    if parallel == False and pcube == False:

        imager = PySynthesisImager(params=paramList)
    elif parallel == True:
        imager = PyParallelContSynthesisImager(params=paramList)
    elif pcube == True:
        imager = PyParallelCubeSynthesisImager(params=paramList)
        # virtualconcat type - changed from virtualmove to virtualcopy 2016-07-20
        concattype = 'virtualcopy'
    else:
        print 'Invalid parallel combination in doClean.'
        return False

    retrec = {}

    try:
        #if (1):
        ## Init major cycle elements
        t0 = time.time()
        imager.initializeImagers()

        # Construct the CFCache for AWProject-class of FTMs.  For
        # other choices the following three calls become NoOps.
        # imager.dryGridding();
        # imager.fillCFCache();
        # imager.reloadCFCache();

        imager.initializeNormalizers()
        imager.setWeighting()
        t1 = time.time()
        casalog.post(
            "***Time for initializing imager and normalizers: " + "%.2f" %
            (t1 - t0) + " sec", "INFO3", "task_tclean")

        ## Init minor cycle elements
        if niter > 0 or restoration == True:
            t0 = time.time()
            imager.initializeDeconvolvers()
            t1 = time.time()
            casalog.post(
                "***Time for initializing deconvolver(s): " + "%.2f" %
                (t1 - t0) + " sec", "INFO3", "task_tclean")

        if niter > 0:
            t0 = time.time()
            imager.initializeIterationControl()
            t1 = time.time()
            casalog.post(
                "***Time for initializing iteration controller: " + "%.2f" %
                (t1 - t0) + " sec", "INFO3", "task_tclean")

        ## Make PSF
        if calcpsf == True:
            t0 = time.time()

            imager.makePSF()

            t1 = time.time()
            casalog.post(
                "***Time for making PSF: " + "%.2f" % (t1 - t0) + " sec",
                "INFO3", "task_tclean")

            imager.makePB()

            t2 = time.time()
            casalog.post(
                "***Time for making PB: " + "%.2f" % (t2 - t1) + " sec",
                "INFO3", "task_tclean")

        if niter >= 0:

            ## Make dirty image
            if calcres == True:
                t0 = time.time()
                imager.runMajorCycle()
                t1 = time.time()
                casalog.post(
                    "***Time for major cycle (calcres=T): " + "%.2f" %
                    (t1 - t0) + " sec", "INFO3", "task_tclean")

            ## In case of no deconvolution iterations....
            if niter == 0 and calcres == False:
                if savemodel != "none":
                    imager.predictModel()

            ## Do deconvolution and iterations
            if niter > 0:

                isit = imager.hasConverged()
                imager.updateMask()

                while (not imager.hasConverged()):

                    #                    maskchanged = imager.updateMask()
                    #                    if maskchanged and imager.hasConverged() :
                    #                        break;

                    t0 = time.time()
                    imager.runMinorCycle()
                    t1 = time.time()
                    casalog.post(
                        "***Time for minor cycle: " + "%.2f" % (t1 - t0) +
                        " sec", "INFO3", "task_tclean")

                    t0 = time.time()
                    imager.runMajorCycle()
                    t1 = time.time()
                    casalog.post(
                        "***Time for major cycle: " + "%.2f" % (t1 - t0) +
                        " sec", "INFO3", "task_tclean")

                    imager.updateMask()

                ## Get summary from iterbot
                if type(interactive) != bool:
                    retrec = imager.getSummary()

            ## Restore images.
            if restoration == True:
                t0 = time.time()
                imager.restoreImages()
                t1 = time.time()
                casalog.post(
                    "***Time for restoring images: " + "%.2f" % (t1 - t0) +
                    " sec", "INFO3", "task_tclean")
                if pbcor == True:
                    t0 = time.time()
                    imager.pbcorImages()
                    t1 = time.time()
                    casalog.post(
                        "***Time for pb-correcting images: " + "%.2f" %
                        (t1 - t0) + " sec", "INFO3", "task_tclean")

        if (pcube):
            print "running concatImages ..."
            casalog.post(
                "Running virtualconcat (type=%s) of sub-cubes" % concattype,
                "INFO2", "task_tclean")
            # fixed to move subcubes
            imager.concatImages(type=concattype)

        ## Close tools.
        imager.deleteTools()

    except Exception as e:
        #print 'Exception : ' + str(e)
        casalog.post('Exception from task_tclean : ' + str(e), "SEVERE",
                     "task_tclean")
        if imager != None:
            imager.deleteTools()

        larg = list(e.args)
        larg[0] = 'Exception from task_tclean : ' + str(larg[0])
        e.args = tuple(larg)
        raise

    return retrec
PARAMS = ImagerParameters(
    msname=VIS_FILES,
    imagename=TEST_IMG,
    field='7',  # G28539
    spw='0',  # NH3 (1,1)
    specmode='cube',
    outframe='lsrk',
    veltype='radio',
    restfreq='23.6944955GHz',
    start='58.58km/s',
    nchan=380,
    imsize=[350, 350],  # 175 as, 350 "efficient size"
    cell='0.5arcsec',  # 3.4 as / 7
    pblimit=0.2,
    # gridder parameters
    gridder='standard',
    # deconvolver parameters
    deconvolver='multiscale',
    scales=[0, 7, 21],  # point, 1, 3 beam hpbw's
    scalebias=0.6,
    restoringbeam='common',
    weighting='briggs',
    robust=1.0,
    niter=1000000,
    threshold='1.8mJy',
    cyclefactor=1.5,
    interactive=False,
    verbose=True,
    # automasking parameters
    usemask='auto-multithresh',  # use ALMA 12m(short) values
    noisethreshold=3.0,
    sidelobethreshold=1.0,
    lownoisethreshold=1.5,
    minbeamfrac=2.0,
    negativethreshold=1000.0,
)
Ejemplo n.º 6
0
sigma = 0.025
point_thresh = 2 * sigma

params = ImagerParameters(
    msname='/mnt/bigdata/ekoch/M33/co21_noema/meas_sets/M33-ARM05.ms',
    datacolumn='data',
    imagename="M33-ARM05_multithresh_test",
    field='M33*',
    imsize=[1024, 700],
    cell='0.2arcsec',
    specmode='cube',
    start=1,
    width=1,
    nchan=-1,
    startmodel=None,
    gridder='mosaic',
    weighting='natural',
    niter=500000,
    threshold='{}Jy/beam'.format(point_thresh),
    phasecenter='J2000 01h33m33.191 +30d32m06.720',
    restfreq='230.538GHz',
    outframe='LSRK',
    pblimit=0.1,
    usemask='pb',
    pbmask=0.05,
    mask=None,
    deconvolver='hogbom',
    dopbcorr=False,
    chanchunks=-1)

# Using the result from the first multi-scale tclean call in line_imaging.py
Ejemplo n.º 7
0
def tsdimaging(infiles, outfile, overwrite, field, spw, antenna, scan, intent,
               mode, nchan, start, width, veltype, outframe, gridfunction,
               convsupport, truncate, gwidth, jwidth, imsize, cell,
               phasecenter, projection, ephemsrcname, pointingcolumn, restfreq,
               stokes, minweight, brightnessunit, clipminmax):

    origin = 'tsdimaging'
    imager = None

    try:
        # if spw starts with ':', add '*' at the beginning
        if isinstance(spw, str):
            _spw = '*' + spw if spw.startswith(':') else spw
        else:
            _spw = ['*' + v if v.startswith(':') else v for v in spw]

        # if antenna doesn't contain '&&&', append it
        def antenna_to_baseline(s):
            if len(s) == 0:
                return s
            elif len(s) > 3 and s.endswith('&&&'):
                return s
            else:
                return '{0}&&&'.format(s)

        if isinstance(antenna, str):
            baseline = antenna_to_baseline(antenna)
        else:
            baseline = [antenna_to_baseline(a) for a in antenna]

        # handle overwrite parameter
        _outfile = outfile.rstrip('/')
        presumed_imagename = _outfile + image_suffix
        if os.path.exists(presumed_imagename):
            if overwrite == False:
                raise RuntimeError(
                    'Output file \'{0}\' exists.'.format(presumed_imagename))
            else:
                # delete existing images
                casalog.post('Removing \'{0}\''.format(presumed_imagename))
                _remove_image(presumed_imagename)
                assert not os.path.exists(presumed_imagename)
                for _suffix in associate_suffixes:
                    casalog.post('Removing \'{0}\''.format(_outfile + _suffix))
                    _remove_image(_outfile + _suffix)
                    assert not os.path.exists(_outfile + _suffix)

        # parse parameter for spectral axis
        imnchan, imstart, imwidth = _configure_spectral_axis(
            mode, nchan, start, width, restfreq)
        _restfreq = _get_restfreq_if_empty(infiles, _spw, field, restfreq)

        # translate some default values into the ones that are consistent with the current framework
        gtruncate = _handle_grid_defaults(truncate)
        ggwidth = _handle_grid_defaults(gwidth)
        gjwidth = _handle_grid_defaults(jwidth)

        # handle image parameters
        if isinstance(infiles, str) or len(infiles) == 1:
            _imsize, _cell, _phasecenter = _handle_image_params(
                imsize, cell, phasecenter, infiles, field, _spw, antenna, scan,
                intent, _restfreq, pointingcolumn, ephemsrcname)
        else:
            # sort input data using cleanhelper function to get consistent result with older sdimaging
            o = OldImagerBasedTools()
            _sorted = o.sort_vis(infiles, _spw, mode, imwidth, field, antenna,
                                 scan, intent)
            sorted_vis, sorted_field, sorted_spw, sorted_antenna, sorted_scan, sorted_intent = _sorted
            _imsize, _cell, _phasecenter = _handle_image_params(
                imsize, cell, phasecenter, sorted_vis, sorted_field,
                sorted_spw, sorted_antenna, sorted_scan, sorted_intent,
                _restfreq, pointingcolumn, ephemsrcname)

        # calculate pblimit from minweight
        pblimit = _calc_pblimit(minweight)

        ## (2) Set up Input Parameters
        ##       - List all parameters that you need here
        ##       - Defaults will be assumed for unspecified parameters
        ##       - Nearly all parameters are identical to that in the task. Please look at the
        ##         list of parameters under __init__ using  " help ImagerParameters " )
        casalog.post('*** Creating paramList ***', origin=origin)
        paramList = ImagerParameters(
            # input file name
            msname=infiles,  #'sdimaging.ms',
            # data selection
            field=field,  #'',
            spw=_spw,  #'0',
            antenna=baseline,
            scan=scan,
            state=intent,
            # image parameters
            imagename=_outfile,  #'try2',
            nchan=imnchan,  #1024,
            start=imstart,  #'0',
            width=imwidth,  #'1',
            outframe=outframe,
            veltype=veltype,
            restfreq=_restfreq,
            phasecenter=_phasecenter,  #'J2000 17:18:29 +59.31.23',
            imsize=_imsize,  #[75,75], 
            cell=_cell,  #['3arcmin', '3arcmin'], 
            projection=projection,
            stokes=stokes,
            # fix specmode to 'cubedata'
            # output spectral coordinate will be determined based on mode, start, and width
            specmode='cube',
            gridder='singledish',
            # single dish specific parameters
            gridfunction=gridfunction,
            convsupport=convsupport,
            truncate=gtruncate,
            gwidth=ggwidth,
            jwidth=gjwidth,
            pointingcolumntouse=pointingcolumn,
            minweight=minweight,
            clipminmax=clipminmax,
            # normalizer
            normtype='flatsky',
            pblimit=pblimit)

        # TODO: hadnle ephemsrcname
        # handle brightnessunit (CAS-11503)
        image_unit = ''
        if len(brightnessunit) > 0:
            if brightnessunit.lower() == 'k':
                image_unit = 'K'
            elif brightnessunit.lower() == 'jy/beam':
                image_unit = 'Jy/beam'
            else:
                raise ValueError, "Invalid brightness unit, %s" % brightnessunit

        # TODO: handle overwrite
        # TODO: output image name

        ## (3) Construct the PySynthesisImager object, with all input parameters

        casalog.post('*** Creating imager object ***', origin=origin)
        imager = PySynthesisImager(params=paramList)

        ## (4) Initialize various modules.
        ##       - Pick only the modules you will need later on. For example, to only make
        ##         the PSF, there is no need for the deconvolver or iteration control modules.

        ## Initialize modules major cycle modules

        casalog.post('*** Initializing imagers ***', origin=origin)
        imager.initializeImagers()
        casalog.post('*** Initializing normalizers ***', origin=origin)
        imager.initializeNormalizers()
        #imager.setWeighting()

        ## (5) Make the initial images

        #imager.makePSF()
        casalog.post('*** Executing runMajorCycle ***', origin=origin)
        casalog.post('NF = {0}'.format(imager.NF), origin=origin)
        #imager.runMajorCycle()  # Make initial dirty / residual image
        imager.makeSdPSF()
        imager.makeSdImage()

    except Exception as e:
        #print 'Exception : ' + str(e)
        casalog.post('Exception from task_tsdimaging : ' + str(e),
                     "SEVERE",
                     origin=origin)
        #         if imager != None:
        #             imager.deleteTools()

        larg = list(e.args)
        larg[0] = 'Exception from task_tsdimaging : ' + str(larg[0])
        e.args = tuple(larg)
        raise

    finally:
        ## (8) Close tools.

        casalog.post('*** Cleaning up tools ***', origin=origin)
        if imager is not None:
            imager.deleteTools()

        # change image suffix from .residual to .image
        if os.path.exists(outfile + residual_suffix):
            os.rename(outfile + residual_suffix, outfile + image_suffix)

    # set beam size
    # TODO: re-define related functions in the new tool framework (sdms?)
    imagename = outfile + image_suffix
    ms_index = 0
    rep_ms = _get_param(0, infiles)
    rep_field = _get_param(0, field)
    rep_spw = _get_param(0, _spw)
    rep_antenna = _get_param(0, antenna)
    rep_scan = _get_param(0, scan)
    rep_intent = _get_param(0, intent)
    if len(rep_antenna) > 0:
        baseline = '{0}&&&'.format(rep_antenna)
    else:
        baseline = '*&&&'
    with open_ms(rep_ms) as ms:
        ms.msselect({'baseline': baseline})
        ndx = ms.msselectedindices()
        antenna_index = ndx['antenna1'][0]
    with open_table(os.path.join(rep_ms, 'ANTENNA')) as tb:
        antenna_name = tb.getcell('NAME', antenna_index)
        antenna_diameter = tb.getcell('DISH_DIAMETER', antenna_index)
    set_beam_size(rep_ms, imagename, rep_field, rep_spw, baseline, rep_scan,
                  rep_intent, ephemsrcname, pointingcolumn, antenna_name,
                  antenna_diameter, _restfreq, gridfunction, convsupport,
                  truncate, gwidth, jwidth)

    # set brightness unit (CAS-11503)
    if len(image_unit) > 0:
        with open_ia(imagename) as ia:
            casalog.post("Setting brightness unit '%s' to image." % image_unit)
            ia.setbrightnessunit(image_unit)

    # mask low weight pixels
    weightimage = outfile + weight_suffix
    do_weight_mask(imagename, weightimage, minweight)