Source code for pipeline.hif.cli.hif_rawflagchans

##################### generated by xml-casa (v2) from hif_rawflagchans.xml ##########
##################### 0a87bc6fdba43976ea8efb50c3ea7a84 ##############################
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_rawflagchans import hif_rawflagchans as _hif_rawflagchans_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_rawflagchans:
    """
    hif_rawflagchans ---- Flag deviant baseline/channels in raw data

    
    hif_rawflagchans flags deviant baseline/channels in the raw data.
    
    The flagging views used are derived from the raw data for the specified
    intent - default is BANDPASS.
    
    Bad baseline/channels are flagged for all intents, not just the
    one that is the basis of the flagging views.
    
    For each spectral window the flagging view is a 2d image with axes
    'channel' and 'baseline'. The pixel for each channel, baseline is the
    time average of the underlying unflagged raw data.
    
    The baseline axis is labeled by numbers of form id1.id2 where id1 and id2
    are the IDs of the baseline antennas. Both id1 and id2 run over all
    antenna IDs in the observation. This means that each baseline is shown
    twice but has the benefit that 'bad' antennas are easily identified by
    eye.
    
    Three flagging methods are available:
    
    If parameter flag_hilo is set True then outliers from the median
    of each flagging view will be flagged.
    
    If parameter flag_bad_quadrant is set True then a simple 2 part
    test is used to check for bad antenna quadrants and/or bad baseline
    quadrants. Here a 'quadrant' is defined simply as one quarter of the
    channel axis. The first part of the test is to note as 'suspect' those
    points further from the view median than fbq_hilo_limit * MAD.
    The second part is to flag entire antenna/quadrants if their
    fraction of suspect points exceeds fbq_antenna_frac_limit.
    Failing that, entire baseline/quadrants may be flagged if their
    fraction of suspect points exceeds fbq_baseline_frac_limit.
    Suspect points are not flagged unless as part of a bad antenna or
    baseline quadrant.
    
    
    Output
    
    results -- If pipeline mode is 'getinputs' then None is returned. Otherwise
    the results object for the pipeline task is returned.

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

    vis                     List of input MeasurementSets.
                            
                            default: [] - Use the MeasurementSets currently known to the pipeline
                            context.
    spw                     The list of spectral windows and channels to which the calibration
                            will be applied. Defaults to all science windows in the pipeline
                            context.
                            
                            example: spw='17', spw='11, 15'
    intent                  A string containing the list of intents to be checked for antennas
                            with deviant gains. The default is blank, which causes the task to select
                            the 'BANDPASS' intent.
                            
                            example: intent='*BANDPASS*'
    flag_hilo               True to flag channel/baseline data further from the view
                            median than fhl_limit * MAD.
    fhl_limit               If flag_hilo is True then flag channel/baseline data
                            further from the view median than fhl_limit * MAD.
    fhl_minsample           Do no flagging if the view median and MAD are derived
                            from fewer than fhl_minsample view pixels.
    flag_bad_quadrant       True to search for and flag bad antenna quadrants
                            and baseline quadrants. Here a /'quadrant/' is one
                            quarter of the channel axis.
    fbq_hilo_limit          If flag_bad_quadrant is True then channel/baselines further
                            from the view median than fbq_hilo_limit * MAD will be noted as
                            'suspect'. If there are enough of them to indicate that an antenna or
                            baseline quadrant is bad then all channel/baselines in that quadrant will
                            be flagged.
    fbq_antenna_frac_limit  If flag_bad_quadrant is True and the fraction of
                            suspect channel/baselines in a particular antenna/quadrant exceeds
                            fbq_antenna_frac_limit then all data for that antenna/quadrant will
                            be flagged.
    fbq_baseline_frac_limit If flag_bad_quadrant is True and the fraction of
                            suspect channel/baselines in a particular baseline/quadrant exceeds
                            fbq_baseline_frac_limit then all data for that baseline/quadrant will
                            be flagged.
    pipelinemode            e 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           This parameter has no effect. The Tsyscal file is already
                            in the pipeline context and is flagged in situ.

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

    
    1. Flag bad quadrants and wild outliers, default method:
    
    hif_rawflagchans()
    
    equivalent to:
    
    hif_rawflagchans(flag_hilo=True, fhl_limit=20,
    flag_bad_quadrant=True, fbq_hilo_limit=8,
    fbq_antenna_frac_limit=0.2, fbq_baseline_frac_limit=1.0)


    """

    _info_group_ = """pipeline"""
    _info_desc_ = """Flag deviant baseline/channels in raw data"""

    def __call__( self, vis=[  ], spw='', intent='', flag_hilo=True, fhl_limit=float(20.0), fhl_minsample=float(5), flag_bad_quadrant=True, fbq_hilo_limit=float(8.0), fbq_antenna_frac_limit=float(0.2), fbq_baseline_frac_limit=float(1.0), pipelinemode='automatic', dryrun=False, acceptresults=True ):
        schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'flag_hilo': {'type': 'cBool'}, 'fhl_limit': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'fhl_minsample': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_bad_quadrant': {'type': 'cBool'}, 'fbq_hilo_limit': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'fbq_antenna_frac_limit': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'fbq_baseline_frac_limit': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
        doc = {'vis': vis, 'spw': spw, 'intent': intent, 'flag_hilo': flag_hilo, 'fhl_limit': fhl_limit, 'fhl_minsample': fhl_minsample, 'flag_bad_quadrant': flag_bad_quadrant, 'fbq_hilo_limit': fbq_hilo_limit, 'fbq_antenna_frac_limit': fbq_antenna_frac_limit, 'fbq_baseline_frac_limit': fbq_baseline_frac_limit, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hif_rawflagchans', [ 'vis=' + repr(_pc.document['vis']), 'spw=' + repr(_pc.document['spw']), 'intent=' + repr(_pc.document['intent']), 'flag_hilo=' + repr(_pc.document['flag_hilo']), 'fhl_limit=' + repr(_pc.document['fhl_limit']), 'fhl_minsample=' + repr(_pc.document['fhl_minsample']), 'flag_bad_quadrant=' + repr(_pc.document['flag_bad_quadrant']), 'fbq_hilo_limit=' + repr(_pc.document['fbq_hilo_limit']), 'fbq_antenna_frac_limit=' + repr(_pc.document['fbq_antenna_frac_limit']), 'fbq_baseline_frac_limit=' + repr(_pc.document['fbq_baseline_frac_limit']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']) ] )
        return _end_log( _logging_state_, 'hif_rawflagchans', _hif_rawflagchans_t( _pc.document['vis'], _pc.document['spw'], _pc.document['intent'], _pc.document['flag_hilo'], _pc.document['fhl_limit'], _pc.document['fhl_minsample'], _pc.document['flag_bad_quadrant'], _pc.document['fbq_hilo_limit'], _pc.document['fbq_antenna_frac_limit'], _pc.document['fbq_baseline_frac_limit'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hif_rawflagchans = _hif_rawflagchans( )