Source code for pipeline.hsd.cli.hsd_blflag

##################### generated by xml-casa (v2) from hsd_blflag.xml ################
##################### f151a976ee2dbb445bded36b19ebbec6 ##############################
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_hsd_blflag import hsd_blflag as _hsd_blflag_t
from casatasks.private.task_logging import start_log as _start_log
from casatasks.private.task_logging import end_log as _end_log

class _hsd_blflag:
    """
    hsd_blflag ---- Flag spectra based on predefined criteria of single dish pipeline

    
    Data are flagged based on several flagging rules. Available rules are:
    expected rms, calculated rms, and running mean of both pre-fit and
    post-fit spectra. Tsys flagging is also available.
    
    In addition, the heuristics script creates many plots for each stage.
    Those plots are included in the weblog.
    
    Output:
    
    results -- If pipeline mode is 'getinputs' then None is returned. Otherwise
    the results object for the pipeline task is returned.

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

    iteration     Number of iterations to perform sigma clipping to 
                  calculate threshold value of flagging.
    edge          Number of channels to be dropped from the edge.
                  The value must be a list of integer with length of one or
                  		     two. If list length is one, same number will be applied 
                  both side of the band.
                  
                  example: [10,20], [10]
    flag_tsys     Activate (True) or deactivate (False) Tsys flag.
    tsys_thresh   Threshold value for Tsys flag.
    flag_weath    Activate (True) or deactivate (False) weather flag. 
                  Since weather flagging is not implemented yet, 
                  setting True has no effect at the moment.
    weath_thresh  Threshold value for weather flag.
    flag_prfre    Activate (True) or deactivate (False) flag by expected 
                  rms of pre-fit spectra.
    prfre_thresh  Threshold value for flag by expected rms of pre-fit 
                  spectra.
    flag_pofre    Activate (True) or deactivate (False) flag by expected 
                  rms of post-fit spectra.
    pofre_thresh  Threshold value for flag by expected rms of post-fit 
                  spectra.
    flag_prfr     Activate (True) or deactivate (False) flag by rms of 
                  pre-fit spectra.
    prfr_thresh   Threshold value for flag by rms of pre-fit spectra.
    flag_pofr     Activate (True) or deactivate (False) flag by rms of
                  post-fit spectra.
    pofr_thresh   Threshold value for flag by rms of post-fit spectra.
    flag_prfrm    Activate (True) or deactivate (False) flag by running 
                  mean of pre-fit spectra.
    prfrm_thresh  Threshold value for flag by running mean of pre-fit 
                  spectra.
    prfrm_nmean   Number of channels for running mean of pre-fit spectra.
    flag_pofrm    Activate (True) or deactivate (False) flag by running 
                  mean of post-fit spectra.
    pofrm_thresh  Threshold value for flag by running mean of post-fit 
                  spectra.
    pofrm_nmean   Number of channels for running mean of post-fit spectra.
    flag_user     Activate (True) or deactivate (False) user-defined flag. 
                  Since user flagging is not implemented yet, setting True 
                  has no effect at the moment.
    user_thresh   Threshold value for flag by user-defined rule.
    plotflag      True to plot result of data flagging.
    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.
    infiles       ASDM or MS files to be processed. This parameter behaves
                  as data selection parameter. The name specified by 
                  infiles must be registered to context before you run
                  hsd_blflag.
    antenna       Data selection by antenna names or ids.
                  example: 'PM03,PM04'
                           '' (all antennas)
    field         Data selection by field names or ids.
                  example: '*Sgr*,M100'
                           '' (all fields)
    spw           Data selection by spw ids.
                  example: '3,4' (spw 3 and 4)
                           '' (all spws)
    pol           Data selection by polarizations.
                  example: 'XX,YY' (correlation XX and YY)
                           '' (all polarizations)
    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).
    parallel      Execute using CASA HPC functionality, if available.

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

    


    """

    _info_group_ = """pipeline"""
    _info_desc_ = """Flag spectra based on predefined criteria of single dish pipeline"""

    def __call__( self, iteration=int(5), edge=[ int(0),int(0) ], flag_tsys=True, tsys_thresh=float(3.0), flag_weath=False, weath_thresh=float(3.0), flag_prfre=True, prfre_thresh=float(3.0), flag_pofre=True, pofre_thresh=float(1.3333), flag_prfr=True, prfr_thresh=float(4.5), flag_pofr=True, pofr_thresh=float(4.0), flag_prfrm=True, prfrm_thresh=float(5.5), prfrm_nmean=int(5), flag_pofrm=True, pofrm_thresh=float(5.0), pofrm_nmean=int(5), flag_user=False, user_thresh=float(5.0), plotflag=True, pipelinemode='automatic', infiles=[  ], antenna='', field='', spw='', pol='', dryrun=False, acceptresults=True, parallel='automatic' ):
        schema = {'iteration': {'type': 'cInt'}, 'edge': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'flag_tsys': {'type': 'cBool'}, 'tsys_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_weath': {'type': 'cBool'}, 'weath_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_prfre': {'type': 'cBool'}, 'prfre_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_pofre': {'type': 'cBool'}, 'pofre_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_prfr': {'type': 'cBool'}, 'prfr_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_pofr': {'type': 'cBool'}, 'pofr_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'flag_prfrm': {'type': 'cBool'}, 'prfrm_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'prfrm_nmean': {'type': 'cInt'}, 'flag_pofrm': {'type': 'cBool'}, 'pofrm_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'pofrm_nmean': {'type': 'cInt'}, 'flag_user': {'type': 'cBool'}, 'user_thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'plotflag': {'type': 'cBool'}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'infiles': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'pol': {'type': 'cStr', 'coerce': _coerce.to_str}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}, 'parallel': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'true', 'false' ]}}
        doc = {'iteration': iteration, 'edge': edge, 'flag_tsys': flag_tsys, 'tsys_thresh': tsys_thresh, 'flag_weath': flag_weath, 'weath_thresh': weath_thresh, 'flag_prfre': flag_prfre, 'prfre_thresh': prfre_thresh, 'flag_pofre': flag_pofre, 'pofre_thresh': pofre_thresh, 'flag_prfr': flag_prfr, 'prfr_thresh': prfr_thresh, 'flag_pofr': flag_pofr, 'pofr_thresh': pofr_thresh, 'flag_prfrm': flag_prfrm, 'prfrm_thresh': prfrm_thresh, 'prfrm_nmean': prfrm_nmean, 'flag_pofrm': flag_pofrm, 'pofrm_thresh': pofrm_thresh, 'pofrm_nmean': pofrm_nmean, 'flag_user': flag_user, 'user_thresh': user_thresh, 'plotflag': plotflag, 'pipelinemode': pipelinemode, 'infiles': infiles, 'antenna': antenna, 'field': field, 'spw': spw, 'pol': pol, 'dryrun': dryrun, 'acceptresults': acceptresults, 'parallel': parallel}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hsd_blflag', [ 'iteration=' + repr(_pc.document['iteration']), 'edge=' + repr(_pc.document['edge']), 'flag_tsys=' + repr(_pc.document['flag_tsys']), 'tsys_thresh=' + repr(_pc.document['tsys_thresh']), 'flag_weath=' + repr(_pc.document['flag_weath']), 'weath_thresh=' + repr(_pc.document['weath_thresh']), 'flag_prfre=' + repr(_pc.document['flag_prfre']), 'prfre_thresh=' + repr(_pc.document['prfre_thresh']), 'flag_pofre=' + repr(_pc.document['flag_pofre']), 'pofre_thresh=' + repr(_pc.document['pofre_thresh']), 'flag_prfr=' + repr(_pc.document['flag_prfr']), 'prfr_thresh=' + repr(_pc.document['prfr_thresh']), 'flag_pofr=' + repr(_pc.document['flag_pofr']), 'pofr_thresh=' + repr(_pc.document['pofr_thresh']), 'flag_prfrm=' + repr(_pc.document['flag_prfrm']), 'prfrm_thresh=' + repr(_pc.document['prfrm_thresh']), 'prfrm_nmean=' + repr(_pc.document['prfrm_nmean']), 'flag_pofrm=' + repr(_pc.document['flag_pofrm']), 'pofrm_thresh=' + repr(_pc.document['pofrm_thresh']), 'pofrm_nmean=' + repr(_pc.document['pofrm_nmean']), 'flag_user=' + repr(_pc.document['flag_user']), 'user_thresh=' + repr(_pc.document['user_thresh']), 'plotflag=' + repr(_pc.document['plotflag']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'infiles=' + repr(_pc.document['infiles']), 'antenna=' + repr(_pc.document['antenna']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'pol=' + repr(_pc.document['pol']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']), 'parallel=' + repr(_pc.document['parallel']) ] )
        return _end_log( _logging_state_, 'hsd_blflag', _hsd_blflag_t( _pc.document['iteration'], _pc.document['edge'], _pc.document['flag_tsys'], _pc.document['tsys_thresh'], _pc.document['flag_weath'], _pc.document['weath_thresh'], _pc.document['flag_prfre'], _pc.document['prfre_thresh'], _pc.document['flag_pofre'], _pc.document['pofre_thresh'], _pc.document['flag_prfr'], _pc.document['prfr_thresh'], _pc.document['flag_pofr'], _pc.document['pofr_thresh'], _pc.document['flag_prfrm'], _pc.document['prfrm_thresh'], _pc.document['prfrm_nmean'], _pc.document['flag_pofrm'], _pc.document['pofrm_thresh'], _pc.document['pofrm_nmean'], _pc.document['flag_user'], _pc.document['user_thresh'], _pc.document['plotflag'], _pc.document['pipelinemode'], _pc.document['infiles'], _pc.document['antenna'], _pc.document['field'], _pc.document['spw'], _pc.document['pol'], _pc.document['dryrun'], _pc.document['acceptresults'], _pc.document['parallel'] ) )

hsd_blflag = _hsd_blflag( )