Source code for pipeline.hifv.cli.hifv_restoredata

##################### generated by xml-casa (v2) from hifv_restoredata.xml ##########
##################### 83be39e9bfd5b081745e3132dfef23c5 ##############################
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_hifv_restoredata import hifv_restoredata as _hifv_restoredata_t
from casatasks.private.task_logging import start_log as _start_log
from casatasks.private.task_logging import end_log as _end_log

class _hifv_restoredata:
    """
    hifv_restoredata ---- Restore flagged and calibration interferometry data from a pipeline run

    The hifv_restoredata restores flagged and calibrated data from archived
    ASDMs and pipeline flagging and calibration data products. Pending archive
    retrieval support hifv_restoredata assumes that the required products
    are available in the rawdata_dir in the format produced by the
    hifv_exportdata task.
    
    hifv_restoredata assumes that the following entities are available in the raw
    data directory
    
    o the ASDMs to be restored
    o for each ASDM in the input list
    o a compressed tar file of the final flagversions file, e.g.
    uid___A002_X30a93d_X43e.ms.flagversions.tar.gz
    o a text file containing the applycal instructions, e.g.
    uid___A002_X30a93d_X43e.ms.calapply.txt
    o a compressed tar file containing the caltables for the parent session,
    e.g. uid___A001_X74_X29.session_3.caltables.tar.gz
    
    hifv_restoredata performs the following operations
    
    o imports the ASDM(s))
    o removes the default MS.flagversions directory created by the filler
    o restores the final MS.flagversions directory stored by the pipeline
    o restores the final set of pipeline flags to the MS
    o restores the final calibration state of the MS
    o restores the final calibration tables for each MS
    o applies the calibration tables to each MS
    
    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 visibility data files. These may be ASDMs, tar files of ASDMs,
                  MSes, or tar files of MSes, If ASDM files are specified, they will be
                  converted  to MS format.
                  example: vis=['X227.ms', 'asdms.tar.gz']
    session       List of sessions one per visibility file.  Only can be set in pipelinemode='interactive'.
                  Example: session=['session_3']
    products_dir  Name of the data products directory to copy calibration
                  products from. The parameter is effective only when copytoraw = True
                  When copytoraw = False, calibration products in rawdata_dir will be used.
                  Only can be set in pipelinemode='interactive'.
                  example: products_dir='myproductspath'
    copytoraw     Copy calibration and flagging tables from products_dir to
                  rawdata_dir directory.
                  Only can be set in pipelinemode='interactive'.
                  Example: copytoraw=False.
    rawdata_dir   The rawdata directory.
                  Only can be set in pipelinemode='interactive'.
                  Example: rawdata_dir='myrawdatapath'
    lazy          Use the lazy filler option.  Only can be set in pipelinemode='interactive'.
    bdfflags      Set the BDF flags.  Only can be set in pipelinemode='interactive'.
    ocorr_mode    Correlation import mode
    gainmap       If True, map gainfields to a particular list of scans when
                  applying calibration tables.
    asis          List of tables to import asis.  Only can be set in pipelinemode='interactive'.
    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).  This is a pipeline task execution mode.
    acceptresults Add the results of the task to the pipeline context (True) or
                  reject them (False).  This is a pipeline task execution mode.

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

    
    Examples
    
    1. Restore the pipeline results for a single ASDM in a single session
    
    hifv_restoredata (vis=['myVLAsdm'], session=['session_1'], ocorr_mode='ca')


    """

    _info_group_ = """pipeline"""
    _info_desc_ = """Restore flagged and calibration interferometry data from a pipeline run"""

    def __call__( self, vis=[  ], session=[  ], products_dir='../products', copytoraw=True, rawdata_dir='../rawdata', lazy=False, bdfflags=False, ocorr_mode='co', gainmap=False, asis='', pipelinemode='automatic', dryrun=False, acceptresults=True ):
        schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'session': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'products_dir': {'type': 'cStr', 'coerce': _coerce.to_str}, 'copytoraw': {'type': 'cBool'}, 'rawdata_dir': {'type': 'cStr', 'coerce': _coerce.to_str}, 'lazy': {'type': 'cBool'}, 'bdfflags': {'type': 'cBool'}, 'ocorr_mode': {'type': 'cStr', 'coerce': _coerce.to_str}, 'gainmap': {'type': 'cBool'}, 'asis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
        doc = {'vis': vis, 'session': session, 'products_dir': products_dir, 'copytoraw': copytoraw, 'rawdata_dir': rawdata_dir, 'lazy': lazy, 'bdfflags': bdfflags, 'ocorr_mode': ocorr_mode, 'gainmap': gainmap, 'asis': asis, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hifv_restoredata', [ 'vis=' + repr(_pc.document['vis']), 'session=' + repr(_pc.document['session']), 'products_dir=' + repr(_pc.document['products_dir']), 'copytoraw=' + repr(_pc.document['copytoraw']), 'rawdata_dir=' + repr(_pc.document['rawdata_dir']), 'lazy=' + repr(_pc.document['lazy']), 'bdfflags=' + repr(_pc.document['bdfflags']), 'ocorr_mode=' + repr(_pc.document['ocorr_mode']), 'gainmap=' + repr(_pc.document['gainmap']), 'asis=' + repr(_pc.document['asis']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']) ] )
        return _end_log( _logging_state_, 'hifv_restoredata', _hifv_restoredata_t( _pc.document['vis'], _pc.document['session'], _pc.document['products_dir'], _pc.document['copytoraw'], _pc.document['rawdata_dir'], _pc.document['lazy'], _pc.document['bdfflags'], _pc.document['ocorr_mode'], _pc.document['gainmap'], _pc.document['asis'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hifv_restoredata = _hifv_restoredata( )