casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
sdtpimaging.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_sdtpimaging
00013 def sdtpimaging(infile='', calmode='none', masklist=[], blpoly=1, backup=True, flaglist=[], antenna='', spw=0, stokes='', createimage=False, outfile='', imsize=[256, 256], cell=['1.0arcmin', '1.0arcmin'], phasecenter='', ephemsrcname='', pointingcolumn='direction', gridfunction='BOX', plotlevel=0):
00014 
00015         """SD task: do a simple calibration and imaging for total power data 
00016   Keyword arguments:
00017         infile -- name of input SD (MS) dataset
00018         calmode -- calibration mode (currently only baseline subtraction)
00019                 options: 'baseline','none'
00020                 default: 'none'
00021                 example: choose mode 'none' if you have
00022                          already calibrated and want to do
00023                          plotting nd/or imaging 
00024             >>> calmode='baseline' expandable parameters
00025                masklist -- mask in numbers of rows from each edge of each scan 
00026                            to be included for baseline fitting
00027                  default: none
00028                  example: [30,30] or [30] 
00029                           used first 30 rows and last 30 rows of each scan for 
00030                           the baseline 
00031                blpoly -- polynomial order for the baseline fit
00032                  default: 1
00033                backup -- set True to create backup for input data
00034                  default: True
00035         flaglist -- list of scan numbers to flag (ranges can be accepted)  
00036                 default: [] (use all scans)
00037                 example: [[0,3],80]
00038                          flag the scan range [0,3] = [0,1,2,3] and scan 80 
00039         antenna -- select data based on antenna name(s) or id(s) in string
00040                 default: '' (use all antennas)
00041                 example: '0,1', 'DV01'
00042                 WARNING: currently baseline subtraction properly 
00043                          only one of the antennas.
00044         spw -- spectral window id
00045                 default: 0
00046                 example: 1
00047         stokes -- select data based on stokes or polarization type 
00048                 default: '' (use all polarizations)
00049                 example: 'XX'
00050         createimage -- do imaging? 
00051                 default: False 
00052             >>> createimage=True expandable parameters
00053                outfile -- output image name
00054                  default: none
00055                  example: 'mySDimage.im'
00056                imsize -- x and y image size in pixels, symmetric for single 
00057                          value
00058                  default: [256,256]
00059                  example: imsize=200 (equivalent to [200,200])
00060                cell -- x and y cell size. default unit arcmin
00061                  default: '1.0arcmin'
00062                  example: cell=['0.2arcmin, 0.2arcmin']
00063                           cell='0.2arcmin' (equivalent to example above)
00064                phasecenter -- image phase center: direction measure or fieldid 
00065                  default: 0
00066                  example: 'J2000 13h44m00 -17d02m00', 'AZEL -123d48m29 15d41m41'
00067                ephemsrcname -- ephemeris source name to proper shifting to 
00068                                center on the moving source for imaging
00069                  default: ''
00070                           if the source name in the data matches one of the 
00071                           known solar objects by the system, this task 
00072                           automatically set the source name. 
00073                  example: 'moon' 
00074                pointingcolumn -- pointing data column to use
00075                  option: 'direction', 'target', 'pointing_offset', 
00076                          'source_offset', 'encoder' 
00077                  default: 'direction'
00078                gridfunction -- gridding function for imaging
00079                  options: 'BOX' (Box-car), 'SF' (Spheroidal), 
00080                           'PB' (Primary-beam), 'GAUSS' (Gaussian),
00081                           'GJINC' (Gaussian*Jinc)
00082                  default: 'BOX'
00083                  example: 'SF'
00084         plotlevel -- control for plotting of results
00085                 options: (int) 0=none, 1=some, 2=more, <0=hardcopy
00086                 default: 0 (no plotting)
00087                 example: plotlevel<0 as abs(plotlevel), e.g.
00088                          -1: hardcopy plot 
00089                              (will be named <infile>_scans.eps)
00090                           1: plot raw data, calibrated data 
00091                              (for calmode='baseline)
00092                              plot raw or if exist calibrated data 
00093                              (for calmode='none')
00094                           2: plot raw data, progressively display baseline 
00095                              fitting for each scan, and final calibrated data 
00096                              (for calmode='baseline')  
00097 
00098 
00099         DESCRIPTION:
00100 
00101         Task sdtpimaging performs data selection, calibration, and imaging for 
00102         single-dish totalpower raster scan data.  This is a still experimental 
00103         task made to work mostly for the data taken at the ALMA Testing 
00104         Facility (ATF) or OSF. Currently, this task directly accesses the 
00105         Measurement Set data only because of the data access efficiency. So it 
00106         differs from other single-dish tasks that mostly operate on the ASAP 
00107         scantable data format.  By setting calmode='none', one can run 
00108         sdtpimaging to plot the data (raw or calibrated, if exists) and 
00109         further imaging by setting createimage=True. 
00110         
00111         The calibration available at this moment is just a simple baseline 
00112         subtraction for each scan. The fitted regions set by masklist are the 
00113         common for all the scans. Selection of the antennas can be made by 
00114         setting antennaid(s) or antenna name(s) in string (e.g. '0', '0,1', 
00115         'DV01',etc.). 
00116 
00117         For baseline subtraction, it currently works properly for a single 
00118         antenna selection. So a separate sdtpimaging task needs to be ran for 
00119         each antenna. It currently assumes that the data has a single spw(=0) 
00120         and fieldid(=0). By setting flaglist, one can set flag by scan numbers 
00121         to be excluded from imaging. (Note: 'scan numbers' are determined from 
00122         state id and related to SUB_SCAN column in STATE subtable and not to 
00123         SCAN_NUMBER in MS.) By default, baseline subtraction stage overwrites 
00124         (FLOAT_)DATA column of input data. You can keep original data by 
00125         setting backup parameter to True. In this case, the task make a copy 
00126         of input data specified by infile parameter. Name of backup file is 
00127         <infile>.sdtpimaging.bak.<timestamp>.  
00128 
00129         The selection of polarizations can be made by specifying the 
00130         polarization name in stokes, such as 'XX' or 'YY' for linear 
00131         polarizations. For example, with createimage=True, stokes='XXYY' will 
00132         produces an image cube with each plane contains the image of one of
00133         the polarizations while stokes='' or stokes='I' will produces a 'total 
00134         intensity' or Stokes I image. 
00135 
00136         Among the imaging sub-parameters, ephemsrcname is used to set the name 
00137         of a moving source such as planets to produce a stationary image (can 
00138         be omitted), and pointingcolumn is used to specify which pointing data 
00139         column to use for imaging. Convolution kernel for imaging can be 
00140         specified by using gridfunction. Available options are 'Box' (Box-car),
00141         'SF' (Spheroidal), 'PB' (Primary-beam), 'GAUSS' (Gaussian), and 
00142         'GJINC' (Gaussian*Jinc), where Jinc(x) = J_1(pi*x/c)/(pi*x/c) with a 
00143         first order Bessel function J_1. Sub-parameters for convolution 
00144         functions cannot be specified in this task. To costomize your 
00145         convolution function, please do imaging using sdimaging task or 
00146         imager tool.
00147   
00148         """
00149         if type(masklist)==int: masklist=[masklist]
00150         if type(flaglist)==int: flaglist=[flaglist]
00151         if type(imsize)==int: imsize=[imsize]
00152         if type(cell)==float: cell=[cell]
00153 
00154 #
00155 #    The following is work around to avoid a bug with current python translation
00156 #
00157         mytmp = {}
00158 
00159         mytmp['infile'] = infile
00160         mytmp['calmode'] = calmode
00161         mytmp['masklist'] = masklist
00162         mytmp['blpoly'] = blpoly
00163         mytmp['backup'] = backup
00164         mytmp['flaglist'] = flaglist
00165         mytmp['antenna'] = antenna
00166         mytmp['spw'] = spw
00167         mytmp['stokes'] = stokes
00168         mytmp['createimage'] = createimage
00169         mytmp['outfile'] = outfile
00170         mytmp['imsize'] = imsize
00171         if type(cell) == str :
00172            mytmp['cell'] = casac.quanta().quantity(cell)
00173         else :
00174            mytmp['cell'] = cell
00175         mytmp['phasecenter'] = phasecenter
00176         mytmp['ephemsrcname'] = ephemsrcname
00177         mytmp['pointingcolumn'] = pointingcolumn
00178         mytmp['gridfunction'] = gridfunction
00179         mytmp['plotlevel'] = plotlevel
00180         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00181         trec = casac.utils().torecord(pathname+'sdtpimaging.xml')
00182 
00183         casalog.origin('sdtpimaging')
00184         if trec.has_key('sdtpimaging') and casac.utils().verify(mytmp, trec['sdtpimaging']) :
00185             result = task_sdtpimaging.sdtpimaging(infile, calmode, masklist, blpoly, backup, flaglist, antenna, spw, stokes, createimage, outfile, imsize, cell, phasecenter, ephemsrcname, pointingcolumn, gridfunction, plotlevel)
00186 
00187         else :
00188           result = False
00189         return result