casa
$Rev:20696$
|
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_mosaic 00013 def mosaic(vis='', imagename='', mode='mfs', alg='clark', imsize=[256, 256], cell=['1.0arcsec', '1.0arcsec'], phasecenter='', stokes='I', niter=500, gain=0.1, threshold=0.0, mask=[''], cleanbox=[], nchan=1, start=0, width=1, field='', spw='', timerange='', restfreq='', sdimage='', modelimage='', weighting='natural', mosweight=False, rmode='norm', robust=0.0, ftmachine='mosaic', cyclefactor=1.5, cyclespeedup=-1, scaletype='SAULT', minpb=0.1, sigma='0.001Jy', targetflux='1.0Jy', constrainflux=False, prior=[''], negcomponent=2, scales=[0, 3, 10], npercycle=100, npixels=0, noise='0.0Jy'): 00014 00015 """Create a multi-field deconvolved image with selected algorithm 00016 00017 00018 Two types of point-source deconvolution, as well as multi-scale 00019 deconvolution, are available. A continuum image (mfs) is produced 00020 by gridding together all spectral data. Individual channels or 00021 groups of channels can also be images and then placed in an output 00022 image cube. 00023 00024 The cleaning regions can be specified by an input mask image, from a 00025 file containing rectangular regions, or interactively as the 00026 deconvolution progresses. 00027 00028 The mosaic task only uses the "corrected" datacolumn which is made 00029 from the "data" data column using applycal with the appropriate 00030 calibration tables. Many Stokes combinations are available. 00031 00032 00033 Keyword arguments: 00034 vis -- Name of input visibility file 00035 default: none; example: vis='ngc5921.ms' 00036 imagename -- Pre-name of output images: 00037 default: none; example: imagename='m2' 00038 output images are: 00039 m2.image; cleaned and restored image 00040 m2.flux; relative sky sensitivity over field 00041 m2.model; image of clean components 00042 m2.residual; image of residuals 00043 m2.interactive.mask; image containing clean regions 00044 mode -- Frequency Specification: 00045 NOTE: See examples below: 00046 default: 'mfs' 00047 mode = 'mfs' means produce one image from all specified data. 00048 mode = 'channel'; Use with nchan, start, width to specify 00049 output image cube. See examples below 00050 mode = 'velocity', means channels are specified in velocity. 00051 mode = 'frequency', means channels are specified in frequency. 00052 >>> mode expandable parameters (for modes other than 'mfs') 00053 Start, width are given in units of channels, frequency or velocity 00054 as indicated by mode, but only channel is complete. 00055 nchan -- Number of channels (planes) in output image 00056 default: 1; example: nchan=3 00057 start -- Start input channel (relative-0) 00058 default=0; example: start=5 00059 width -- Output channel width (>1 indicates channel averaging) 00060 default=1; example: width=4 00061 examples: 00062 spw = '0,1'; mode = 'mfs' 00063 will produce one image made from all channels in spw 0 and 1 00064 spw='0:5~28^2'; mode = 'mfs' 00065 will produce one image made with channels (5,7,9,...,25,27) 00066 spw = '0'; mode = 'channel': nchan=3; start=5; width=4 00067 will produce an image with 3 output planes 00068 plane 1 contains data from channels (5+6+7+8) 00069 plane 2 contains data from channels (9+10+11+12) 00070 plane 3 contains data from channels (13+14+15+16) 00071 spw = '0:0~63^3'; mode=chann; nchan=21; start = 0; width = 1 00072 will produce an image with 20 output planes 00073 Plane 1 contains data from channel 0 00074 Plane 2 contains date from channel 2 00075 Plane 21 contains data from channel 61 00076 spw = '0:0~40^2'; mode = 'channel'; nchan = 3; start = 5; width = 4 00077 will produce an image with three output planes 00078 plane 1 contains channels (5,7) 00079 plane 2 contains channels (13,15) 00080 plane 3 contains channels (21,23) 00081 alg -- Algorithm to use (expandable): 00082 default: 'clark': Options: 'clark','hogbom','multiscale','entropy' 00083 'hogbom' Cleans from the images only. Only inner quarter 00084 of image is cleaned 00085 'clark' Cleans from gridded us data. Only inner quarter of 00086 image is cleaned 00087 'multiscale' cleans with several resolutions using hobgom clean 00088 Currently much slower than single resolution. For extended 00089 sources, try single resolution with interactive and 00090 'entropy' Maximum entropy algorithm is still experimental 00091 and not recommended for general use 00092 >>> multiscale expandable parameter 00093 scales -- in pixel numbers; the size of component to deconvolve 00094 default = [0,3,10] 00095 recommended sizes are 0 (point), 3 (points per clean beam), and 00096 10 (about a factor of three lower resolution) 00097 negcomponent' -- Stop component search when the largest 00098 scale has found this number of negative components; -1 means 00099 continue component search even if the largest component is 00100 negative. 00101 default: 2; example: negcomponent=-1 00102 >>> entropy (MEM) expandable parameters (experimental) 00103 sigma -- Target image sigma 00104 default: '0.001Jy'; example: sigma='0.1Jy' 00105 targetflux -- Target flux for final image 00106 default: '1.0Jy'; example: targetflux='200Jy' 00107 constrainflux -- Constrain image to match target flux; 00108 otherwise, targetflux is used to initialize model only. 00109 default: False; example: constrainflux=True 00110 prior -- Name of MEM prior images 00111 default: ['']; example: prior='source_mem.image' 00112 imsize -- Image pixel size (x,y) 00113 default = [256,256]; example: imsize=[350,350] 00114 imsize = 500 is equivalent to [500,500] 00115 cell -- Cell size (x,y) 00116 default= none; 00117 example: cell=['0.5arcsec,'0.5arcsec'] or 00118 cell=['1arcmin', '1arcmin'] 00119 cell = '1arcsec' is equivalent to ['1arcsec','1arcsec'] 00120 NOTE:cell = '2' makes default cell size of 2 radians! 00121 phasecenter -- direction measure or fieldid for the mosaic center 00122 default: 0 (imply field=0 as center); example: phasecenter=6 00123 or phasecenter='J2000 19h30m00 -40d00m00' 00124 stokes -- Stokes parameters to image 00125 default='I'; example: stokes='IQUV'; 00126 Options: 'I','IV''QU','IQUV','RR','LL','XX','YY','RRLL','XXYY' 00127 niter -- Maximum number iterations, set to zero for no CLEANing 00128 default: 500; example: niter=500 00129 gain -- Loop gain for CLEANing 00130 default: 0.1; example: gain=0.5 00131 threshold -- Flux level at which to stop CLEANing (units=mJy) 00132 default: 0.0; example: threshold=0.0 00133 mask -- Name of mask image used for CLEANing 00134 default '' means no mask; 00135 example: mask='orion.mask'. 00136 It is useful to use a mask from a previous interactive mosaic 00137 session for a new execution. The mask image shape 00138 must be the same as the new mosaic. 00139 cleanbox -- Cleaning region: 00140 default: [] defaults to inner quarter of image 00141 Three specification types: 00142 (a) 'interactive' allows the user to build the cleaning 00143 mask interactively using the viewer. The viewer will 00144 appear every npercycle interation, but modify as needed 00145 The final interactive maks is saved in the file 00146 imagename_interactive.mask. 00147 (b) Explicit pixel ranges 00148 example: cleanbox=[110,110,150,145] 00149 clean region with blc=110,100; trc=150,145 (pixel values) 00150 Only one clean region can be given this way. 00151 (c) Filename with pixel values with ascii format: 00152 <fieldindex blc-x blc-y trc-x trc-y> on each line 00153 1 45 66 123 124 00154 2 23 100 300 340 00155 >>> 'interactive' expandable parameter 00156 npercycle -- this is the number of iterations between each clean 00157 to update mask interactively. Set to about niter/5, can also 00158 be changed interactively. 00159 field -- Select fields in mosaic. Use field id(s) or field name(s). 00160 ['go listobs' to obtain the list id's or names] 00161 default: ''=all fields 00162 If field string is a non-negative integer, it is assumed to 00163 be a field index otherwise, it is assumed to be a field name 00164 field='0~2'; field ids 0,1,2 00165 field='0,4,5~7'; field ids 0,4,5,6,7 00166 field='3C286,3C295'; field named 3C286 and 3C295 00167 field = '3,4C*'; field id 3, all names starting with 4C 00168 spw -- Select spectral window/channels 00169 NOTE: This selects the data passed as the INPUT to mode 00170 default: ''=all spectral windows and channels 00171 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00172 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00173 spw='0:5~61'; spw 0, channels 5 to 61 00174 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00175 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00176 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00177 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10, 00178 spw 1, channels 20-30, and spw 2, channels, 1,2 and 3 00179 timerange -- Time range: 00180 default = '' (all); examples, 00181 selectime = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00182 Note: if YYYY/MM/DD is missing date defaults to first day 00183 in data set 00184 timerange='09:14:0~09:54:0' picks 40 min on first day 00185 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00186 timerange='09:44:00' data within one integration of time 00187 timerange='>10:24:00' data after this time 00188 restfreq -- Specify rest frequency to use for image 00189 default='' 00190 Occasionally it is necessary to set this (for example some VLA 00191 spectral line data). For example for 00192 NH_3 (1,1) put restfreq='23.694496GHz' 00193 sdimage -- Input Single Dish image to use for model 00194 default='' (no image); example: sdimage='n4826_12mchan.im' 00195 modelimage -- Name of output(/input) model image 00196 default='' (none=imagename.model); modelimage='orion.model' 00197 Note: This specifies the output model if a single dish 00198 image is input or the output model name from the imaging 00199 weighting -- Weighting to apply to visibilities: 00200 default='natural'; example: weighting='uniform'; 00201 Options: 'natural','uniform','briggs','radial', 'superuniform' 00202 >>> Weighting expandable parameters 00203 For weighting='briggs' 00204 rmode -- Robustness mode (see help mosaic) 00205 default='norm'; example='abs'; 00206 Options: 'norm','abs','none' 00207 robust -- Brigg's robustness parameter 00208 default=0.0; example: robust=0.5; 00209 Options: -2.0 to 2.0; -2 (uniform)/+2 (natural) 00210 noise -- noise parameter to use for rmode='abs' in 00211 briggs weighting 00212 example noise='1.0mJy' 00213 For superuniform/briggs weighting 00214 npixels -- number of pixels to determine uv-cell size 00215 for weight calculation 00216 example npixels=7 00217 mosweight -- Individually weight the fields of the mosaic 00218 default: False; example: mosweight=True 00219 This can be useful if some of your fields are more 00220 sensitive than others (i.e. due to time spent on-source); 00221 this parameter will give more weight to higher sensitivity 00222 fields in the overlap regions. 00223 ftmachine -- Gridding method for the image; 00224 Options: ft (standard interferometric gridding), sd 00225 (standard single dish) both (ft and sd as appropriate), 00226 mosaic (gridding use PB as convolution function) 00227 default: 'mosaic'; example: ftmachine='ft' 00228 cyclefactor -- Change the threshold at which the deconvolution cycle will 00229 stop, degrid and subtract from the visibilities. For poor PSFs, 00230 reconcile often (cyclefactor=4 or 5); For good PSFs, use 00231 cyclefactor 1.5 to 2.0. 00232 default: 1.5; example: cyclefactor=4 00233 cycle threshold = cyclefactor * max sidelobe * max residual 00234 cyclespeedup -- Cycle threshold doubles in this number of iterations 00235 default: -1; example: cyclespeedup=500 00236 scaletype -- Controls scaling of pixels in the image plane. 00237 default='SAULT'; example: scaletype='PBCOR' 00238 Options: 'PBCOR','SAULT' 00239 'SAULT' scale makes an output image where the noise is constant 00240 across the whole mosaic. However, the image is NOT 00241 corrected for the PB pattern, and therefore is not "flux 00242 correct". Division of the SAULT image_name.image image 00243 by the image_name.flux image will produce a "flux correct image". 00244 The 'PBCOR' option uses the SAULT scaling scheme for 00245 deconvolution, but when interactively cleaning shows the 00246 primary beam corrected image; the final PBCOR image is "flux 00247 correct" 00248 minpb -- Minimum PB level to use 00249 default=0.1; example: minpb=0.01 00250 async -- Run asynchronously 00251 default = False; do not run asychronously 00252 00253 """ 00254 if type(imsize)==int: imsize=[imsize] 00255 if type(cell)==float: cell=[cell] 00256 if type(mask)==str: mask=[mask] 00257 if type(prior)==str: prior=[prior] 00258 if type(scales)==int: scales=[scales] 00259 00260 # 00261 # The following is work around to avoid a bug with current python translation 00262 # 00263 mytmp = {} 00264 00265 mytmp['vis'] = vis 00266 mytmp['imagename'] = imagename 00267 mytmp['mode'] = mode 00268 mytmp['alg'] = alg 00269 mytmp['imsize'] = imsize 00270 if type(cell) == str : 00271 mytmp['cell'] = casac.quanta().quantity(cell) 00272 else : 00273 mytmp['cell'] = cell 00274 mytmp['phasecenter'] = phasecenter 00275 mytmp['stokes'] = stokes 00276 mytmp['niter'] = niter 00277 mytmp['gain'] = gain 00278 mytmp['threshold'] = threshold 00279 mytmp['mask'] = mask 00280 mytmp['cleanbox'] = cleanbox 00281 mytmp['nchan'] = nchan 00282 mytmp['start'] = start 00283 mytmp['width'] = width 00284 mytmp['field'] = field 00285 mytmp['spw'] = spw 00286 mytmp['timerange'] = timerange 00287 mytmp['restfreq'] = restfreq 00288 mytmp['sdimage'] = sdimage 00289 mytmp['modelimage'] = modelimage 00290 mytmp['weighting'] = weighting 00291 mytmp['mosweight'] = mosweight 00292 mytmp['rmode'] = rmode 00293 mytmp['robust'] = robust 00294 mytmp['ftmachine'] = ftmachine 00295 mytmp['cyclefactor'] = cyclefactor 00296 mytmp['cyclespeedup'] = cyclespeedup 00297 mytmp['scaletype'] = scaletype 00298 mytmp['minpb'] = minpb 00299 if type(sigma) == str : 00300 mytmp['sigma'] = casac.quanta().quantity(sigma) 00301 else : 00302 mytmp['sigma'] = sigma 00303 if type(targetflux) == str : 00304 mytmp['targetflux'] = casac.quanta().quantity(targetflux) 00305 else : 00306 mytmp['targetflux'] = targetflux 00307 mytmp['constrainflux'] = constrainflux 00308 mytmp['prior'] = prior 00309 mytmp['negcomponent'] = negcomponent 00310 mytmp['scales'] = scales 00311 mytmp['npercycle'] = npercycle 00312 mytmp['npixels'] = npixels 00313 if type(noise) == str : 00314 mytmp['noise'] = casac.quanta().quantity(noise) 00315 else : 00316 mytmp['noise'] = noise 00317 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00318 trec = casac.utils().torecord(pathname+'mosaic.xml') 00319 00320 casalog.origin('mosaic') 00321 if trec.has_key('mosaic') and casac.utils().verify(mytmp, trec['mosaic']) : 00322 result = task_mosaic.mosaic(vis, imagename, mode, alg, imsize, cell, phasecenter, stokes, niter, gain, threshold, mask, cleanbox, nchan, start, width, field, spw, timerange, restfreq, sdimage, modelimage, weighting, mosweight, rmode, robust, ftmachine, cyclefactor, cyclespeedup, scaletype, minpb, sigma, targetflux, constrainflux, prior, negcomponent, scales, npercycle, npixels, noise) 00323 00324 else : 00325 result = False 00326 return result