Source code for pipeline.hifa.cli.hifa_restoredata

##################### generated by xml-casa (v2) from hifa_restoredata.xml ##########
##################### 24d7955034f8e5deb55a68112c485156 ##############################
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_restoredata import hifa_restoredata as _hifa_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 _hifa_restoredata:
    """
    hifa_restoredata ---- Restore flagged and calibration interferometry data from a pipeline run

    
    The hifa_restoredata task restores flagged and calibrated MeasurementSets
    from archived ASDMs and pipeline flagging and calibration date products.
    
    Output
    
    results -- If pipeline mode is 'getinputs' then None is returned. Otherwise
    the results object for the pipeline task is returned.
    
    
    Description
    
    The hifa_restoredata restores flagged and calibrated data from archived
    ASDMs and pipeline flagging and calibration data products. Pending archive
    retrieval support hifa_restoredata assumes that the required products
    are available in the rawdata_dir in the format produced by the
    hifa_exportdata task.
    
    hifa_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
    
    hifa_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
    
    
    Issues

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

    vis           List of raw visibility data files to be restored. 
                  Assumed to be in the directory specified by rawdata_dir.
                  (can be set only in 'interactive mode')
                  example: vis=['uid___A002_X30a93d_X43e']
    session       List of sessions one per visibility file. 
                  (can be set only in 'interactive mode')
                  
                  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.
                  (can be set only in 'interactive mode')
                  
                  example: products_dir='myproductspath'
    copytoraw     Copy calibration and flagging tables from products_dir to
                  rawdata_dir directory.
                  (can be set only in 'interactive mode')
                  
                  example: copytoraw=False
    rawdata_dir   Name of the rawdata subdirectory. 
                  (can be set only in 'interactive mode')
                  
                  example: rawdata_dir='myrawdatapath'
    lazy          Use the lazy filler option.
                  (can be set only in 'interactive mode')
                  
                  example: lazy=True
    bdfflags      Set the BDF flags.
                  (can be set only in 'interactive mode')
                  
                  example: bdfflags=False
    ocorr_mode    Set ocorr_mode.
                  (can be set only in 'interactive mode')
                  
                  example: ocorr_mode='ca'
    asis          Set list of tables to import as is.
                  (can be set only in 'interactive mode')
                  
                  example: asis='Source Receiver'
    pipelinemode  The pipeline operating mode. In 'automatic' mode 
                  the pipeline determines the values of all context 
                  defined pipeline inputs automatically.
                  (can be set in any pipeline mode)
    dryrun        Run the commands (False) or generate the commands to be
                  run but do not execute (True).
    acceptresults Add the results of the task to the pipeline context (True)
                  or reject them (False).

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

    
    1. Restore the pipeline results for a single ASDM in a single session:
    
    hifa_restoredata(vis=['uid___A002_X30a93d_X43e'], 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=True, ocorr_mode='ca', asis='SBSummary ExecBlock Antenna Station Receiver Source CalAtmosphere CalWVR CalPointing', 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}, '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, 'asis': asis, 'pipelinemode': pipelinemode, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hifa_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']), '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_, 'hifa_restoredata', _hifa_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['asis'], _pc.document['pipelinemode'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hifa_restoredata = _hifa_restoredata( )