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_pclean 00013 def pclean(vis='', imagename='', imsize=[256, 256], cell=['1.0arcsec', '1.0arcsec'], phasecenter='', stokes='I', mask='', field='', spw='', ftmachine='ft', alg='clark', scales=[0], cyclefactor=1.5, majorcycles=1, niter=500, gain=0.1, threshold='0.0Jy', weighting='natural', robust=0.0, npixels=0, mode='continuum', nterms=1, start=0, nchan=1, width=1, restfreq='', interactive=False, npercycle=100, wprojplanes=128, facets=1, overwrite=True, uvtaper=False, outertaper=[''], timerange='', uvrange='', antenna='', scan='', observation='', pbcor=False, minpb=0.2, clusterdef=''): 00014 00015 """Invert and deconvolve images with parallel engines 00016 00017 Keyword arguments: 00018 Invert and deconvolve images with parallel engines 00019 Form images from visibilities. Handles continuum and spectral line 00020 cubes using module pcont and pcube respectively. 00021 00022 vis -- Name of input visibility file 00023 default: none; example: vis='ngc5921.ms' 00024 00025 imagename -- Pre-name of output CASA image. (only the prefix) 00026 default: none; 00027 example: imagename='m2', output images are: 00028 m2.image; cleaned and restored image 00029 With or without primary beam correction 00030 m2.psf; point-spread function (dirty beam) 00031 m2.model; image of clean components 00032 m2.mask; image containing clean regions, when interative=True 00033 00034 imsize -- Image pixel size (x,y). DOES NOT HAVE TO BE A POWER OF 2 00035 default: [256,256]; 00036 example: imsize=[350,350] 00037 imsize=500 is equivalent to imsize=[500, 500] 00038 Avoid odd-numbered imsize. 00039 00040 cell -- Cell size (x,y) 00041 default: '1.0arcsec'; 00042 example: cell=['0.5arcsec', '0.5arcsec'] or 00043 cell=['1arcmin', '1arcmin'] 00044 cell='1arcsec' is equivalent to cell=['1arcsec', '1arcsec'] 00045 NOTE:cell=2.0 => cell=['2arcsec', '2arcsec'] 00046 00047 phasecenter -- direction measure or fieldid for the mosaic center 00048 default: '' => first field selected; 00049 example: phasecenter=6 00050 or phasecenter='J2000 19h30m00 -40d00m00' 00051 00052 mask -- mask image to be used for CLEANing. As long as the image has 00053 the same shape (size), mask images from a previous 00054 interactive session can be used for a new execution. 00055 Only an image mask is allowed at this stage. Text formats not allowed yet. 00056 00057 field -- Select fields in MS. Use field id(s) or field name(s). 00058 ['go listobs' to obtain the list id's or names] 00059 default: ''= all fields 00060 If field string is a non-negative integer, it is assumed to 00061 be a field index otherwise, it is assumed to be a field name 00062 examples: 00063 field='0~2'; field ids 0,1,2 00064 field='0,4,5~7'; field ids 0,4,5,6,7 00065 field='3C286,3C295'; field named 3C286 and 3C295 00066 field = '3,4C*'; field id 3, all names starting with 4C 00067 00068 spw --Select spectral window/channels 00069 NOTE: This selects the data passed as the INPUT to mode 00070 default: ''=all spectral windows and channels 00071 examples: 00072 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00073 spw='0:5~61'; spw 0, channels 5 to 61 00074 spw='< 2'; spectral windows less than 2 (i.e. 0,1) 00075 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, 00076 channels 3 to 45. 00077 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00078 spw='0:0~10;15~60'; spectral window 0 with channels 00079 0-10,15-60 00080 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10, 00081 spw 1, channels 20-30, and spw 2, channels, 1,2 and 3 00082 00083 ftmachine -- Fourier Transform Engine (Gridding method) 00084 Options: 00085 'ft' (standard interferometric gridding), 00086 'sd' (standard single dish), 00087 'mosaic' (grid using PB as convolution function). 00088 'wproject' (wprojection gridder to correct for widefield 'w' term errors) 00089 default: 'ft' 00090 00091 alg -- Deconvolution algorithm 00092 Options: 'clark', 'hogbom', 'multiscale' 00093 default: 'clark' 00094 00095 cyclefactor -- Controls the threshhold at which the 00096 deconvolution cycle will pause to degrid and subtract the 00097 model from the visibilities (Cotton-Schwab (CS) major cycle). 00098 With poor PSFs, reconcile often (cyclefactor=4 or 5) for 00099 reliability. 00100 With good PSFs, use cyclefactor = 1.5 to 2.0 for speed. 00101 Note: threshold = cyclefactor * max sidelobe * max residual 00102 default: 1.5; example: cyclefactor=4 00103 cyclefactor=0 allows the user to control number of CS major cycle 00104 >>> majorcycles -- integer number of CS major cycles to do 00105 default: 1; 00106 example: majorcycles=10 00107 00108 niter -- Maximum number iterations, 00109 if niter=0, then no CLEANing is done ("invert" only) 00110 default: 500; 00111 example: niter=5000 00112 00113 threshold -- Flux level (residual peak) at which to stop CLEANing 00114 default: '0.0mJy'; 00115 example: 00116 threshold='2.3mJy' (always include units) 00117 threshold='0.0023Jy' 00118 threshold='0.0023Jy/beam' (okay also) 00119 00120 weighting -- Weighting to apply to visibilities: 00121 Options: 'natural','uniform','briggs', 00122 'superuniform','radial' 00123 default: 'natural'; 00124 example: weighting='uniform'; 00125 00126 scales -- list of scales in pixel for multiscale clean 00127 default: [0] 00128 example: scales=[0, 3, 10] 00129 00130 mode -- type of image to be generated 00131 Options: 'continuum', 'cube' 00132 default: 'continuum' 00133 example: 00134 mode='cube'; Use with nchan, start, step to specify 00135 output image cube. 00136 NOTE: mode='velocity' or 'channel' or 'frequency' 00137 are aliased to mode='cube' for backward compatibility 00138 and comfort. 00139 00140 >>> mode='cube' expandable parameters 00141 nchan -- Total number of channels in the output image. 00142 Example: nchan=100. 00143 Default: -1; Automatically selects enough channels to cover 00144 data selected by 'spw' and consistent with 'start' and 'step' 00145 It is often easiest to leave nchan at the default value. 00146 start -- First channel, velocity, or frequency. 00147 if start is an integer pclean will assume it is the a channel index 00148 if start is in units of velocity or frequency it will take it as such 00149 00150 If the user use the the ms channel as starting pclean will assign 00151 the first channel of the image to the data channel frequency in LSRK 00152 of the first 00153 spw selected at the first time seen in the data and the direction of the 00154 source selected. 00155 If the data is not in the LSRK frame the user should be aware that the 00156 data channel indicated may not fall on the first image channel as time goes. 00157 00158 example:start=5 00159 start can be in units of frequency or velocity too 00160 When velocity units is used it is obvious then that it is referring to the line 00161 whose restfrequency is provided by the user or is default one for the source 00162 in the MS/SOURCE table. 00163 examples: start='5.0km/s', or start='22.3GHz'. 00164 width -- Output channel width 00165 should be in the same units as start 00166 default=1; >1 indicates channel averaging 00167 if start is an integer, width has to be an integer defining the image channel 00168 width by the number of channels of first spectral window selected 00169 example: width=4. 00170 when start is in frequency or velocity units then the width has to be in the same units. default=''; 00171 00172 examples: width='1.0km/s', or width='24.2kHz'. 00173 00174 00175 interactive -- Create a mask interactively or not. 00176 interactive clean allows the user to build the cleaning 00177 mask interactively using the viewer. 00178 00179 default: False; 00180 example: interactive=True 00181 The viewer will open with the image displayed. Select the 00182 region for the mask and double click in the middle of it. 00183 00184 >>> npercycle -- Number of iteration in between viewer interactions. 00185 default=100 00186 00187 pbcor -- Output primary beam-corrected image 00188 If pbcor=False, the final output image is NOT corrected for 00189 the PB pattern (particularly important for mosaics), and 00190 therefore is not "flux correct". Correction can also be 00191 done after the fact using immath to divide 00192 <imagename>.image by the <imagename>.flux image. 00193 default: pbcor=False; output un-corrected image 00194 example: pbcor=True; output pb-corrected image (masked outside 00195 minpb) 00196 00197 >>> minpb -- Minimum PB level to use for pb-correction and pb-based masking. 00198 default=0.2; 00199 example: minpb=0.01 00200 When ftmachine is *not* 'mosaic' : 00201 minpb is applied to the flux image (sensitivity-weighted pb). 00202 When ftmachine='mosaic' : 00203 minpb is applied to the flux.pbcoverage image 00204 00205 overwrite -- If False use existing model image of same name to continue clean 00206 if True the imagename.model and other associated images are overwitten 00207 if they exist 00208 default: True 00209 00210 00211 timerange -- Select data based on time range: 00212 default: '' (all); examples, 00213 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00214 Note: if YYYY/MM/DD is missing date defaults to first 00215 day in data set 00216 timerange='09:14:0~09:54:0' picks 40 min on first day 00217 timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 00218 30min on NEXT day 00219 timerange='09:44:00' pick data within one integration 00220 of time 00221 timerange='>10:24:00' data after this time 00222 For multiple MS input, a list of timerange strings can be 00223 used: 00224 uvrange -- Select data within uvrange (default units meters) 00225 default: '' (all); example: 00226 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 00227 uvrange='>4klambda';uvranges greater than 4 kilo lambda 00228 antenna -- Select data based on antenna/baseline 00229 default: '' (all) 00230 If antenna string is a non-negative integer, it is 00231 assumed to be an antenna index, otherwise, it is 00232 considered an antenna name. 00233 antenna='5&6'; baseline between antenna index 5 and 00234 index 6. 00235 antenna='VA05&VA06'; baseline between VLA antenna 5 00236 and 6. 00237 antenna='5&6;7&8'; baselines 5-6 and 7-8 00238 antenna='5'; all baselines with antenna index 5 00239 antenna='05'; all baselines with antenna number 05 00240 (VLA old name) 00241 antenna='5,6,9'; all baselines with antennas 5,6,9 00242 index number 00243 scan -- Scan number range. 00244 default: '' (all) 00245 example: scan='1~5 00246 observation -- Observation ID range. 00247 default: '' (all) 00248 example: observation='1~5' 00249 00250 00251 clusterdef -- Name of a file that contains the cluster definition. 00252 NOTE: there is a chapter in the cookbook on how to 00253 define this file 00254 If clusterdef='' (the default) then all the cores, if possible, 00255 of the machine on 00256 which casapy is run will be used. 00257 00258 Example of a cube imaging run: 00259 00260 pclean(vis="ngc5921.ms.contsub",imagename="loulou",imsize=[2500, 2500], 00261 cell=['15.0arcsec', '15.0arcsec'],phasecenter="",stokes="I",field="0",spw="*", 00262 ftmachine="ft",alg="hogbom",majorcycles=2, niter=6000,gain=0.1, 00263 threshold="8mJy",weighting="briggs",robust=0.5,npixels=0,mode="cube", 00264 start=5,nchan=46,width=1,interactive=True,overwrite=True,uvtaper=False, 00265 outertaper=[''],pbcor=True) 00266 00267 Example of a continuum run: 00268 00269 pclean(vis='sim100g_4chan15kRows.ms', 00270 imagename='hundredG_cont', imsize=[1500, 1500], 00271 cell=['0.135arcsec', '0.135arcsec'], mode='continuum', phasecenter='0', 00272 field='0', spw='*', ftmachine='wproject', wprojplanes=128, 00273 threshold='0.1mJy', 00274 majorcycles=4, niter=10000, alg='clark', 00275 weighting='natural', 00276 overwrite=True) 00277 00278 00279 """ 00280 if type(imsize)==int: imsize=[imsize] 00281 if type(cell)==float: cell=[cell] 00282 if type(scales)==int: scales=[scales] 00283 if type(outertaper)==str: outertaper=[outertaper] 00284 00285 # 00286 # The following is work around to avoid a bug with current python translation 00287 # 00288 mytmp = {} 00289 00290 mytmp['vis'] = vis 00291 mytmp['imagename'] = imagename 00292 mytmp['imsize'] = imsize 00293 if type(cell) == str : 00294 mytmp['cell'] = casac.quanta().quantity(cell) 00295 else : 00296 mytmp['cell'] = cell 00297 mytmp['phasecenter'] = phasecenter 00298 mytmp['stokes'] = stokes 00299 mytmp['mask'] = mask 00300 mytmp['field'] = field 00301 mytmp['spw'] = spw 00302 mytmp['ftmachine'] = ftmachine 00303 mytmp['alg'] = alg 00304 mytmp['scales'] = scales 00305 mytmp['cyclefactor'] = cyclefactor 00306 mytmp['majorcycles'] = majorcycles 00307 mytmp['niter'] = niter 00308 mytmp['gain'] = gain 00309 mytmp['threshold'] = threshold 00310 mytmp['weighting'] = weighting 00311 mytmp['robust'] = robust 00312 mytmp['npixels'] = npixels 00313 mytmp['mode'] = mode 00314 mytmp['nterms'] = nterms 00315 mytmp['start'] = start 00316 mytmp['nchan'] = nchan 00317 mytmp['width'] = width 00318 mytmp['restfreq'] = restfreq 00319 mytmp['interactive'] = interactive 00320 mytmp['npercycle'] = npercycle 00321 mytmp['wprojplanes'] = wprojplanes 00322 mytmp['facets'] = facets 00323 mytmp['overwrite'] = overwrite 00324 mytmp['uvtaper'] = uvtaper 00325 mytmp['outertaper'] = outertaper 00326 mytmp['timerange'] = timerange 00327 mytmp['uvrange'] = uvrange 00328 mytmp['antenna'] = antenna 00329 mytmp['scan'] = scan 00330 mytmp['observation'] = observation 00331 mytmp['pbcor'] = pbcor 00332 mytmp['minpb'] = minpb 00333 mytmp['clusterdef'] = clusterdef 00334 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00335 trec = casac.utils().torecord(pathname+'pclean.xml') 00336 00337 casalog.origin('pclean') 00338 if trec.has_key('pclean') and casac.utils().verify(mytmp, trec['pclean']) : 00339 result = task_pclean.pclean(vis, imagename, imsize, cell, phasecenter, stokes, mask, field, spw, ftmachine, alg, scales, cyclefactor, majorcycles, niter, gain, threshold, weighting, robust, npixels, mode, nterms, start, nchan, width, restfreq, interactive, npercycle, wprojplanes, facets, overwrite, uvtaper, outertaper, timerange, uvrange, antenna, scan, observation, pbcor, minpb, clusterdef) 00340 00341 else : 00342 result = False 00343 return result