Source code for pipeline.hsdn.cli.hsdn_restoredata

##################### generated by xml-casa (v2) from hsdn_restoredata.xml ##########
##################### e2dc22f8ee4111e4d2034bfb4f05475b ##############################
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_hsdn_restoredata import hsdn_restoredata as _hsdn_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 _hsdn_restoredata:
    """
    hsdn_restoredata ---- Restore flagged and calibration single dish data from a pipeline run

    
    The hsdn_restoredata task restores flagged and calibrated MeasurementSets
    from archived ASDMs and pipeline flagging and calibration date products.
    
    pipeline context defined parameter argument which can be set only in
    'interactive mode'
    
    The hsdn_restoredata task restores flagged and calibrated data from archived
    ASDMs and pipeline flagging and calibration data products. Pending archive
    retrieval support hsdn_restoredata assumes that the required products
    are available in the rawdata_dir in the format produced by the
    hifa_exportdata task.
    
    hsdn_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
    
    hsdn_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 raw visibility data files to be restored. Assumed to be
                  in the directory specified by rawdata_dir.
                  
                  example: vis=['uid___A002_X30a93d_X43e']
    reffile       Path to a file containing scaling factors between beams.
                  The format is equals to jyperk.csv with five fields:
                  MS name, beam name (instead of antenna name), spectral window id,
                  polarization string, and the scaling factor.
                  Example for the file is as follows:
                  
                  #MS,Beam,Spwid,Polarization,Factor
                  mg2-20181016165248-181017.ms,NRO-BEAM0,0,I,1.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM0,1,I,1.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM0,2,I,1.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM0,3,I,1.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM1,0,I,3.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM1,1,I,3.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM1,2,I,3.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM1,3,I,3.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM2,0,I,0.500000000
                  mg2-20181016165248-181017.ms,NRO-BEAM2,1,I,0.500000000
                  mg2-20181016165248-181017.ms,NRO-BEAM2,2,I,0.500000000
                  mg2-20181016165248-181017.ms,NRO-BEAM2,3,I,0.500000000
                  mg2-20181016165248-181017.ms,NRO-BEAM3,0,I,2.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM3,1,I,2.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM3,2,I,2.000000000
                  mg2-20181016165248-181017.ms,NRO-BEAM3,3,I,2.000000000
                  
                  If no file name is specified or specified file doesn't exist,
                  all the factors are set to 1.0.
                  
                  example: reffile='', reffile='nroscalefactor.csv'
    infiles       List of input MeasurementSets.
                  
                  example: vis='ngc5921.ms'
    caltable      Name of output gain calibration tables.
                  
                  example: caltable='ngc5921.gcal'
    products_dir  Name of the data products directory. Currently not
                  used.
                  
                  example: products_dir='myproductspath'
    copytoraw     Copy calibration and flagging tables to raw data directory.
                  
                  example: copytoraw=False
    rawdata_dir   Name of the raw data directory.
                  
                  example: rawdata_dir='myrawdatapath'
    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.
    overwrite     Overwrite existing files on import
    nocopy        Disable copying of MS to working directory
    createmms     Create an MMS
    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. Restore the pipeline results for a single ASDM in a single session
    
    hsdn_restoredata (vis=['mg2-20181016165248-190320.ms'], reffile='nroscalefactor.csv')


    """

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

    def __call__( self, vis=[  ], reffile='', infiles=[  ], caltable=[  ], products_dir='../products', copytoraw=True, rawdata_dir='../rawdata', pipelinemode='automatic', overwrite=False, nocopy=False, createmms='automatic', dryrun=False, acceptresults=True ):
        schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'reffile': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'infiles': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'caltable': {'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}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'overwrite': {'type': 'cBool'}, 'nocopy': {'type': 'cBool'}, 'createmms': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'true', 'false' ]}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
        doc = {'vis': vis, 'reffile': reffile, 'infiles': infiles, 'caltable': caltable, 'products_dir': products_dir, 'copytoraw': copytoraw, 'rawdata_dir': rawdata_dir, 'pipelinemode': pipelinemode, 'overwrite': overwrite, 'nocopy': nocopy, 'createmms': createmms, 'dryrun': dryrun, 'acceptresults': acceptresults}
        assert _pc.validate(doc,schema), str(_pc.errors)
        _logging_state_ = _start_log( 'hsdn_restoredata', [ 'vis=' + repr(_pc.document['vis']), 'reffile=' + repr(_pc.document['reffile']), 'infiles=' + repr(_pc.document['infiles']), 'caltable=' + repr(_pc.document['caltable']), 'products_dir=' + repr(_pc.document['products_dir']), 'copytoraw=' + repr(_pc.document['copytoraw']), 'rawdata_dir=' + repr(_pc.document['rawdata_dir']), 'pipelinemode=' + repr(_pc.document['pipelinemode']), 'overwrite=' + repr(_pc.document['overwrite']), 'nocopy=' + repr(_pc.document['nocopy']), 'createmms=' + repr(_pc.document['createmms']), 'dryrun=' + repr(_pc.document['dryrun']), 'acceptresults=' + repr(_pc.document['acceptresults']) ] )
        return _end_log( _logging_state_, 'hsdn_restoredata', _hsdn_restoredata_t( _pc.document['vis'], _pc.document['reffile'], _pc.document['infiles'], _pc.document['caltable'], _pc.document['products_dir'], _pc.document['copytoraw'], _pc.document['rawdata_dir'], _pc.document['pipelinemode'], _pc.document['overwrite'], _pc.document['nocopy'], _pc.document['createmms'], _pc.document['dryrun'], _pc.document['acceptresults'] ) )

hsdn_restoredata = _hsdn_restoredata( )