casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
cvel.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_cvel
00013 def cvel(vis='', outputvis='', passall=False, field='', spw='', selectdata=True, antenna='', timerange='', scan='', array='', mode='channel', nchan=-1, start=0, width=1, interpolation='linear', phasecenter='', restfreq='', outframe='', veltype='radio', hanning=False):
00014 
00015         """regrid an MS to a new spectral window / channel structure or frame
00016 
00017        vis -- Name of input visibility file
00018                default: none; example: vis='ngc5921.ms'    
00019 
00020        outputvis -- Name of output measurement set (required)
00021                default: none; example: vis='ngc5921-regridded.ms'    
00022                
00023        passall --  if False, data not meeting the selection is omitted/deleted 
00024                or flagged (if in-row); if True, data not meeting the selection 
00025                on field and spw is passed through without modification
00026                default: False; example: 
00027                field='NGC5921'
00028                passall=False : only data from NGC5921 is included in output MS, 
00029                          no data from other fields (e.g. 1331+305) is included
00030                passall=True : data from NGC5921 is transformed by cvel, all other 
00031                          fields are passed through unchanged 
00032 
00033        field -- Select fields in mosaic.  Use field id(s) or field name(s).
00034                   ['go listobs' to obtain the list id's or names]
00035               default: ''= all fields
00036               If field string is a non-negative integer, it is assumed to
00037                   be a field index otherwise, it is assumed to be a 
00038                   field name
00039               field='0~2'; field ids 0,1,2
00040               field='0,4,5~7'; field ids 0,4,5,6,7
00041               field='3C286,3C295'; field named 3C286 and 3C295
00042               field = '3,4C*'; field id 3, all names starting with 4C
00043 
00044        spw --Select spectral window/channels
00045               NOTE: This selects the data passed as the INPUT to mode
00046               default: ''=all spectral windows and channels
00047                 spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
00048                 spw='0:5~61'; spw 0, channels 5 to 61
00049                 spw='<2';   spectral windows less than 2 (i.e. 0,1)
00050                 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, 
00051                                    channels 3 to 45.
00052                 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each.
00053                 spw='0:0~10;15~60'; spectral window 0 with channels 
00054                                     0-10,15-60
00055                 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10,
00056                       spw 1, channels 20-30, and spw 2, channels, 1,2 and 3
00057 
00058        selectdata -- Other data selection parameters
00059               default: True
00060 
00061   >>> selectdata=True expandable parameters
00062 
00063               antenna -- Select data based on antenna/baseline
00064                   default: '' (all)
00065                   If antenna string is a non-negative integer, it is 
00066                     assumed to be an antenna index, otherwise, it is
00067                     considered an antenna name.
00068                   antenna='5&6'; baseline between antenna index 5 and 
00069                                  index 6.
00070                   antenna='VA05&VA06'; baseline between VLA antenna 5 
00071                                        and 6.
00072                   antenna='5&6;7&8'; baselines 5-6 and 7-8
00073                   antenna='5'; all baselines with antenna index 5
00074                   antenna='05'; all baselines with antenna number 05 
00075                                 (VLA old name)
00076                   antenna='5,6,9'; all baselines with antennas 5,6,9 
00077                                    index numbers
00078 
00079               timerange  -- Select data based on time range:
00080                  default = '' (all); examples,
00081                   timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
00082                   Note: if YYYY/MM/DD is missing date defaults to first 
00083                         day in data set
00084                   timerange='09:14:0~09:54:0' picks 40 min on first day
00085                   timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 
00086                              30min on NEXT day
00087                   timerange='09:44:00' pick data within one integration 
00088                              of time
00089                   timerange='>10:24:00' data after this time
00090 
00091               scan -- Scan number range.
00092                   default: '' (all)
00093                   example: scan='1~5'
00094                   Check 'go listobs' to insure the scan numbers are in 
00095                         order.
00096 
00097               array -- Select data by (sub)array indices
00098                   default: '' (all); example:
00099                   array='0~2'; arrays 0 to 2 
00100 
00101       mode -- Frequency Specification:
00102                NOTE: See examples below:
00103                default: 'channel'
00104                  mode = 'channel'; Use with nchan, start, width to specify
00105                          output spw. Produces equidistant grid based on first
00106                          selected channel. See examples below.
00107                  mode = 'velocity', means channels are specified in 
00108                       velocity.
00109                  mode = 'frequency', means channels are specified in 
00110                       frequency.
00111                  mode = 'channel_b', alternative 'channel' mode.
00112                          Does not force an equidistant grid. Faster.
00113 
00114   >>> mode expandable parameters 
00115                Start, width are given in units of channels, frequency 
00116                   or velocity as indicated by mode 
00117                nchan -- Number of channels in output spw
00118                  default: -1 = all channels; example: nchan=3
00119                start -- Start or end input channel (zero-based) depending on the sign of the width parameter
00120                  default=0; example: start=5
00121                width -- Output channel width in units of the input
00122                      channel width (sign indicates whether the start parameter is lower(+) or upper(-) end of the range)
00123                  default=1; example: width=4
00124                interpolation -- Interpolation method (linear, nearest, cubic, spline, fftshift)
00125                  default = 'linear'
00126            examples:
00127                spw = '0,1'; mode = 'channel'
00128                   will produce a single spw containing all channels in spw 
00129                        0 and 1
00130                spw='0:5~28^2'; mode = 'channel'
00131                   will produce a single spw made with channels 
00132                        (5,7,9,...,25,27)
00133                spw = '0'; mode = 'channel': nchan=3; start=5; width=4
00134                   will produce an spw with 3 output channels
00135                   new channel 1 contains data from channels (5+6+7+8)
00136                   new channel 2 contains data from channels (9+10+11+12)
00137                   new channel 3 contains data from channels (13+14+15+16)
00138                spw = '0:0~63^3'; mode='channel'; nchan=21; start = 0; 
00139                    width = 1
00140                   will produce an spw with 21 channels
00141                   new channel 1 contains data from channel 0
00142                   new channel 2 contains data from channel 2
00143                   new channel 21 contains data from channel 61
00144                spw = '0:0~40^2'; mode = 'channel'; nchan = 3; start = 
00145                    5; width = 4
00146                   will produce an spw with three output channels
00147                   new channel 1 contains channels (5,7)
00148                   new channel 2 contains channels (13,15)
00149                   new channel 3 contains channels (21,23)
00150 
00151       phasecenter -- direction measure  or fieldid for the mosaic center
00152                default: '' => first field selected ; example: phasecenter=6
00153                or phasecenter='J2000 19h30m00 -40d00m00'
00154 
00155       restfreq -- Specify rest frequency to use for output image
00156                default='' Occasionally it is necessary to set this (for
00157                example some VLA spectral line data).  For example for
00158                NH_3 (1,1) put restfreq='23.694496GHz'
00159 
00160       outframe -- output reference frame
00161                default='' (keep original reference frame) ; example: outframe='bary'     
00162 
00163       veltype -- definition of velocity (in mode)
00164                default = 'radio'
00165 
00166       hanning -- if true, Hanning smooth frequency channel data to remove Gibbs ringing
00167 
00168 ==================================================================
00169 
00170 The intent of cvel is to transform channel labels and the 
00171 visibilities to a spectral reference frame which is appropriate
00172 for the science analysis, e.g. from TOPO to LSRK to correct for 
00173 Doppler shifts throughout the time of the observation. Naturally, 
00174 this will change the shape of the spectral feature to some extent. 
00175 According to the Nyquist theorem you should oversample a spectrum 
00176 with twice the numbers of channels to retain the shape. Based on 
00177 some tests, however, we recommend to observe with at least 
00178 3-4 times the number of channels for each significant spectral 
00179 feature (like 3-4 times the linewidth). This will minimize 
00180 regridding artifacts in cvel.
00181 
00182 If cvel has already established the grid that is desired for the
00183 imaging, clean should be run with exactly the same frequency/velocity 
00184 parameters as used in cvel in order to avoid additional regridding in 
00185 clean.
00186 
00187 Hanning smoothing is optionally offered in cvel, but tests have 
00188 shown that already the regridding process itself, if it involved 
00189 a transformation from TOPO to a non-terrestrial reference frame, 
00190 implies some smoothing (due to channel interpolation) such that 
00191 Hanning smoothing may not be necessary.
00192 
00193         """
00194 
00195 #
00196 #    The following is work around to avoid a bug with current python translation
00197 #
00198         mytmp = {}
00199 
00200         mytmp['vis'] = vis
00201         mytmp['outputvis'] = outputvis
00202         mytmp['passall'] = passall
00203         mytmp['field'] = field
00204         mytmp['spw'] = spw
00205         mytmp['selectdata'] = selectdata
00206         mytmp['antenna'] = antenna
00207         mytmp['timerange'] = timerange
00208         mytmp['scan'] = scan
00209         mytmp['array'] = array
00210         mytmp['mode'] = mode
00211         mytmp['nchan'] = nchan
00212         mytmp['start'] = start
00213         mytmp['width'] = width
00214         mytmp['interpolation'] = interpolation
00215         mytmp['phasecenter'] = phasecenter
00216         mytmp['restfreq'] = restfreq
00217         mytmp['outframe'] = outframe
00218         mytmp['veltype'] = veltype
00219         mytmp['hanning'] = hanning
00220         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00221         trec = casac.utils().torecord(pathname+'cvel.xml')
00222 
00223         casalog.origin('cvel')
00224         if trec.has_key('cvel') and casac.utils().verify(mytmp, trec['cvel']) :
00225             result = task_cvel.cvel(vis, outputvis, passall, field, spw, selectdata, antenna, timerange, scan, array, mode, nchan, start, width, interpolation, phasecenter, restfreq, outframe, veltype, hanning)
00226 
00227         else :
00228           result = False
00229         return result