Source code for pipeline.hifa.cli.hifa_bandpass

##################### generated by xml-casa (v2) from hifa_bandpass.xml #############
##################### 2643377cfd2d5fa81e8e55df2aa3a976 ##############################
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_hifa_bandpass import hifa_bandpass as _hifa_bandpass_t
from casatasks.private.task_logging import start_log as _start_log
from casatasks.private.task_logging import end_log as _end_log

class _hifa_bandpass:
    """
    hifa_bandpass ---- Compute bandpass calibration solutions

    
    The hifa_bandpass task computes a bandpass solution for every specified science
    spectral window. By default a 'phaseup' pre-calibration is performed
    and applied on the fly to the data, before the bandpass is computed.
    
    The hif_refant task may be used to pre-compute a prioritized list of
    reference antennas.
    
    If pipeline mode is 'getinputs' then None is returned. Otherwise
    the results object for the pipeline task is returned.
    
    Issues:
    There is currently some discussion about whether or not to do an 'ampup'
    operations at the same time as the 'phaseup'. This is not required for the
    bandpass computation but the amplitude information may provide a useful quality
    assessment measure.
    
    The specified minsnr parameter is currently applied to the bandpass
    solution computation but not the 'phaseup' computation. Some noisy
    solutions in the phaseup may not be properly rejected.

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

    vis                 List of input MeasurementSets. Defaults to the list of
                        MeasurementSets specified in the pipeline context.
                        
                        Example: vis=['ngc5921.ms']
    caltable            List of names for the output calibration tables. Defaults
                        to the standard pipeline naming convention.
                        
                        Example: caltable=['ngc5921.gcal']
    field               The list of field names or field ids for which bandpasses are
                        computed. Set to field='' by default, which means the task will select all
                        fields.
                        
                        Example: field='3C279', field='3C279,M82'
    intent              A string containing a comma delimited list of intents against
                        which the selected fields are matched. Set to intent='' by default, which
                        means the task will select all data with the BANDPASS intent.
                        
                        Example: intent='*PHASE*'
    spw                 The list of spectral windows and channels for which bandpasses are
                        computed. Set to spw='' by default, which means the task will select all
                        science spectral windows.
                        
                        Example: spw='11,13,15,17'
    antenna             Set of data selection antenna IDs
    hm_phaseup          The pre-bandpass solution phaseup gain heuristics. The options are:
                        'snr': compute solution required to achieve the specified SNR
                        'manual': use manual solution parameters
                        '': skip phaseup
                        
                        Example: hm_phaseup='manual'
    phaseupsolint       The phase correction solution interval in CASA syntax.
                        Used when hm_phaseup='manual' or as a default if the hm_phaseup='snr'
                        heuristic computation fails.
                        
                        Example: phaseupsolint='300s'
    phaseupbw           Bandwidth to be used for phaseup. Used when hm_phaseup='manual'.
                        
                        Example: phaseupbw='' to use entire bandpass
                                 phaseupbw='500MHz' to use central 500MHz
    phaseupsnr          The required SNR for the phaseup solution. Used only if
                        hm_phaseup='snr'.
                        
                        Example: phaseupsnr=10.0
    phaseupnsols        The minimum number of phaseup gain solutions. Used only if
                        hm_phaseup='snr'.
                        
                        Example: phaseupnsols=4
    hm_bandpass         The bandpass solution heuristics. The options are:
                        'snr': compute the solution required to achieve the specified SNR
                        'smoothed': simple smoothing heuristics
                        'fixed': use the user defined parameters for all spws
    solint              Time and channel solution intervals in CASA syntax.
                        
                        Default is solint='inf', which is used when hm_bandpass='fixed'.
                        If hm_bandpass is set to 'snr', then the task will attempt to compute and use
                        an optimal SNR-based solint (and warn if this solint is not good enough).
                        If hm_bandpass is set to 'smoothed', the task will use a smoothed solint.
    maxchannels         The bandpass solution smoothing factor in channels. The
                        solution interval is bandwidth / 240. Set to 0 for no smoothing.
                        Used if hm_bandpass='smoothed'.
                        
                        Example: maxchannels=0
    evenbpints          Force the per spw frequency solint to be evenly divisible
                        into the spw bandpass if hm_bandpass='snr'.
                        
                        Example: evenbpints=False
    bpsnr               The required SNR for the bandpass solution. Used only if
                        hm_bandpass='snr'.
                        
                        Example: bpsnr=30.0
    minbpsnr            The minimum required SNR for the bandpass solution
                        when strong atmospheric lines exist in Tsys spectra.
                        Used only if hm_bandpass='snr'.
                        
                        Example: minbpsnr=10.0
    bpnsols             The minimum number of bandpass solutions. Used only if
                        hm_bandpass='snr'.
    combine             Data axes to combine for solving. Axes are '', 'scan', 'spw',
                        'field' or any comma-separated combination.
                        
                        Example: combine='scan,field'
    refant              List of reference antenna names. Defaults to the value(s) stored in the
                        pipeline context. If undefined in the pipeline context defaults to
                        the CASA reference antenna naming scheme.
                        
                        Example: refant='DV06,DV07'
    solnorm             Normalise the bandpass solution
    minblperant         Minimum number of baselines required per antenna for each solve.
                        Antennas with fewer baselines are excluded from solutions.
    minsnr              Solutions below this SNR are rejected
    unregister_existing Unregister all bandpass calibrations from the pipeline context
                        before registering the new bandpass calibrations from this task.
    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 commands (True) or generate the commands to be run but
                        do not execute (False).
    acceptresults       Automatically accept the results of the task into the pipeline context (True)
                        or reject them (False).

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

    
    1. Compute a channel bandpass for all visibility files in the pipeline
    context using the CASA reference antenna determination scheme:
    
    hifa_bandpass()
    
    2. Same as the above but precompute a prioritized reference antenna list:
    
    hif_refant()
    hifa_bandpass()


    """

    _info_group_ = """pipeline"""
    _info_desc_ = """Compute bandpass calibration solutions"""

    def __call__( self, vis=[  ], caltable=[  ], field='', intent='', spw='', antenna='', hm_phaseup='snr', phaseupsolint='int', phaseupbw='', phaseupsnr=float(20.0), phaseupnsols=int(2), hm_bandpass='snr', solint='inf', maxchannels=int(240), evenbpints=True, bpsnr=float(50.0), minbpsnr=float(20.0), bpnsols=int(8), combine='scan', refant='', solnorm=True, minblperant=int(4), minsnr=float(3.0), unregister_existing=False, pipelinemode='automatic', dryrun=False, acceptresults=True ):
        schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'caltable': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'hm_phaseup': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'snr', 'manual', '' ]}, 'phaseupsolint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'phaseupbw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'phaseupsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'phaseupnsols': {'type': 'cInt'}, 'hm_bandpass': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'snr', 'smoothed', 'fixed' ]}, 'solint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'maxchannels': {'type': 'cInt'}, 'evenbpints': {'type': 'cBool'}, 'bpsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'minbpsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'bpnsols': {'type': 'cInt'}, 'combine': {'type': 'cStr', 'coerce': _coerce.to_str}, 'refant': {'type': 'cStr', 'coerce': _coerce.to_str}, 'solnorm': {'type': 'cBool'}, 'minblperant': {'type': 'cInt'}, 'minsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'unregister_existing': {'type': 'cBool'}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
        doc = {'vis': vis, 'caltable': caltable, 'field': field, 'intent': intent, 'spw': spw, 'antenna': antenna, 'hm_phaseup': hm_phaseup, 'phaseupsolint': phaseupsolint, 'phaseupbw': phaseupbw, 'phaseupsnr': phaseupsnr, 'phaseupnsols': phaseupnsols, 'hm_bandpass': hm_bandpass, 'solint': solint, 'maxchannels': maxchannels, 'evenbpints': evenbpints, 'bpsnr': bpsnr, 'minbpsnr': minbpsnr, 'bpnsols': bpnsols, 'combine': combine, 'refant': refant, 'solnorm': solnorm, 'minblperant': minblperant, 'minsnr': minsnr, 'unregister_existing': unregister_existing, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hifa_bandpass', [ 'vis=' + repr(_pc.document['vis']), 'caltable=' + repr(_pc.document['caltable']), 'field=' + repr(_pc.document['field']), 'intent=' + repr(_pc.document['intent']), 'spw=' + repr(_pc.document['spw']), 'antenna=' + repr(_pc.document['antenna']), 'hm_phaseup=' + repr(_pc.document['hm_phaseup']), 'phaseupsolint=' + repr(_pc.document['phaseupsolint']), 'phaseupbw=' + repr(_pc.document['phaseupbw']), 'phaseupsnr=' + repr(_pc.document['phaseupsnr']), 'phaseupnsols=' + repr(_pc.document['phaseupnsols']), 'hm_bandpass=' + repr(_pc.document['hm_bandpass']), 'solint=' + repr(_pc.document['solint']), 'maxchannels=' + repr(_pc.document['maxchannels']), 'evenbpints=' + repr(_pc.document['evenbpints']), 'bpsnr=' + repr(_pc.document['bpsnr']), 'minbpsnr=' + repr(_pc.document['minbpsnr']), 'bpnsols=' + repr(_pc.document['bpnsols']), 'combine=' + repr(_pc.document['combine']), 'refant=' + repr(_pc.document['refant']), 'solnorm=' + repr(_pc.document['solnorm']), 'minblperant=' + repr(_pc.document['minblperant']), 'minsnr=' + repr(_pc.document['minsnr']), 'unregister_existing=' + repr(_pc.document['unregister_existing']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']) ] )
        return _end_log( _logging_state_, 'hifa_bandpass', _hifa_bandpass_t( _pc.document['vis'], _pc.document['caltable'], _pc.document['field'], _pc.document['intent'], _pc.document['spw'], _pc.document['antenna'], _pc.document['hm_phaseup'], _pc.document['phaseupsolint'], _pc.document['phaseupbw'], _pc.document['phaseupsnr'], _pc.document['phaseupnsols'], _pc.document['hm_bandpass'], _pc.document['solint'], _pc.document['maxchannels'], _pc.document['evenbpints'], _pc.document['bpsnr'], _pc.document['minbpsnr'], _pc.document['bpnsols'], _pc.document['combine'], _pc.document['refant'], _pc.document['solnorm'], _pc.document['minblperant'], _pc.document['minsnr'], _pc.document['unregister_existing'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hifa_bandpass = _hifa_bandpass( )