casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
sdgrid.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_sdgrid
00013 def sdgrid(infiles=[""], antenna=-1, scanlist=[], ifno=-1, pollist=[], gridfunction='BOX', convsupport=-1, truncate=-1, gwidth=-1, jwidth=-1, weight='UNIFORM', clipminmax=False, outfile='', overwrite=False, npix=-1, cell='', center='', plot=False):
00014 
00015         """SD task: gridding single dish data
00016   Keyword arguments:
00017         infiles -- name of input SD dataset. can be list.
00018                 example: 'testimage.asap' 
00019                          ['testimage1.asap','testimage2.asap']
00020         antenna -- select data based on antenna name(s) or id(s)
00021                 default: -1
00022                 example: 0, 'DV01'
00023         scanlist -- list of scan numbers to process
00024                 default: [] (use all scans)
00025                 example: [21,22,23,24]
00026         ifno -- IFNO to be gridded
00027                 default: -1 (only process IFNO in the first row)
00028                 example: 1
00029         pollist -- POLNO to be gridded
00030                 default: [] (all polarizations)
00031                 example: 1,[0,1]
00032         gridfunction -- gridding function 
00033                 options: 'BOX' (Box-car), 'SF' (Spheroidal), 
00034                          'GAUSS' (Gaussian), 'PB' (Primary-beam)
00035                          'GJINC' (Gaussian*Jinc)
00036                 default: 'BOX'
00037                 example: 'SF'
00038             >>> gridfunction expandable parameter:
00039                convsupport -- convolution support for 'SF' 
00040                    default: -1 (use default for each gridfunction)
00041                    example: 3
00042                truncate -- truncattion radius of convolution kernel.
00043                            effective only for 'GAUSS' and 'GJINC'.
00044                    default: '-1' (use default for each gridfunction)
00045                    example: 3, '20arcsec', '3pixel'
00046                gwidth -- HWHM for gaussian. Effective only for 
00047                          'GAUSS' and 'GJINC'.
00048                    default: '-1' (use default for each gridfunction)
00049                    example: 3, '20arcsec', '3pixel'
00050                jwidth -- Width of jinc function. Effective only for 
00051                          'GJINC'.
00052                    default: '-1' (use default for each gridfunction)
00053                    example: 3, '20arcsec', '3pixel'
00054         weight -- weight type (both lower-case and upper-case are 
00055                   acceptable)
00056                 options: 'UNIFORM',
00057                          'TSYS'  (1/Tsys**2 weighted)
00058                          'TINT'  (integration time weighted)
00059                          'TINTSYS'  (Tint/Tsys**2)
00060                 default: 'UNIFORM'
00061         clipminmax -- do min/max cliping if True
00062                 default: False
00063         outfile -- output data name
00064                 default: '' (outfile will be set to infile+'.grid')
00065                 example: 'mydata.asap.grid'
00066         overwrite -- overwrite option for outfile
00067                 default: False (not overwrite)
00068                 options: True, False
00069                 example: if True, existing file will be overwritten
00070         npix -- x and y image size in pixels, symmetric for single value
00071                 default: -1 (automatically calculated from cell size and 
00072                              the data)
00073                 example: npix=200 (equivalent to [200,200])
00074         cell -- x and y cell size. default unit arcsec
00075                 default: '' (automatically calculated from npix if it is 
00076                              set, otherwise '1.0arcmin')
00077                 example: cell=['0.2arcmin, 0.2arcmin']
00078                          cell='0.2arcmin' (equivalent to example above)
00079                          cell=12.0 (interpreted as '12.0arcsec'='0.2arcmin')
00080         center -- grid center
00081                 default: '' (automatically calculated from the data)
00082                 example: 'J2000 13h44m00 -17d02m00'
00083                          ['05:34:48.2', '-05.22.17.7'] (in J2000 frame)
00084                          [1.46, -0.09] (interpreted as radian in J2000 frame)
00085         plot -- Plot result or not
00086                 default: False (not plot)
00087                 example: if True, result will be plotted
00088 
00089         DESCRIPTION:
00090 
00091         The sdgrid task performs spatial gridding according to the user 
00092         specification of spatial grid, convolution function, etc.
00093 
00094         For grid configuration, the task supplements necessary information 
00095         by referring input data if any of gridding parameter ('npix', 
00096         'cell', or 'center') is not specified by the user. If 'center' is 
00097         default value (empty string), central position of the grid will be 
00098         set to the center of observed area, i.e. x=0.5*(xmax+xmin), 
00099         y=0.5*(ymax+ymin). If either 'cell' or 'npix' is set, unspecified 
00100         one will be calculated from the others. In that case, total extent of 
00101         the grid will be set to cover all observed position. If neither 'cell' 
00102         nor 'npix' is set, cell size will be set to 1.0 arcmin and number of 
00103         pixel will be calculated based on that cell size.
00104  
00105         Currently, only J2000 frame is supported.
00106  
00107         The parameter gridfunction sets gridding function for imaging. 
00108         Currently, the task supports 'BOX' (Box-car), 'SF' (Prolate 
00109         Spheroidal Wave Function), 'GAUSS' (Gaussian), 'GJINC' (Gaussian*
00110         Jinc), where Jinc(x) = J_1(pi*x/c)/(pi*x/c) with a first order 
00111         Bessel function J_1, and 'PB' (Primary Beam, not implemented yet). 
00112         For 'PB', correct antenna informations should be included in input 
00113         file. 
00114         
00115         There are four subparameters for gridfunction: convsupport, truncate, 
00116         gwidth, and jwidth. The convsupport is an integer specifying cut-off 
00117         radius for 'SF' in units of pixel. By default (convsupport=-1), 
00118         the cut-off radius is set to 3 pixels. The truncate is a cut-off 
00119         radius for 'GAUSS' or 'GJINC'. It accepts integer, float, and 
00120         string values of numeric plus unit. Allowed units are angular 
00121         units such as 'deg', 'arcmin', 'arcsec', and 'pixel'. Default unit 
00122         is 'pixel' so that string without unit or numerical values (integer 
00123         or float) will be interpreted as radius in pixel. Default value 
00124         for truncate, which is used when negative radius is set, is 3*HWHM 
00125         for 'GAUSS' and radius at first null for 'GJINC'. The gwidth is 
00126         the HWHM of gaussian for 'GAUSS' and 'GJINC'. Default value is 
00127         sqrt(log(2)) pixel for 'GAUSS' and 2.52*sqrt(log(2)) pixel for 
00128         'GJINC'. The jwidth specifies width of the jinc function (parameter 
00129         'c' in the definition above). Default is 1.55 pixel. Both gwidth 
00130         jwidth allows integer, float, or string of numeric plus unit. 
00131         Default values for gwidth and jwidth are taken from Mangum et al. 
00132         (2007).
00133 
00134         Boolean parameter 'plot' controls whether gridded result is plotted 
00135         or not. If True, color map of gridded data will be shown. Pixel 
00136         center and observed position are overlayed as blue dot and red dot, 
00137         respectively. Currently, channel averaged value will be plotted.
00138   
00139         """
00140         if type(scanlist)==int: scanlist=[scanlist]
00141 
00142 #
00143 #    The following is work around to avoid a bug with current python translation
00144 #
00145         mytmp = {}
00146 
00147         mytmp['infiles'] = infiles
00148         mytmp['antenna'] = antenna
00149         mytmp['scanlist'] = scanlist
00150         mytmp['ifno'] = ifno
00151         mytmp['pollist'] = pollist
00152         mytmp['gridfunction'] = gridfunction
00153         mytmp['convsupport'] = convsupport
00154         mytmp['truncate'] = truncate
00155         mytmp['gwidth'] = gwidth
00156         mytmp['jwidth'] = jwidth
00157         mytmp['weight'] = weight
00158         mytmp['clipminmax'] = clipminmax
00159         mytmp['outfile'] = outfile
00160         mytmp['overwrite'] = overwrite
00161         mytmp['npix'] = npix
00162         mytmp['cell'] = cell
00163         mytmp['center'] = center
00164         mytmp['plot'] = plot
00165         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00166         trec = casac.utils().torecord(pathname+'sdgrid.xml')
00167 
00168         casalog.origin('sdgrid')
00169         if trec.has_key('sdgrid') and casac.utils().verify(mytmp, trec['sdgrid']) :
00170             result = task_sdgrid.sdgrid(infiles, antenna, scanlist, ifno, pollist, gridfunction, convsupport, truncate, gwidth, jwidth, weight, clipminmax, outfile, overwrite, npix, cell, center, plot)
00171 
00172         else :
00173           result = False
00174         return result