Source code for pipeline.hifa.cli.hifa_session_bandpass

##################### generated by xml-casa (v2) from hifa_session_bandpass.xml #####
##################### c002de19bc4253460b98219aaeef6395 ##############################
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_session_bandpass import hifa_session_bandpass as _hifa_session_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_session_bandpass:
    """
    hifa_session_bandpass ---- Compute bandpass calibration solutions

    
    Compute amplitude and phase as a function of frequency for each spectral
    window in each MeasurementSet.
    
    Previous calibration can be applied on the fly.
    
    hifa_session_bandpass 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 precompute a prioritized list of
    reference antennas.
    
    
    Output
    
    results -- 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           The list of input MeasurementSets. Defaults to the list of
                  MeasurementSets specified in the pipeline context.
                  
                  example: vis=['M51.ms']
    caltable      The list of output calibration tables. Defaults to the standard
                  pipeline naming convention.
                  
                  example: caltable=['M51.bcal']
    field         The list of field names or field ids for which bandpasses are
                  computed. Defaults to 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. Defaults to all data
                  with bandpass intent.
                  
                  example: intent='*PHASE*'
    spw           The list of spectral windows and channels for which bandpasses are
                  computed. Defaults to all science spectral windows.
                  
                  example: spw='11,13,15,17'
    antenna       
    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), and '' (none).
                  
                  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. Defaults to 500MHz.
                  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), and 'fixed' (use
                  the user defined parameters for all spws).
    solint        Time and channel solution intervals in CASA syntax.
                  default: 'inf' Used for hm_bandpass='fixed', and as a default
                  for the 'snr' and 'smoothed' options.
                  
                  default: 'inf,7.8125MHz'
                  example: solint='inf,10ch', solint='inf'
    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: 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'.
    hm_bandtype   The type of bandpass. The options are 'channel' and
                  'polynomial' for CASA bandpass types = 'B' and 'BPOLY' respectively.
    combine       Data axes to combine for solving. Axes are '', 'scan', 'spw',
                  'field' or any comma-separated combination.
                  
                  example: combine='scan,field'
    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'
    solnorm       Normalise the bandpass solutions.
    minblperant   Minimum number of baselines required per antenna for each solve
                  Antennas with fewer baselines are excluded from solutions. Used for
                  hm_bandtype='channel' only.
    minsnr        Solutions below this SNR are rejected. Used for hm_bandtype=
                  'channel' only.
    degamp        
    degphase      
    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 Add the results of the task to the pipeline context (True) or
                  reject them (False).
    parallel      Execute using CASA HPC functionality, if available.

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

    
    1. Compute a channel bandpass for all visibility files in the pipeline
    context using the CASA reference antenna determination scheme:
    
    hifa_session_bandpass()
    
    2. Same as the above but precompute a prioritized reference antenna list:
    
    hif_refant()
    hifa_session_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), hm_bandtype='channel', combine='scan', refant='', solnorm=True, minblperant=int(4), minsnr=float(3.0), degamp='', degphase='', pipelinemode='automatic', dryrun=False, acceptresults=True, parallel='automatic' ):
        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'}, 'hm_bandtype': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'channel', 'polynomial' ]}, '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}, 'degamp': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'degphase': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}, 'parallel': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'true', 'false' ]}}
        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, 'hm_bandtype': hm_bandtype, 'combine': combine, 'refant': refant, 'solnorm': solnorm, 'minblperant': minblperant, 'minsnr': minsnr, 'degamp': degamp, 'degphase': degphase, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults, 'parallel': parallel}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hifa_session_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']), 'hm_bandtype=' + repr(_pc.document['hm_bandtype']), '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']), 'degamp=' + repr(_pc.document['degamp']), 'degphase=' + repr(_pc.document['degphase']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']), 'parallel=' + repr(_pc.document['parallel']) ] )
        return _end_log( _logging_state_, 'hifa_session_bandpass', _hifa_session_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['hm_bandtype'], _pc.document['combine'], _pc.document['refant'], _pc.document['solnorm'], _pc.document['minblperant'], _pc.document['minsnr'], _pc.document['degamp'], _pc.document['degphase'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'], _pc.document['parallel'] ) )

hifa_session_bandpass = _hifa_session_bandpass( )