casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
sdimaging.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_sdimaging
00013 def sdimaging(infile='', specunit='', restfreq='', scanlist=[], field=-1, spw=0, antenna=-1, stokes='', gridfunction='BOX', convsupport=-1, truncate=-1, gwidth=-1, jwidth=-1, outfile='', overwrite=False, imsize=[256, 256], cell=['1.0arcmin', '1.0arcmin'], dochannelmap=False, nchan=1, start=0, step=1, phasecenter='', ephemsrcname='', pointingcolumn='direction'):
00014 
00015         """SD task: imaging for total power and spectral data
00016   Keyword arguments:
00017         infile -- name of input SD (MS) dataset
00018         specunit -- units for spectral axis
00019                 options: (str) 'channel','km/s','GHz','MHz','kHz','Hz'
00020                 default: 'channel'
00021                 example: this will be the units for nchan, start, and step
00022         restfreq -- rest frequency
00023                 default: '' (refer input data)
00024                 example: 1.0e11, '100GHz'
00025         scanlist -- list of scan numbers to process
00026                 default: [] (use all scans)
00027                 example: [21,22,23,24]
00028                 this selection is in addition to field and spw
00029         field -- field id or selection string for selecting scans by name
00030                 default: -1 (all fields)
00031                 example: 'FLS3a', 0
00032                 this selection is in addition to scanlist and spw
00033         spw -- spectral window id
00034                 default: 0
00035                 example: 1
00036                 this selection is in addition to scanlist and field
00037         antenna -- select data based on antenna name(s) or id(s)
00038                 default: -1 (all baselines, i.e. all antenna in case of auto data)
00039                 example: 0, 'DV01'
00040         stokes -- select data based on stokes or polarization type 
00041                 default: '' (use all polarizations)
00042                 example: 'XX'
00043         gridfunction -- gridding function for imaging
00044                 options: 'BOX' (Box-car), 'SF' (Spheroidal), 
00045                          'PB' (Primary-beam), 'GAUSS' (Gaussian),
00046                          'GJINC' (Gaussian*Jinc)
00047                 default: 'BOX'
00048                 example: 'SF'
00049             >>> gridfunction expandable parameter:
00050                convsupport -- convolution support for 'SF' 
00051                    default: -1 (use default for each gridfunction)
00052                    example: 3
00053                truncate -- truncattion radius of convolution kernel.
00054                            effective only for 'GAUSS' and 'GJINC'.
00055                    default: '-1' (use default for each gridfunction)
00056                    example: 3, '20arcsec', '3pixel'
00057                gwidth -- HWHM for gaussian. Effective only for 
00058                          'GAUSS' and 'GJINC'.
00059                    default: '-1' (use default for each gridfunction)
00060                    example: 3, '20arcsec', '3pixel'
00061                jwidth -- Width of jinc function. Effective only for 
00062                          'GJINC'.
00063                    default: '-1' (use default for each gridfunction)
00064                    example: 3, '20arcsec', '3pixel'
00065         outfile -- output image name
00066                 default: none
00067                 example: 'mySDimage.im'
00068         overwrite -- overwrite option for outfile
00069                 default: False (not overwrite)
00070                 options: True, False
00071                 example: if True, existing file will be overwritten
00072         imsize -- x and y image size in pixels, symmetric for single value
00073                 default: [256,256]
00074                 example: imsize=200 (equivalent to [200,200])
00075         cell -- x and y cell size. default unit arcmin
00076                 default: ['1.0arcmin', '1.0arcmin']
00077                 example: cell=['0.2arcmin, 0.2arcmin']
00078                          cell='0.2arcmin' (equivalent to example above)
00079         dochannelmap -- channel map image or total power image
00080                 default: False (total power)
00081                 options: True (channel map), False
00082             >>> dochannelmap=True expandable parameters
00083                nchan -- number of spectral channel for created image
00084                    default: 1 
00085                    example: 100
00086                start -- reference value of start channel (in units of specunit)
00087                    default: 0 (0th channel if specunit='channel')
00088                    example: 100
00089                step -- width of each spectral channel for created image
00090                    default: 1 (width of 1 channel if specunit='channel')
00091                    example: 100
00092         phasecenter -- image phase center: direction measure or fieldid 
00093                 default: 0
00094                 example: 'J2000 13h44m00 -17d02m00', 'AZEL -123d48m29 15d41m41'
00095         ephemsrcname -- ephemeris source name for moving source
00096                 default: ''
00097                 if the source name in the data matches one of the known 
00098                 solar objects by the system, this task automatically set 
00099                 the source name. 
00100                 example: 'moon' 
00101         pointingcolumn -- pointing data column to use
00102                 option: 'direction', 'target', 'pointing_offset', 'source_offset', 'encoder' 
00103                 default: 'direction'
00104 
00105 
00106         DESCRIPTION:
00107 
00108         Task sdimaging create image from input single-dish data.
00109         The input can be either total power and spectral data. Currently,
00110         this task directly accesses the Measurement Set data only because of 
00111         the data access efficiency. So it differs from other single-dish 
00112         tasks that mostly operate on the ASAP scantable data format.
00113  
00114         Units of spectral axis can be specified via a parameter specunit.
00115         Allowed values for specunit are 'channel', 'GHz', 'MHz', 'kHz', 'Hz', 
00116         and 'km/s'. This parameter is also used as the units of the parameter 
00117         start and step that specify reference value of start channel and 
00118         width of each spectral channel for channel map, respectively. 
00119         The parameter nchan specifies number of channels for created image. 
00120         If you set nchan as -1, the task selects existing all channels and 
00121         combine those data into one channel to create continuum image.
00122 
00123         You can specify field id or name directly. By default, field is set 
00124         to -1 that means the task selects all fields in the data.
00125 
00126         Selection of the antennas can be made by setting antennaid(s) or 
00127         antenna name(s) in string (e.g. '0', 'DV01',etc.) or integer 
00128         (e.g. 0). Defalut value, -1, means that the task selects data from 
00129         all baseline, i.e., data from all antenna when data only contains 
00130         auto-correlation.
00131 
00132         The parameter gridfunction sets gridding function for imaging. 
00133         Currently, the task supports 'BOX' (Box-car), 'SF' (Prolate 
00134         Spheroidal Wave Function), 'GAUSS' (Gaussian), 'GJINC' (Gaussian*
00135         Jinc), where Jinc(x) = J_1(pi*x/c)/(pi*x/c) with a first order 
00136         Bessel function J_1, and 'PB' (Primary Beam). For 'PB', correct 
00137         antenna informations should be included in input file. 
00138 
00139         There are four subparameters for gridfunction: convsupport, truncate, 
00140         gwidth, and jwidth. The convsupport is an integer specifying cut-off 
00141         radius for 'SF' in units of pixel. By default (convsupport=-1), 
00142         the cut-off radius is set to 3 pixels. The truncate is a cut-off 
00143         radius for 'GAUSS' or 'GJINC'. It accepts integer, float, and 
00144         string values of numeric plus unit. Allowed units are angular 
00145         units such as 'deg', 'arcmin', 'arcsec', and 'pixel'. Default unit 
00146         is 'pixel' so that string without unit or numerical values (integer 
00147         or float) will be interpreted as radius in pixel. Default value 
00148         for truncate, which is used when negative radius is set, is 3*HWHM 
00149         for 'GAUSS' and radius at first null for 'GJINC'. The gwidth is 
00150         the HWHM of gaussian for 'GAUSS' and 'GJINC'. Default value is 
00151         sqrt(log(2)) pixel for 'GAUSS' and 2.52*sqrt(log(2)) pixel for 
00152         'GJINC'. The jwidth specifies width of the jinc function (parameter 
00153         'c' in the definition above). Default is 1.55 pixel. Both gwidth 
00154         jwidth allows integer, float, or string of numeric plus unit. 
00155         Default values for gwidth and jwidth are taken from Mangum et al. 
00156         (2007).
00157   
00158         """
00159         if type(scanlist)==int: scanlist=[scanlist]
00160         if type(imsize)==int: imsize=[imsize]
00161         if type(cell)==float: cell=[cell]
00162 
00163 #
00164 #    The following is work around to avoid a bug with current python translation
00165 #
00166         mytmp = {}
00167 
00168         mytmp['infile'] = infile
00169         mytmp['specunit'] = specunit
00170         mytmp['restfreq'] = restfreq
00171         mytmp['scanlist'] = scanlist
00172         mytmp['field'] = field
00173         mytmp['spw'] = spw
00174         mytmp['antenna'] = antenna
00175         mytmp['stokes'] = stokes
00176         mytmp['gridfunction'] = gridfunction
00177         mytmp['convsupport'] = convsupport
00178         mytmp['truncate'] = truncate
00179         mytmp['gwidth'] = gwidth
00180         mytmp['jwidth'] = jwidth
00181         mytmp['outfile'] = outfile
00182         mytmp['overwrite'] = overwrite
00183         mytmp['imsize'] = imsize
00184         if type(cell) == str :
00185            mytmp['cell'] = casac.quanta().quantity(cell)
00186         else :
00187            mytmp['cell'] = cell
00188         mytmp['dochannelmap'] = dochannelmap
00189         mytmp['nchan'] = nchan
00190         mytmp['start'] = start
00191         mytmp['step'] = step
00192         mytmp['phasecenter'] = phasecenter
00193         mytmp['ephemsrcname'] = ephemsrcname
00194         mytmp['pointingcolumn'] = pointingcolumn
00195         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00196         trec = casac.utils().torecord(pathname+'sdimaging.xml')
00197 
00198         casalog.origin('sdimaging')
00199         if trec.has_key('sdimaging') and casac.utils().verify(mytmp, trec['sdimaging']) :
00200             result = task_sdimaging.sdimaging(infile, specunit, restfreq, scanlist, field, spw, antenna, stokes, gridfunction, convsupport, truncate, gwidth, jwidth, outfile, overwrite, imsize, cell, dochannelmap, nchan, start, step, phasecenter, ephemsrcname, pointingcolumn)
00201 
00202         else :
00203           result = False
00204         return result