casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
accum.py
Go to the documentation of this file.
00001 #
00002 # This file was generated using xslt from its XML file
00003 #
00004 # Copyright 2009, Associated Universities Inc., Washington DC
00005 #
00006 import sys
00007 import os
00008 from  casac import *
00009 import string
00010 from taskinit import casalog
00011 #from taskmanager import tm
00012 import task_accum
00013 def accum(vis='', tablein='', incrtable='', caltable='', field=[''], calfield=[''], interp='linear', accumtime=1.0, spwmap=[-1]):
00014 
00015         """Accumulate incremental calibration solutions into a calibration table
00016 
00017        Accum will interpolate and extrapolate a temporal calibration
00018        table onto a new table that has a regularly-space time grid.
00019 
00020        The first run of accum defines the time grid and fills this
00021        table with the results from the input table.
00022 
00023        Subsequent use of accum will combine additional calibration
00024        tables onto the same grid of the initial accum table to obtain
00025        an output accum table.  See below for a concrete example.
00026 
00027 
00028      Keyword arguments:
00029 
00030      vis -- Name of input visibility file
00031              default: none.  example: vis='ngc5921.ms'
00032      tablein -- Input cumulative calibration table.
00033              default: ''  means none
00034              On first execution of accum, tablein=''
00035              and accumtime is used to generate tablein with
00036              the specified time gridding.
00037      accumtime -- The time separation when making tablein.
00038              default: 1.0  (1 second).  This time should not be
00039              less than the visibiility sampling time, but should
00040              be less than about 30% of a typical scan length.
00041      incrtable -- The calibration data to be interpolated onto the
00042              tablein file.
00043              default: ''.  Must be specified
00044      caltable -- The output cumulated calibration file.
00045              default: ''  means use tablein as the output file
00046              
00047      field -- Select field(s) from tablein to process.
00048               ['go listobs' to obtain the list id's or names]
00049             default: ''= all fields
00050             If field string is a non-negative integer, it is assumed to
00051                be a field index otherwise, it is assumed to be a field name
00052             field='0~2'; field ids 0,1,2
00053             field='0,4,5~7'; field ids 0,4,5,6,7
00054             field='3C286,3C295'; field named 3C286 and 3C295
00055             field = '3,4C*'; field id 3, all names starting with 4C
00056      calfield -- Select field(s) from incrtable to process.
00057             default: '' = all fields
00058      interp -- Interpolation type (in time[,freq]) to use for each gaintable.
00059                 When frequency interpolation is relevant (B, Df, Xf),
00060                 separate time-dependent and freq-dependent interp
00061                 types with a comma (freq _after_ the comma).                
00062                 Specifications for frequency are ignored when the
00063                 calibration table has no channel-dependence.
00064                 Time-dependent interp options ending in 'PD' enable a
00065                 "phase delay" correction per spw for non-channel-dependent
00066                 calibration types.
00067                 default: '' --> 'linear,linear' for all gaintable(s)
00068                 example: interp='nearest'   (in time, freq-dep will be
00069                                              linear, if relevant)
00070                          interp='linear,cubic'  (linear in time, cubic
00071                                                  in freq)
00072                          interp=',spline'  (spline in freq; linear in
00073                                             time by default)
00074                          interp=['nearest,spline','linear']  (for multiple gaintables)
00075                 Options: Time: 'nearest', 'linear'
00076                          Freq: 'nearest', 'linear', 'cubic', 'spline'
00077      spwmap -- Spectral windows combinations to form for gaintable(s)
00078             default: [] (apply solutions from each spw to that spw only)
00079             Example:  spwmap=[0,0,1,1] means apply the caltable solutions
00080                       from spw = 0 to the spw 0,1 and spw 1 to spw 2,3.
00081                       spwmap=[[0,0,1,1],[0,1,0,1]]  (for multiple gaintables)
00082      async -- Run task in a separate process 
00083              default: False; example: async=True
00084 
00085      Examples:
00086 
00087        Create an accum table with 10-sec sampling, filling it with the calibration
00088           in 'first_cal' with the desired interpolation.
00089 
00090            taskname = 'accum'
00091              default()
00092              vis = 'mydata.ms'
00093              tablein = ''
00094              accumtime = 10
00095              incrtable = 'first_cal'
00096              caltable = 'accum1_cal'
00097              accum()
00098 
00099        If you plot 'accum1_cal' with plotcal, you can see how the incrtable was
00100              interpolated.
00101 
00102        Continue accumulating calibrations in accum1_cal from 'second_cal'
00103 
00104            taskname = 'accum'
00105              default()
00106              vis = 'mydata.ms'
00107              tablein = 'accum1_cal'
00108              incrtable = 'second_cal'
00109              caltable = 'accum1_cal'
00110              accum()
00111 
00112        Incorporate gaincurve, opacity, parang once and for all
00113 
00114           taskname= 'gaincal'
00115              vis = 'mydata.ms'
00116              caltable = 'first_cal'
00117                etc
00118              gaincurve = T
00119              opacity = 0.11
00120              parang = T
00121              gaincal()
00122 
00123            taskname = 'accum'
00124              default()
00125              vis = 'mydata.ms'
00126              tablein = ''
00127              accumtime = 10
00128              incrtable = 'first_cal'
00129              caltable = 'accum1_cal'
00130              accum()
00131 
00132          accum1_cal with contain not only the gaincal solution, but the gaincurve,
00133              opacity and parang correction.  Hence, when applying accum1_cal
00134              on the fly for subsequent calibrations (gaincal, bandpass) or applying
00135              the calibrations, then
00136                 gaincurve=F; opacity = 0.0; parang = F  should be used
00137      
00138   
00139  
00140         """
00141         if type(field)==str: field=[field]
00142         if type(calfield)==str: calfield=[calfield]
00143         if type(spwmap)==int: spwmap=[spwmap]
00144 
00145 #
00146 #    The following is work around to avoid a bug with current python translation
00147 #
00148         mytmp = {}
00149 
00150         mytmp['vis'] = vis
00151         mytmp['tablein'] = tablein
00152         mytmp['incrtable'] = incrtable
00153         mytmp['caltable'] = caltable
00154         mytmp['field'] = field
00155         mytmp['calfield'] = calfield
00156         mytmp['interp'] = interp
00157         mytmp['accumtime'] = accumtime
00158         mytmp['spwmap'] = spwmap
00159         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00160         trec = casac.utils().torecord(pathname+'accum.xml')
00161 
00162         casalog.origin('accum')
00163         if trec.has_key('accum') and casac.utils().verify(mytmp, trec['accum']) :
00164             result = task_accum.accum(vis, tablein, incrtable, caltable, field, calfield, interp, accumtime, spwmap)
00165 
00166         else :
00167           result = False
00168         return result