casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2008, Associated Universities Inc., Washington DC 00005 # 00006 import sys 00007 import os 00008 from casac import * 00009 import string 00010 import time 00011 import inspect 00012 import gc 00013 import numpy 00014 from odict import odict 00015 from task_widefield import widefield 00016 from task_widefield import casalog 00017 00018 class widefield_pg_: 00019 __name__ = "widefield" 00020 00021 def __init__(self) : 00022 self.__bases__ = (widefield_pg_,) 00023 self.__doc__ = self.__call__.__doc__ 00024 00025 00026 def __call__(self, vis=None, imagename=None, outlierfile=None, field=None, spw=None, selectdata=None, timerange=None, uvrange=None, antenna=None, scan=None, mode=None, niter=None, gain=None, threshold=None, psfmode=None, ftmachine=None, facets=None, wprojplanes=None, multiscale=None, negcomponent=None, interactive=None, mask=None, nchan=None, start=None, width=None, imsize=None, cell=None, phasecenter=None, restfreq=None, stokes=None, weighting=None, robust=None, npixels=None, noise=None, cyclefactor=None, cyclespeedup=None, npercycle=None, uvtaper=None, outertaper=None, innertaper=None, restoringbeam=None, calready=None, async=None): 00027 00028 """Wide-field imaging and deconvolution with selected algorithm 00029 00030 Wide-field imaging and deconvolution with selected algorithm: 00031 00032 This is the main wide-field imaging/deconvolution task. It 00033 uses the wprojection method for a large field of view, can 00034 make many facets, and can include outlier fields. Several 00035 deconvolution algorithms are supported. Interactive cleaning 00036 is also supported. 00037 00038 For making large images (>2000 on a size), see hints at the 00039 end of the descriptions. For making images larger than about 00040 5000x5000, the available memory must be larger than 2 Gbytes. For such 00041 images therefore a computer with a 64-bit operating system may be 00042 needed. 00043 00044 00045 Keyword arguments: 00046 vis -- Name of all input visibility files 00047 default: none; example: vis='ngc5921.ms' 00048 example: vis=['data01.ms', 'data02.ms'] 00049 imagename -- Pre-name of output images: 00050 default: none; example: imagename='n5921' 00051 if outlier fields are included, then 00052 imagename=['n5921', 'outlier1', outlier2'] 00053 and the first imagename is the wide-field image 00054 output images names are: n5921.clean, n5921.residual, 00055 n5921.model, n5921.interactive.mask 00056 mode -- Type of selection 00057 default: 'mfs'; example: mode='channel'; 00058 Options: 'mfs', channel, velocity, frequency' 00059 alg -- Algorithm to use 00060 default: 'clark'; 00061 Options: 'clark', 'hogbom','multiscale','entropy' 00062 Strongly advise 'clark'. multiscale and entropy 00063 well-tested. 00064 imsize -- Image pixel size (x,y) 00065 default = [256,256]; example: imsize=[500,500], or imsize=500 00066 example for multiple fields: imsize=[(1000, 1000), (100, 100)] 00067 cell -- Cell size (x,y) 00068 default=['1arcsec,'1arcsec'] 00069 example: cell=['0.5arcsec,'0.5arcsec'], or cell='0.5arcsec' 00070 phasecenter -- direction position or the field for the image center 00071 A list of the above is needed for multiple-fields 00072 default: '' -->field='0' as center; example: phasecenter='6' 00073 phasecenter='J2000 19h30m00 -40d00m00' 00074 phasecenter=['J2000 19h30m00 -40d00m00', 'J2000 19h57m00 40d00m00'] 00075 for wide-field, plus one outlier field. 00076 stokes -- Stokes parameters to image 00077 default='I'; example: stokes='IQUV'; 00078 Options: 'I','IV','IQU','IQUV' 00079 niter -- Number iterations, set to zero for no CLEANing 00080 default: 500; example: niter=500 00081 gain -- Loop gain for CLEANing 00082 default: 0.1; example: gain=0.1 00083 threshold -- Flux level at which to stop CLEANing (units=mJy) 00084 default: 0.0; example: threshold=0.0 00085 mask -- Name(s) of mask image(s) used for CLEANing 00086 default: '' example: mask='orion.mask' 00087 Number of mask fields must equal number of imaged fields 00088 cleanbox -- List of [blc-x,blc-y,trc-x,trc-y] values 00089 default: []; example: cleanbox=[110,110,150,145] 00090 Note: This can also be a filename with clean values: 00091 fieldindex blc-x blc-y trc-x trc-y 00092 cleanbox = 'interactive' is very useful. 00093 --- Data Selection 00094 nchan -- Number of channels to select 00095 default: 1; example: nchan=45 00096 start -- Start channel, 0-relative 00097 default=0; example: start=5 00098 if mode='frequency' then a frequency value e.g start='1.4GHz' 00099 width -- Channel width (value > 1 indicates channel averaging) 00100 default=1; example: width=5 00101 if mode='frequency' then a frequency value e.g width='10kHz' 00102 step -- Step in channel number 00103 default=1; example: step=2 00104 field -- Select field using field id(s) or field name(s). 00105 [run listobs to obtain the list id's or names] 00106 default: ''=all fields 00107 If field string is a non-negative integer, it is assumed a field index 00108 otherwise, it is assumed a field name 00109 field='0~2'; field ids 0,1,2 00110 field='0,4,5~7'; field ids 0,4,5,6,7 00111 field='3C286,3C295'; field named 3C286 adn 3C295 00112 field = '3,4C*'; field id 3, all names starting with 4C 00113 example for multiple ms in vis parameter: 00114 field=['0~2', '1,2'] 00115 spw -- Select spectral window/channels 00116 default: ''=all spectral windows and channels 00117 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00118 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00119 spw='0:5~61'; spw 0, channels 5 to 61 00120 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00121 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00122 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00123 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10, 00124 spw 1, channels 20-30, and spw 2, channels, 1,2 and 3 00125 For multiple ms in vis parameter: 00126 spw=['0,10,3:3~45', '<2'] 00127 timerange -- Select time range subset of data (not implemented yet) 00128 default='' meaning no time selection 00129 example: timerange='YYYY/MM/DD/HH:MM:SS.sss' 00130 timerange='< YYYY/MM/DD/HH:MM:SS.sss' 00131 timerange='> YYYY/MM/DD/HH:MM:SS.sss' 00132 timerange='ddd/HH:MM:SS.sss' 00133 timerange='< ddd/HH:MM:SS.sss' 00134 timerange='> ddd/HH:MM:SS.sss' 00135 restfreq -- Specify rest frequency to use for image 00136 default='' (i.e., try to use the restfreq specified in the visibility data) 00137 00138 --- Weighting 00139 weighting -- Weighting to apply to visibilities 00140 default='natural'; example: weighting='uniform'; 00141 Options: 'natural','uniform','briggs','briggsabs','radial', 'superuniform' 00142 robust -- 'briggs' and 'brigssabs' robustness parameter 00143 default=0.0; example: robust=0.5; 00144 Options: -2.0 to 2.0; -2 (uniform)/+2 (natural) 00145 npixels -- number of pixels to determine uv-cell size for weight calculation 00146 -- Used with superuniform or briggs weighting schemes 00147 example: npixels=3 00148 00149 --- widefield controls 00150 ftmachine -- Gridding method for the image; 00151 ft (standard interferometric gridding). 00152 wproject (wprojection algorithm for gridding) 00153 default: wproject 00154 wprojplanes -- Number w-projection planes to use for gridding 00155 default: 256 00156 example: wprojplanes=64 00157 Good value = BMAX(klambda) * Map width(arcmin)^2 / 600 00158 facets -- Number of facets along one axis on central image 00159 image is divided in facets x facets rectangles. 00160 default: 1 00161 example: facets=3 makes 3x3 images to cover the field 00162 if ftmachine = 'ft', only faceting is used 00163 if ftmachine = 'wproject', both wplanes and faceting 00164 can be used (see below). 00165 00166 cyclefactor -- Change the threshold at which the deconvolution cycle will 00167 stop and degrid and subtract from the visibilities. For bad PSFs, 00168 reconcile often (cyclefactor=4 or 5); For good PSFs, use 00169 cyclefactor 1.5 to 2.0. 00170 default: 2.5; example: cyclefactor=4, but decreases speed considerably. 00171 <cycle threshold = cyclefactor * max sidelobe * max residual> 00172 cyclespeedup -- Cycle threshold doubles in this number of iterations 00173 default: -1; example: cyclespeedup=500 00174 00175 --- MEM parameters (Experimental, not well-tested) 00176 sigma -- Target image sigma 00177 default: '0.001Jy'; example: sigma='0.1Jy' 00178 targetflux -- Target flux for final image 00179 default: '1.0Jy'; example: targetflux='200Jy' 00180 constrainflux -- Constrain image to match target flux; 00181 otherwise, targetflux is used to initialize model only. 00182 default: False; example: constrainflux=True 00183 prior -- Name of MEM prior images 00184 default: ['']; example: prior='source_mem.image' 00185 00186 --- Multi-scale parameters (Experimental, not well-tested) 00187 negcomponent -- Stop component search when the largest scale has found this 00188 number of negative components; -1 means continue component search 00189 even if the largest component is negative. 00190 default: 2; example: negcomponent=-1 00191 scales -- Used for alg='multiscale'; set a number of scales or a vector 00192 default: [0,3,10]; example: scales=[0.0,3.0,10.0, 30] 00193 -- interactive masking 00194 npercycle -- when cleanbox is set to 'interactive', 00195 this is the number of iterations between each clean to update mask 00196 interactively. However, this number can be adjusted during execution. 00197 00198 uvtaper -- Apply additional uv tapering of the visibilities. 00199 default: uvtaper=False; example: uvtaper=True 00200 uvtaper=True expandable parameters 00201 outertaper -- uv-taper on outer baselines in uv-plane 00202 [bmaj, bmin, bpa] taper Gaussian scale in uv or 00203 angular units. NOTE: uv taper in (klambda) is 00204 roughly on-sky FWHM(arcsec/200) 00205 default: outertaper=[]; no outer taper applied 00206 example: outertaper=['5klambda'] circular taper 00207 FWHM=5 kilo-lambda 00208 outertaper=['5klambda','3klambda','45.0deg'] 00209 outertaper=['10arcsec'] on-sky FWHM 10" 00210 outertaper=['300.0'] default units are meters 00211 in aperture plane 00212 innertaper -- uv-taper in center of uv-plane 00213 NOT YET IMPLEMENTED 00214 00215 restoringbeam -- Output Gaussian restoring beam for CLEAN image 00216 [bmaj, bmin, bpa] elliptical Gaussian restoring beam 00217 default units are in arc-seconds for bmaj,bmin, degrees 00218 for bpa default: restoringbeam=[]; Use PSF calculated 00219 from dirty beam. 00220 example: restoringbeam=['10arcsec'] circular Gaussian 00221 FWHM 10" example: 00222 restoringbeam=['10.0','5.0','45.0deg'] 10"x5" 00223 at 45 degrees 00224 00225 calready -- if True will create scratch columns if they are 00226 not there. And after clean completes the predicted model 00227 visibility is from the clean components are 00228 written to the ms. 00229 00230 async -- Run asynchronously 00231 default = False; do not run asychronously 00232 00233 ====================================================================== 00234 00235 HINTS ON RUNNING WIDEFIELD 00236 00237 1. Decide if the images will be specified directly in the 00238 inputs or with an outlier file. For more than a few fields, 00239 an outlier file more convenient. 00240 00241 Direct Method: 00242 00243 cell = ['1.0arcsec', '1.0arcsec'] 00244 imagename = ['M1_0','M1_1','M1_2] 00245 imsize = [[1024,1024],[128,128],[128,128]] 00246 phasecenter = ['J2000 13h27m20.98 43d26m28.0', 00247 'J2000 13h30m52.159 43d23m08.02', 'J2000 13h24m08.16 43d09m48.0'] 00248 00249 Text file method (in outlier.txt) 00250 00251 imagename = 'M1' 00252 outlierfile = 'outlier.txt' 00253 [phasecenter, imsize ignored] 00254 00255 Contents of outlier.txt 00256 C 0 1024 1024 13 27 20.98 43 26 28.0 00257 C 1 128 128 13 30 52.158 43 23 08.00 00258 C 2 128 128 13 24 08.163 43 09 48.00 00259 00260 In both cases the following images will be made: 00261 M1_0.image, M1_1.image, M1_2.image cleaned images 00262 M1.0.model, M1_1.model, M1_2.model model images 00263 M1.0.residual, M1_1.residual, M1_2.residual residual images 00264 00265 2. Wprojection: It is fastest to use wprojection without faceting. 00266 ftmachine = 'wproject' 00267 wprojplane = NN 00268 00269 The value of NN should be chosen as small as possible to reduce 00270 execution time. The algorithm 00271 NN = BMAX(klambda) * imagewidth (arcmin)^2 / 600, with a minimum 00272 of 16, should be adequate. 00273 00274 3. Depending on the memory of the computer, a limit of about 00275 5000x5000 may occur for example if a computer has 2Gbyte of 00276 RAM. Also a 32-bit computer has a maximum limit of 2Gbyte 00277 memory usable per process, irrespective of how much physical 00278 RAM is present. Hence it is recommended to move to a 64-bit 00279 computer with more than 2 GByte of RAM for >5000x5000 images 00280 00281 00282 4. For data with extremely large 'w' values, i.e low frequency, 00283 long baseline and very widefield image, the wprojection 00284 convolution can be very large and either not fit in memory or 00285 slow for processing. In these cases you should consider using 00286 both ftmachine='wproject' and facets=xx where is 3. 00287 00288 00289 """ 00290 a=inspect.stack() 00291 stacklevel=0 00292 for k in range(len(a)): 00293 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00294 stacklevel=k 00295 break 00296 myf=sys._getframe(stacklevel).f_globals 00297 myf['__last_task'] = 'widefield' 00298 myf['taskname'] = 'widefield' 00299 ### 00300 myf['update_params'](func=myf['taskname'],printtext=False) 00301 ### 00302 ### 00303 #Handle globals or user over-ride of arguments 00304 # 00305 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00306 useLocalDefaults = False 00307 00308 for item in function_signature_defaults.iteritems(): 00309 key,val = item 00310 keyVal = eval(key) 00311 if (keyVal == None): 00312 #user hasn't set it - use global/default 00313 pass 00314 else: 00315 #user has set it - use over-ride 00316 if (key != 'self') : 00317 useLocalDefaults = True 00318 #myf[key]=keyVal 00319 00320 myparams = {} 00321 if useLocalDefaults : 00322 for item in function_signature_defaults.iteritems(): 00323 key,val = item 00324 keyVal = eval(key) 00325 exec('myparams[key] = keyVal') 00326 if (keyVal == None): 00327 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00328 keyVal = eval(key) 00329 if(type(keyVal) == dict) : 00330 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00331 00332 else : 00333 uselessvariable = None 00334 myparams['vis'] = vis = myf['vis'] 00335 myparams['imagename'] = imagename = myf['imagename'] 00336 myparams['outlierfile'] = outlierfile = myf['outlierfile'] 00337 myparams['field'] = field = myf['field'] 00338 myparams['spw'] = spw = myf['spw'] 00339 myparams['selectdata'] = selectdata = myf['selectdata'] 00340 myparams['timerange'] = timerange = myf['timerange'] 00341 myparams['uvrange'] = uvrange = myf['uvrange'] 00342 myparams['antenna'] = antenna = myf['antenna'] 00343 myparams['scan'] = scan = myf['scan'] 00344 myparams['mode'] = mode = myf['mode'] 00345 myparams['niter'] = niter = myf['niter'] 00346 myparams['gain'] = gain = myf['gain'] 00347 myparams['threshold'] = threshold = myf['threshold'] 00348 myparams['psfmode'] = psfmode = myf['psfmode'] 00349 myparams['ftmachine'] = ftmachine = myf['ftmachine'] 00350 myparams['facets'] = facets = myf['facets'] 00351 myparams['wprojplanes'] = wprojplanes = myf['wprojplanes'] 00352 myparams['multiscale'] = multiscale = myf['multiscale'] 00353 myparams['negcomponent'] = negcomponent = myf['negcomponent'] 00354 myparams['interactive'] = interactive = myf['interactive'] 00355 myparams['mask'] = mask = myf['mask'] 00356 myparams['nchan'] = nchan = myf['nchan'] 00357 myparams['start'] = start = myf['start'] 00358 myparams['width'] = width = myf['width'] 00359 myparams['imsize'] = imsize = myf['imsize'] 00360 myparams['cell'] = cell = myf['cell'] 00361 myparams['phasecenter'] = phasecenter = myf['phasecenter'] 00362 myparams['restfreq'] = restfreq = myf['restfreq'] 00363 myparams['stokes'] = stokes = myf['stokes'] 00364 myparams['weighting'] = weighting = myf['weighting'] 00365 myparams['robust'] = robust = myf['robust'] 00366 myparams['npixels'] = npixels = myf['npixels'] 00367 myparams['noise'] = noise = myf['noise'] 00368 myparams['cyclefactor'] = cyclefactor = myf['cyclefactor'] 00369 myparams['cyclespeedup'] = cyclespeedup = myf['cyclespeedup'] 00370 myparams['npercycle'] = npercycle = myf['npercycle'] 00371 myparams['uvtaper'] = uvtaper = myf['uvtaper'] 00372 myparams['outertaper'] = outertaper = myf['outertaper'] 00373 myparams['innertaper'] = innertaper = myf['innertaper'] 00374 myparams['restoringbeam'] = restoringbeam = myf['restoringbeam'] 00375 myparams['calready'] = calready = myf['calready'] 00376 00377 if type(vis)==str: vis=[vis] 00378 if type(multiscale)==int: multiscale=[multiscale] 00379 if type(imsize)==int: imsize=[imsize] 00380 if type(cell)==float: cell=[cell] 00381 if type(outertaper)==str: outertaper=[outertaper] 00382 if type(innertaper)==str: innertaper=[innertaper] 00383 if type(restoringbeam)==str: restoringbeam=[restoringbeam] 00384 00385 result = None 00386 00387 # 00388 # The following is work around to avoid a bug with current python translation 00389 # 00390 mytmp = {} 00391 00392 mytmp['vis'] = vis 00393 mytmp['imagename'] = imagename 00394 mytmp['outlierfile'] = outlierfile 00395 mytmp['field'] = field 00396 mytmp['spw'] = spw 00397 mytmp['selectdata'] = selectdata 00398 mytmp['timerange'] = timerange 00399 mytmp['uvrange'] = uvrange 00400 mytmp['antenna'] = antenna 00401 mytmp['scan'] = scan 00402 mytmp['mode'] = mode 00403 mytmp['niter'] = niter 00404 mytmp['gain'] = gain 00405 mytmp['threshold'] = threshold 00406 mytmp['psfmode'] = psfmode 00407 mytmp['ftmachine'] = ftmachine 00408 mytmp['facets'] = facets 00409 mytmp['wprojplanes'] = wprojplanes 00410 mytmp['multiscale'] = multiscale 00411 mytmp['negcomponent'] = negcomponent 00412 mytmp['interactive'] = interactive 00413 mytmp['mask'] = mask 00414 mytmp['nchan'] = nchan 00415 mytmp['start'] = start 00416 mytmp['width'] = width 00417 mytmp['imsize'] = imsize 00418 if type(cell) == str : 00419 mytmp['cell'] = casac.quanta().quantity(cell) 00420 else : 00421 mytmp['cell'] = cell 00422 mytmp['phasecenter'] = phasecenter 00423 mytmp['restfreq'] = restfreq 00424 mytmp['stokes'] = stokes 00425 mytmp['weighting'] = weighting 00426 mytmp['robust'] = robust 00427 mytmp['npixels'] = npixels 00428 mytmp['noise'] = noise 00429 mytmp['cyclefactor'] = cyclefactor 00430 mytmp['cyclespeedup'] = cyclespeedup 00431 mytmp['npercycle'] = npercycle 00432 mytmp['uvtaper'] = uvtaper 00433 mytmp['outertaper'] = outertaper 00434 mytmp['innertaper'] = innertaper 00435 mytmp['restoringbeam'] = restoringbeam 00436 mytmp['calready'] = calready 00437 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00438 trec = casac.utils().torecord(pathname+'widefield.xml') 00439 00440 casalog.origin('widefield') 00441 if not trec.has_key('widefield') or not casac.utils().verify(mytmp, trec['widefield']) : 00442 return False 00443 00444 00445 try : 00446 casalog.post('') 00447 casalog.post('##########################################') 00448 casalog.post('##### Begin Task: widefield #####') 00449 casalog.post('') 00450 result = widefield(vis, imagename, outlierfile, field, spw, selectdata, timerange, uvrange, antenna, scan, mode, niter, gain, threshold, psfmode, ftmachine, facets, wprojplanes, multiscale, negcomponent, interactive, mask, nchan, start, width, imsize, cell, phasecenter, restfreq, stokes, weighting, robust, npixels, noise, cyclefactor, cyclespeedup, npercycle, uvtaper, outertaper, innertaper, restoringbeam, calready) 00451 casalog.post('') 00452 casalog.post('##### End Task: widefield #####') 00453 casalog.post('##########################################') 00454 00455 00456 # saveinputs for individule engine has no use 00457 # saveinputs should alos be removed from casa_in_py.py 00458 # 00459 # 00460 # saveinputs = myf['saveinputs'] 00461 # saveinputs('widefield', 'widefield.last', myparams) 00462 # 00463 # 00464 except Exception, instance: 00465 #print '**** Error **** ',instance 00466 pass 00467 00468 gc.collect() 00469 return result 00470 # 00471 # 00472 ## 00473 # def paramgui(self, useGlobals=True): 00474 # """ 00475 # Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00476 # """ 00477 # import paramgui 00478 # 00479 # a=inspect.stack() 00480 # stacklevel=0 00481 # for k in range(len(a)): 00482 # if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00483 # stacklevel=k 00484 # break 00485 # myf = sys._getframe(stacklevel).f_globals 00486 # 00487 # if useGlobals: 00488 # paramgui.setGlobals(myf) 00489 # else: 00490 # paramgui.setGlobals({}) 00491 # 00492 # paramgui.runTask('widefield', myf['_ip']) 00493 # paramgui.setGlobals({}) 00494 # 00495 # 00496 # 00497 # 00498 def defaults(self, param=None): 00499 a=inspect.stack() 00500 stacklevel=0 00501 for k in range(len(a)): 00502 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00503 stacklevel=k 00504 break 00505 myf=sys._getframe(stacklevel).f_globals 00506 a = odict() 00507 a['vis'] = [''] 00508 a['imagename'] = '', 00509 a['outlierfile'] = '' 00510 a['field'] = '' 00511 a['spw'] = '' 00512 a['selectdata'] = False 00513 a['mode'] = 'mfs' 00514 a['niter'] = 500 00515 a['gain'] = 0.1 00516 a['threshold'] = '0.0Jy' 00517 a['psfmode'] = 'clark' 00518 a['ftmachine'] = '' 00519 a['multiscale'] = [] 00520 a['interactive'] = False 00521 a['mask'] = [] 00522 a['imsize'] = [256, 256] 00523 a['cell'] = ['1.0arcsec', '1.0arcsec'] 00524 a['phasecenter'] = '' 00525 a['restfreq'] = '' 00526 a['stokes'] = 'I' 00527 a['weighting'] = 'natural' 00528 a['cyclefactor'] = 1.5 00529 a['cyclespeedup'] = -1 00530 a['uvtaper'] = False 00531 a['restoringbeam'] = [''] 00532 a['calready'] = False 00533 00534 a['async']=False 00535 a['selectdata'] = { 00536 0:{'value':False}, 00537 1:odict([{'value':True}, {'timerange':''}, {'uvrange':''}, {'antenna':''}, {'scan':''}])} 00538 a['multiscale'] = { 00539 0:odict([{'notvalue':[]}, {'negcomponent':-1}])} 00540 a['mode'] = { 00541 0:{'value':'mfs'}, 00542 1:odict([{'value':'channel'}, {'nchan':-11}, {'start':0}, {'width':1}]), 00543 2:odict([{'value':'velocity'}, {'nchan':1}, {'start':'0.0km/s'}, {'width':'1km/s'}]), 00544 3:odict([{'value':'frequency'}, {'nchan':1}, {'start':'1.4GHz'}, {'width':'10kHz'}])} 00545 a['weighting'] = { 00546 0:{'value':'natural'}, 00547 1:{'value':'uniform'}, 00548 2:odict([{'value':'briggs'}, {'robust':0.0}, {'npixels':0}]), 00549 3:odict([{'value':'briggsabs'}, {'robust':0.0}, {'noise':'1.0Jy'}, {'npixels':0}]), 00550 4:odict([{'value':'superuniform'}, {'npixels':0}])} 00551 a['uvtaper'] = { 00552 0:{'value':False}, 00553 1:odict([{'value':True}, {'outertaper':[]}, {'innertaper':[]}])} 00554 a['interactive'] = { 00555 0:{'value':False}, 00556 1:odict([{'value':True}, {'npercycle':100}])} 00557 a['ftmachine'] = { 00558 0:odict([{'value':'wproject'}, {'wprojplanes':256}, {'facets':1}]), 00559 1:odict([{'value':'ft'}, {'facets':1}])} 00560 00561 ### This function sets the default values but also will return the list of 00562 ### parameters or the default value of a given parameter 00563 if(param == None): 00564 myf['__set_default_parameters'](a) 00565 elif(param == 'paramkeys'): 00566 return a.keys() 00567 else: 00568 if(a.has_key(param)): 00569 #if(type(a[param]) == dict) : 00570 # return a[param][len(a[param])-1]['value'] 00571 #else : 00572 return a[param] 00573 00574 00575 # 00576 # 00577 def check_params(self, param=None, value=None): 00578 a=inspect.stack() 00579 stacklevel=0 00580 for k in range(len(a)): 00581 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00582 stacklevel=k 00583 break 00584 myf=sys._getframe(stacklevel).f_globals 00585 00586 # print 'param:', param, 'value:', value 00587 try : 00588 if str(type(value)) != "<type 'instance'>" : 00589 value0 = value 00590 value = myf['cu'].expandparam(param, value) 00591 matchtype = False 00592 if(type(value) == numpy.ndarray): 00593 if(type(value) == type(value0)): 00594 myf[param] = value.tolist() 00595 else: 00596 #print 'value:', value, 'value0:', value0 00597 #print 'type(value):', type(value), 'type(value0):', type(value0) 00598 myf[param] = value0 00599 if type(value0) != list : 00600 matchtype = True 00601 else : 00602 myf[param] = value 00603 value = myf['cu'].verifyparam({param:value}) 00604 if matchtype: 00605 value = False 00606 except Exception, instance: 00607 #ignore the exception and just return it unchecked 00608 myf[param] = value 00609 return value 00610 00611 # 00612 # 00613 def description(self, key='widefield', subkey=None): 00614 desc={'widefield': 'Wide-field imaging and deconvolution with selected algorithm', 00615 'vis': 'name of input visibility file', 00616 'imagename': 'Pre-name of output images', 00617 'outlierfile': 'Text file with image names, sizes, centers', 00618 'field': 'Field Name', 00619 'spw': 'Spectral windows:channels: \'\' is all ', 00620 'selectdata': 'Other data selection parameters', 00621 'timerange': 'Range of time to select from data', 00622 'uvrange': 'Select data within uvrange ', 00623 'antenna': 'Select data based on antenna/baseline', 00624 'scan': 'scan number range', 00625 'mode': 'Type of selection (mfs, channel, velocity, frequency)', 00626 'niter': 'Maximum number of iterations', 00627 'gain': 'Loop gain for cleaning', 00628 'threshold': 'Flux level to stop cleaning. Must include units', 00629 'psfmode': 'Algorithm to use (clark, hogbom) ', 00630 'ftmachine': 'Gridding method for the image (wproject, ft)', 00631 'facets': 'Number of facets along each axis in main image only', 00632 'wprojplanes': 'Number of planes to use in wprojection convolutiuon function', 00633 'multiscale': 'set deconvolution scales (pixels), default: multiscale=[]', 00634 'negcomponent': 'Stop cleaning if the largest scale finds this number of neg components', 00635 'interactive': 'use interactive clean (with GUI viewer)', 00636 'mask': 'cleanbox(es), mask image(s), and/or region(s) ', 00637 'nchan': 'Number of channels (planes) in output image', 00638 'start': 'First channel in input to use', 00639 'width': 'Number of input channels to average', 00640 'imsize': 'Image size in pixels (nx,ny), single value okay', 00641 'cell': 'The image cell size in arcseconds [x,y], single value okay. ', 00642 'phasecenter': 'Field Identififier or direction of the image phase center', 00643 'restfreq': 'rest frequency to assign to image (see help)', 00644 'stokes': 'Stokes params to image (I,IV,QU,IQUV,RR,LL,XX,YY,RRLL,XXYY)', 00645 'weighting': 'Weighting to apply to visibilities', 00646 'robust': 'Briggs robustness parameter', 00647 'npixels': 'number of pixels to determine cell size for superuniform or briggs weighting', 00648 'noise': 'noise parameter for briggs abs mode weighting', 00649 'cyclefactor': 'Threshold for minor/major cycles (see pdoc)', 00650 'cyclespeedup': 'Cycle threshold doubles in this number of iterations', 00651 'npercycle': 'Number of iterations before interactive masking prompt', 00652 'uvtaper': 'Apply additional uv tapering of visibilities.', 00653 'outertaper': 'uv-taper on outer baselines in uv-plane', 00654 'innertaper': 'uv-taper in center of uv-plane', 00655 'restoringbeam': 'Output Gaussian restoring beam for CLEAN image', 00656 'calready': 'Create scratch columns and store model visibilities so that selfcal can be run after clean', 00657 00658 'async': 'If true the taskname must be started using widefield(...)' 00659 } 00660 00661 # 00662 # Set subfields defaults if needed 00663 # 00664 if(subkey == 'channel'): 00665 desc['start'] = 'first channel in image relative to data channels' 00666 if(subkey == 'velocity'): 00667 desc['start'] = 'Velocity of first image channel: e.g \'0.0km/s\'' 00668 if(subkey == 'velocity'): 00669 desc['width'] = 'image channel width in velocity units: e.g \'-1.0km/s\'' 00670 if(subkey == 'frequency'): 00671 desc['start'] = 'Frequency of first image channel: e.q. \'1.4GHz\'' 00672 if(subkey == 'frequency'): 00673 desc['width'] = 'Image channel width in frequency units: e.g \'10kHz\'' 00674 if(subkey == 'briggs'): 00675 desc['npixels'] = 'number of pixels to determine uv-cell size 0=> field of view' 00676 if(subkey == 'briggsabs'): 00677 desc['npixels'] = 'number of pixels to determine uv-cell size 0=> field of view' 00678 if(subkey == 'superuniform'): 00679 desc['npixels'] = 'number of pixels to determine uv-cell size 0=> +/-3pixels' 00680 00681 if(desc.has_key(key)) : 00682 return desc[key] 00683 00684 def itsdefault(self, paramname) : 00685 a = {} 00686 a['vis'] = [''] 00687 a['imagename'] = '', 00688 a['outlierfile'] = '' 00689 a['field'] = '' 00690 a['spw'] = '' 00691 a['selectdata'] = False 00692 a['timerange'] = '' 00693 a['uvrange'] = '' 00694 a['antenna'] = '' 00695 a['scan'] = '' 00696 a['mode'] = 'mfs' 00697 a['niter'] = 500 00698 a['gain'] = 0.1 00699 a['threshold'] = '0.0Jy' 00700 a['psfmode'] = 'clark' 00701 a['ftmachine'] = '' 00702 a['facets'] = 3 00703 a['wprojplanes'] = 64 00704 a['multiscale'] = [] 00705 a['negcomponent'] = 0 00706 a['interactive'] = False 00707 a['mask'] = [] 00708 a['nchan'] = 1 00709 a['start'] = 0 00710 a['width'] = 1 00711 a['imsize'] = [256, 256] 00712 a['cell'] = ['1.0arcsec', '1.0arcsec'] 00713 a['phasecenter'] = '' 00714 a['restfreq'] = '' 00715 a['stokes'] = 'I' 00716 a['weighting'] = 'natural' 00717 a['robust'] = 0.0 00718 a['npixels'] = 0 00719 a['noise'] = '1.0Jy' 00720 a['cyclefactor'] = 1.5 00721 a['cyclespeedup'] = -1 00722 a['npercycle'] = 100 00723 a['uvtaper'] = False 00724 a['outertaper'] = [''] 00725 a['innertaper'] = ['1.0'] 00726 a['restoringbeam'] = [''] 00727 a['calready'] = False 00728 00729 if a.has_key(paramname) : 00730 return a[paramname] 00731 widefield_pg = widefield_pg_()