Source code for pipeline.hif.cli.hif_makeimlist

##################### generated by xml-casa (v2) from hif_makeimlist.xml ############
##################### a986d92169339078a04432f0d8abc957 ##############################
from __future__ import absolute_import
import numpy
from casatools.typecheck import CasaValidator as _val_ctor
_pc = _val_ctor( )
from casatools.coercetype import coerce as _coerce
from .private.task_hif_makeimlist import hif_makeimlist as _hif_makeimlist_t
from casatasks.private.task_logging import start_log as _start_log
from casatasks.private.task_logging import end_log as _end_log

class _hif_makeimlist:
    """
    hif_makeimlist ---- Compute list of clean images to be produced

    
    Create a a list of images to be cleaned.
    
    Generate a list of images to be cleaned. By default the list will include
    one image per science target per spw. Calibrator targets can be selected
    by setting appropriate values for intent.
    
    By default the output image cell size is set to the minimum cell size
    consistent with the UV coverage.
    
    By default the image size in pixels is set to values determined by the
    cell size and the single dish beam size. If a calibrator is being
    imaged (intents 'PHASE', 'BANDPASS', 'FLUX' or 'AMPLITUDE') then the
    image dimensions are limited to 'calmaxpix' pixels.
    
    By default science target images are cubes and calibrator target images
    are single channel. Science target images may be mosaics or single fields.
    
    Output
    
    results -- If pipeline mode is 'getinputs' then None is returned. Otherwise
    the results object for the pipeline task is returned.

    --------- parameter descriptions ---------------------------------------------

    vis           The list of input MeasurementSets. Defaults to the list of
                  MeasurementSets specified in the h_init or hif_importdata task.
                  "": use all MeasurementSets in the context
                  
                  Examples: 'ngc5921.ms', ['ngc5921a.ms', ngc5921b.ms', 'ngc5921c.ms']
    imagename     Prefix for output image names, "" for automatic.
    intent        Select intents for which associated fields will be imaged.
                  Possible choices are PHASE, BANDPASS, AMPLITUDE, CHECK and
                  TARGET or combinations thereof.
                  
                  Examples: 'PHASE,BANDPASS', 'TARGET'
    field         Select fields to image. Use field name(s) NOT id(s). Mosaics
                  are assumed to have common source / field names.  If intent is
                  specified only fields with data matching the intent will be
                  selected. The fields will be selected from MeasurementSets in
                  "vis".
                  "" Fields matching intent, one image per target source.
    spw           Select spectral windows to image.
                  "": Images will be computed for all science spectral windows.
    contfile      Name of file with frequency ranges to use for continuum images.
    linesfile     Name of file with line frequency ranges to exclude for continuum images.
    uvrange       Select a set of uv ranges to image.
                  "": All uv data is included
                  
                  Examples: '0~1000klambda', ['0~100klambda', 100~1000klambda]
    specmode      Frequency imaging mode, 'mfs', 'cont', 'cube', 'repBW'. ''
                  defaults to 'cube' if intent parameter includes 'TARGET'
                  otherwise 'mfs'.
                  
                  specmode='mfs' produce one image per source and spw
                  specmode='cont' produce one image per source and aggregate
                           over all specified spws
                  specmode='cube' produce an LSRK frequency cube, channels are
                           specified in frequency
                  specmode='repBW' produce an LSRK frequency cube at
                           representative channel width
    outframe      velocity frame of output image (LSRK, '' for automatic)
    hm_imsize     Image X and Y size in pixels or PB level for single fields.
                  The explicit sizes must be even and divisible by 2,3,5,7 only.
                  The default values are derived as follows:
                    1. Determine phase center and spread of field centers
                       around it.
                    2. Set the size of the image to cover the spread of field
                       centers plus a border of width 0.75 * beam radius, to
                       first null.
                    3. Divide X and Y extents by cell size to arrive at the
                       number of pixels required.
                  The PB level setting for single fields leads to an imsize
                  extending to the specified level plus 5% padding in all
                  directions.
                  
                  Examples: '0.3pb', [120, 120]
    hm_cell       Image X and Y cell sizes. "" computes the cell size based on
                  the UV coverage of all the fields to be imaged and uses a
                  5 pix per beam sampling.
                  The pix per beam specification ('<number>ppb') uses the above
                  default cell size ('5ppb') and scales it accordingly.
                  The cells can also be specified as explicit measures.
                  
                  Examples: '3ppb', ['0.5arcsec', '0.5arcsec']
    calmaxpix     Maximum image X or Y size in pixels if a calibrator is being
                  imaged ('PHASE', 'BANDPASS', 'AMPLITUDE' or 'FLUX' intent).
    phasecenter   Direction measure or field id of the image center.
                  The default phase center is set to the mean of the field
                  directions of all fields that are to be image together.
                  
                  Examples: 'J2000 19h30m00 -40d00m00', 0
    nchan         Total number of channels in the output image(s)
                  -1 selects enough channels to cover the data selected by
                  spw consistent with start and width.
    start         Start of image frequency axis as frequency or velocity.
                  "" selects start frequency automatically.
    width         Output channel width.
                  Difference in frequency between 2 selected channels for
                  frequency mode images.
                  'pilotimage' for 15 MHz / 8 channel heuristic
    nbins         Channel binning factors for each spw.
                  Format: 'spw1:nb1,spw2:nb2,...' with optional wildcards: '*:nb'
                  
                  Examples: '9:2,11:4,13:2,15:8', '*:2'
    robust        Briggs robustness parameter
                  Values range from -2.0 (uniform) to 2.0 (natural)
    uvtaper       uv-taper on outer baselines
    clearlist     Clear any existing target list
    per_eb        Make an image target per EB
    calcsb        Force (re-)calculation of sensitivities and beams
    parallel      Use MPI cluster where possible
    pipelinemode  The pipeline operating mode.
                  In 'automatic' mode the pipeline determines the values of all
                  context defined pipeline inputs automatically.
                  In 'interactive' mode the user can set the pipeline context
                  defined parameters manually.
                  In 'getinputs' mode the user can check the settings of all
                  pipeline parameters without running the task.
    dryrun        Run the task (False) or just display the command (True)
    acceptresults Add the results of the task to the pipeline context (True) or
                  reject them (False).

    --------- examples -----------------------------------------------------------

    
    1. Make a list of science target images to be cleaned, one image per science
    spw.
    
    hif_makeimlist()
    
    2. Make a list of PHASE and BANDPASS calibrator targets to be imaged,
    one image per science spw.
    
    hif_makeimlist(intent='PHASE,BANDPASS')
    
    3. Make a list of PHASE calibrator images observed in spw 1, images limited to
    50 pixels on a side.
    
    hif_makeimlist(intent='PHASE',spw='1',calmaxpix=50)


    """

    _info_group_ = """pipeline"""
    _info_desc_ = """Compute list of clean images to be produced"""

    def __call__( self, vis=[  ], imagename='', intent='TARGET', field='', spw='', contfile='', linesfile='', uvrange='', specmode='', outframe='', hm_imsize='', hm_cell=[  ], calmaxpix=int(300), phasecenter='', nchan=int(-1), start='', width='', nbins='', robust=float(-999.0), uvtaper=[  ], clearlist=True, per_eb=False, calcsb=False, parallel='automatic', pipelinemode='automatic', dryrun=False, acceptresults=True ):
        schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'imagename': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'contfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'linesfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'uvrange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'specmode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'cont', 'repBW', 'cube', 'mfs', '' ]}, 'outframe': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ '', 'LSRK' ]}, 'hm_imsize': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'hm_cell': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'calmaxpix': {'type': 'cInt'}, 'phasecenter': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'nchan': {'type': 'cInt'}, 'start': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'width': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'nbins': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'robust': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'uvtaper': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'clearlist': {'type': 'cBool'}, 'per_eb': {'type': 'cBool'}, 'calcsb': {'type': 'cBool'}, 'parallel': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'true', 'false' ]}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
        doc = {'vis': vis, 'imagename': imagename, 'intent': intent, 'field': field, 'spw': spw, 'contfile': contfile, 'linesfile': linesfile, 'uvrange': uvrange, 'specmode': specmode, 'outframe': outframe, 'hm_imsize': hm_imsize, 'hm_cell': hm_cell, 'calmaxpix': calmaxpix, 'phasecenter': phasecenter, 'nchan': nchan, 'start': start, 'width': width, 'nbins': nbins, 'robust': robust, 'uvtaper': uvtaper, 'clearlist': clearlist, 'per_eb': per_eb, 'calcsb': calcsb, 'parallel': parallel, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hif_makeimlist', [ 'vis=' + repr(_pc.document['vis']), 'imagename=' + repr(_pc.document['imagename']), 'intent=' + repr(_pc.document['intent']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'contfile=' + repr(_pc.document['contfile']), 'linesfile=' + repr(_pc.document['linesfile']), 'uvrange=' + repr(_pc.document['uvrange']), 'specmode=' + repr(_pc.document['specmode']), 'outframe=' + repr(_pc.document['outframe']), 'hm_imsize=' + repr(_pc.document['hm_imsize']), 'hm_cell=' + repr(_pc.document['hm_cell']), 'calmaxpix=' + repr(_pc.document['calmaxpix']), 'phasecenter=' + repr(_pc.document['phasecenter']), 'nchan=' + repr(_pc.document['nchan']), 'start=' + repr(_pc.document['start']), 'width=' + repr(_pc.document['width']), 'nbins=' + repr(_pc.document['nbins']), 'robust=' + repr(_pc.document['robust']), 'uvtaper=' + repr(_pc.document['uvtaper']), 'clearlist=' + repr(_pc.document['clearlist']), 'per_eb=' + repr(_pc.document['per_eb']), 'calcsb=' + repr(_pc.document['calcsb']), 'parallel=' + repr(_pc.document['parallel']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']) ] )
        return _end_log( _logging_state_, 'hif_makeimlist', _hif_makeimlist_t( _pc.document['vis'], _pc.document['imagename'], _pc.document['intent'], _pc.document['field'], _pc.document['spw'], _pc.document['contfile'], _pc.document['linesfile'], _pc.document['uvrange'], _pc.document['specmode'], _pc.document['outframe'], _pc.document['hm_imsize'], _pc.document['hm_cell'], _pc.document['calmaxpix'], _pc.document['phasecenter'], _pc.document['nchan'], _pc.document['start'], _pc.document['width'], _pc.document['nbins'], _pc.document['robust'], _pc.document['uvtaper'], _pc.document['clearlist'], _pc.document['per_eb'], _pc.document['calcsb'], _pc.document['parallel'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hif_makeimlist = _hif_makeimlist( )