Source code for pipeline.hifa.cli.hifa_gfluxscaleflag

##################### generated by xml-casa (v2) from hifa_gfluxscaleflag.xml #######
##################### c0591abdf9951a0579add1f561d7138b ##############################
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_gfluxscaleflag import hifa_gfluxscaleflag as _hifa_gfluxscaleflag_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_gfluxscaleflag:
    """
    hifa_gfluxscaleflag ---- Derive the flux density scale with flagging

    
    This task computes the flagging heuristics on the phase calibrator and flux
    calibrator by calling hif_correctedampflag which looks for outlier
    visibility points by statistically examining the scalar difference of
    corrected amplitudes minus model amplitudes, and flags those outliers. The
    philosophy is that only outlier data points that have remained outliers
    after calibration will be flagged. The heuristic works equally well on
    resolved calibrators and point sources because it is not performing a
    vector difference, and thus is not sensitive to nulls in the flux density
    vs. uvdistance domain. Note that the phase of the data is not assessed.
    
    In further detail, the workflow is as follows: a snapshot of the flagging
    state is preserved at the start, a preliminary phase and amplitude gaincal
    solution is solved and applied, the flagging heuristics are run and
    any outliers are marked for flagging, the flagging state is restored from the
    snapshot. If any outliers were found, then these are flagged. Plots are
    generated at two points in this workflow: after preliminary phase and
    amplitude calibration but before flagging heuristics are run, and after
    flagging heuristics have been run and applied. If no points were flagged,
    the 'after' plots are not generated or displayed. The score for this stage
    is the standard data flagging score, which depends on the fraction of data
    flagged.
    
    
    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 pipeline context.
                   
                   example: vis=['M51.ms']
    intent         A string containing a comma delimited list of intents against
                   which the selected fields are matched. If undefined (default), it
                   will select all data with the AMPLITUDE, PHASE, and CHECK intents,
                   except for one case: if one of the AMPLITUDE intent fields was also
                   used for BANDPASS, then this task will select only data with PHASE
                   and CHECK intents.
                   
                   example: intent='*PHASE*'
    phaseupsolint  The phase correction solution interval in CASA syntax.
                   
                   example: phaseupsolint='300s'
    solint         Time and channel solution intervals in CASA syntax.
                   
                   example: solint='inf,10ch', solint='inf'
    minsnr         Solutions below this SNR are rejected.
    refant         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='DV01', refant='DV06,DV07'
    antnegsig      Lower sigma threshold for identifying outliers as a result of bad
                   antennas within individual timestamps.
    antpossig      Upper sigma threshold for identifying outliers as a result of bad
                   antennas within individual timestamps.
    tmantint       Threshold for maximum fraction of timestamps that are allowed to
                   contain outliers.
    tmint          eshold for maximum fraction of "outlier timestamps" over
                   "total timestamps" that a baseline may be a part of.
    tmbl           Initial threshold for maximum fraction of "bad baselines" over "all
                   baselines" that an antenna may be a part of.
    antblnegsig    Lower sigma threshold for identifying outliers as a result of
                   "bad baselines" and/or "bad antennas" within baselines, across all
                   timestamps.
    antblpossig    threshold for identifying outliers as a result of
                   "bad baselines" and/or "bad antennas" within baselines, across all
                   timestamps.
    relaxed_factor Relaxed value to set the threshold scaling factor to under
                   certain conditions (see task description).
    niter          Maximum number of times to iterate on evaluation of flagging
                   heuristics. If an iteration results in no new flags, then subsequent
                   iterations are skipped.
    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.
                   
                   default: 'automatic'.
    dryrun         Run the commands (True) or generate the commands to be run but
                   do not execute (False).
    acceptresults  Add the results of the task to the pipeline context (True) or
                   reject them (False).

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

    
    1. run with recommended settings to create flux scale calibration with flagging
    using recommended thresholds:
    
    hifa_gfluxscaleflag()


    """

    _info_group_ = """pipeline"""
    _info_desc_ = """Derive the flux density scale with flagging"""

    def __call__( self, vis=[  ], intent='', phaseupsolint='int', solint='inf', minsnr=float(2.0), refant='', antnegsig=float(4.0), antpossig=float(4.6), tmantint=float(0.063), tmint=float(0.085), tmbl=float(0.175), antblnegsig=float(3.4), antblpossig=float(3.2), relaxed_factor=float(2.0), niter=int(2), pipelinemode='automatic', dryrun=False, acceptresults=True ):
        schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'phaseupsolint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'solint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'minsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'refant': {'type': 'cStr', 'coerce': _coerce.to_str}, 'antnegsig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'antpossig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'tmantint': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'tmint': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'tmbl': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'antblnegsig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'antblpossig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'relaxed_factor': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'niter': {'type': 'cInt'}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
        doc = {'vis': vis, 'intent': intent, 'phaseupsolint': phaseupsolint, 'solint': solint, 'minsnr': minsnr, 'refant': refant, 'antnegsig': antnegsig, 'antpossig': antpossig, 'tmantint': tmantint, 'tmint': tmint, 'tmbl': tmbl, 'antblnegsig': antblnegsig, 'antblpossig': antblpossig, 'relaxed_factor': relaxed_factor, 'niter': niter, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hifa_gfluxscaleflag', [ 'vis=' + repr(_pc.document['vis']), 'intent=' + repr(_pc.document['intent']), 'phaseupsolint=' + repr(_pc.document['phaseupsolint']), 'solint=' + repr(_pc.document['solint']), 'minsnr=' + repr(_pc.document['minsnr']), 'refant=' + repr(_pc.document['refant']), 'antnegsig=' + repr(_pc.document['antnegsig']), 'antpossig=' + repr(_pc.document['antpossig']), 'tmantint=' + repr(_pc.document['tmantint']), 'tmint=' + repr(_pc.document['tmint']), 'tmbl=' + repr(_pc.document['tmbl']), 'antblnegsig=' + repr(_pc.document['antblnegsig']), 'antblpossig=' + repr(_pc.document['antblpossig']), 'relaxed_factor=' + repr(_pc.document['relaxed_factor']), 'niter=' + repr(_pc.document['niter']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']) ] )
        return _end_log( _logging_state_, 'hifa_gfluxscaleflag', _hifa_gfluxscaleflag_t( _pc.document['vis'], _pc.document['intent'], _pc.document['phaseupsolint'], _pc.document['solint'], _pc.document['minsnr'], _pc.document['refant'], _pc.document['antnegsig'], _pc.document['antpossig'], _pc.document['tmantint'], _pc.document['tmint'], _pc.document['tmbl'], _pc.document['antblnegsig'], _pc.document['antblpossig'], _pc.document['relaxed_factor'], _pc.document['niter'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hifa_gfluxscaleflag = _hifa_gfluxscaleflag( )