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_mosaic import mosaic 00016 from task_mosaic import casalog 00017 00018 class mosaic_pg_: 00019 __name__ = "mosaic" 00020 00021 def __init__(self) : 00022 self.__bases__ = (mosaic_pg_,) 00023 self.__doc__ = self.__call__.__doc__ 00024 00025 00026 def __call__(self, vis=None, imagename=None, mode=None, alg=None, imsize=None, cell=None, phasecenter=None, stokes=None, niter=None, gain=None, threshold=None, mask=None, cleanbox=None, nchan=None, start=None, width=None, field=None, spw=None, timerange=None, restfreq=None, sdimage=None, modelimage=None, weighting=None, mosweight=None, rmode=None, robust=None, ftmachine=None, cyclefactor=None, cyclespeedup=None, scaletype=None, minpb=None, sigma=None, targetflux=None, constrainflux=None, prior=None, negcomponent=None, scales=None, npercycle=None, npixels=None, noise=None, async=None): 00027 00028 """Create a multi-field deconvolved image with selected algorithm 00029 00030 00031 Two types of point-source deconvolution, as well as multi-scale 00032 deconvolution, are available. A continuum image (mfs) is produced 00033 by gridding together all spectral data. Individual channels or 00034 groups of channels can also be images and then placed in an output 00035 image cube. 00036 00037 The cleaning regions can be specified by an input mask image, from a 00038 file containing rectangular regions, or interactively as the 00039 deconvolution progresses. 00040 00041 The mosaic task only uses the "corrected" datacolumn which is made 00042 from the "data" data column using applycal with the appropriate 00043 calibration tables. Many Stokes combinations are available. 00044 00045 00046 Keyword arguments: 00047 vis -- Name of input visibility file 00048 default: none; example: vis='ngc5921.ms' 00049 imagename -- Pre-name of output images: 00050 default: none; example: imagename='m2' 00051 output images are: 00052 m2.image; cleaned and restored image 00053 m2.flux; relative sky sensitivity over field 00054 m2.model; image of clean components 00055 m2.residual; image of residuals 00056 m2.interactive.mask; image containing clean regions 00057 mode -- Frequency Specification: 00058 NOTE: See examples below: 00059 default: 'mfs' 00060 mode = 'mfs' means produce one image from all specified data. 00061 mode = 'channel'; Use with nchan, start, width to specify 00062 output image cube. See examples below 00063 mode = 'velocity', means channels are specified in velocity. 00064 mode = 'frequency', means channels are specified in frequency. 00065 >>> mode expandable parameters (for modes other than 'mfs') 00066 Start, width are given in units of channels, frequency or velocity 00067 as indicated by mode, but only channel is complete. 00068 nchan -- Number of channels (planes) in output image 00069 default: 1; example: nchan=3 00070 start -- Start input channel (relative-0) 00071 default=0; example: start=5 00072 width -- Output channel width (>1 indicates channel averaging) 00073 default=1; example: width=4 00074 examples: 00075 spw = '0,1'; mode = 'mfs' 00076 will produce one image made from all channels in spw 0 and 1 00077 spw='0:5~28^2'; mode = 'mfs' 00078 will produce one image made with channels (5,7,9,...,25,27) 00079 spw = '0'; mode = 'channel': nchan=3; start=5; width=4 00080 will produce an image with 3 output planes 00081 plane 1 contains data from channels (5+6+7+8) 00082 plane 2 contains data from channels (9+10+11+12) 00083 plane 3 contains data from channels (13+14+15+16) 00084 spw = '0:0~63^3'; mode=chann; nchan=21; start = 0; width = 1 00085 will produce an image with 20 output planes 00086 Plane 1 contains data from channel 0 00087 Plane 2 contains date from channel 2 00088 Plane 21 contains data from channel 61 00089 spw = '0:0~40^2'; mode = 'channel'; nchan = 3; start = 5; width = 4 00090 will produce an image with three output planes 00091 plane 1 contains channels (5,7) 00092 plane 2 contains channels (13,15) 00093 plane 3 contains channels (21,23) 00094 alg -- Algorithm to use (expandable): 00095 default: 'clark': Options: 'clark','hogbom','multiscale','entropy' 00096 'hogbom' Cleans from the images only. Only inner quarter 00097 of image is cleaned 00098 'clark' Cleans from gridded us data. Only inner quarter of 00099 image is cleaned 00100 'multiscale' cleans with several resolutions using hobgom clean 00101 Currently much slower than single resolution. For extended 00102 sources, try single resolution with interactive and 00103 'entropy' Maximum entropy algorithm is still experimental 00104 and not recommended for general use 00105 >>> multiscale expandable parameter 00106 scales -- in pixel numbers; the size of component to deconvolve 00107 default = [0,3,10] 00108 recommended sizes are 0 (point), 3 (points per clean beam), and 00109 10 (about a factor of three lower resolution) 00110 negcomponent' -- Stop component search when the largest 00111 scale has found this number of negative components; -1 means 00112 continue component search even if the largest component is 00113 negative. 00114 default: 2; example: negcomponent=-1 00115 >>> entropy (MEM) expandable parameters (experimental) 00116 sigma -- Target image sigma 00117 default: '0.001Jy'; example: sigma='0.1Jy' 00118 targetflux -- Target flux for final image 00119 default: '1.0Jy'; example: targetflux='200Jy' 00120 constrainflux -- Constrain image to match target flux; 00121 otherwise, targetflux is used to initialize model only. 00122 default: False; example: constrainflux=True 00123 prior -- Name of MEM prior images 00124 default: ['']; example: prior='source_mem.image' 00125 imsize -- Image pixel size (x,y) 00126 default = [256,256]; example: imsize=[350,350] 00127 imsize = 500 is equivalent to [500,500] 00128 cell -- Cell size (x,y) 00129 default= none; 00130 example: cell=['0.5arcsec,'0.5arcsec'] or 00131 cell=['1arcmin', '1arcmin'] 00132 cell = '1arcsec' is equivalent to ['1arcsec','1arcsec'] 00133 NOTE:cell = '2' makes default cell size of 2 radians! 00134 phasecenter -- direction measure or fieldid for the mosaic center 00135 default: 0 (imply field=0 as center); example: phasecenter=6 00136 or phasecenter='J2000 19h30m00 -40d00m00' 00137 stokes -- Stokes parameters to image 00138 default='I'; example: stokes='IQUV'; 00139 Options: 'I','IV''QU','IQUV','RR','LL','XX','YY','RRLL','XXYY' 00140 niter -- Maximum number iterations, set to zero for no CLEANing 00141 default: 500; example: niter=500 00142 gain -- Loop gain for CLEANing 00143 default: 0.1; example: gain=0.5 00144 threshold -- Flux level at which to stop CLEANing (units=mJy) 00145 default: 0.0; example: threshold=0.0 00146 mask -- Name of mask image used for CLEANing 00147 default '' means no mask; 00148 example: mask='orion.mask'. 00149 It is useful to use a mask from a previous interactive mosaic 00150 session for a new execution. The mask image shape 00151 must be the same as the new mosaic. 00152 cleanbox -- Cleaning region: 00153 default: [] defaults to inner quarter of image 00154 Three specification types: 00155 (a) 'interactive' allows the user to build the cleaning 00156 mask interactively using the viewer. The viewer will 00157 appear every npercycle interation, but modify as needed 00158 The final interactive maks is saved in the file 00159 imagename_interactive.mask. 00160 (b) Explicit pixel ranges 00161 example: cleanbox=[110,110,150,145] 00162 clean region with blc=110,100; trc=150,145 (pixel values) 00163 Only one clean region can be given this way. 00164 (c) Filename with pixel values with ascii format: 00165 <fieldindex blc-x blc-y trc-x trc-y> on each line 00166 1 45 66 123 124 00167 2 23 100 300 340 00168 >>> 'interactive' expandable parameter 00169 npercycle -- this is the number of iterations between each clean 00170 to update mask interactively. Set to about niter/5, can also 00171 be changed interactively. 00172 field -- Select fields in mosaic. Use field id(s) or field name(s). 00173 ['go listobs' to obtain the list id's or names] 00174 default: ''=all fields 00175 If field string is a non-negative integer, it is assumed to 00176 be a field index otherwise, it is assumed to be a field name 00177 field='0~2'; field ids 0,1,2 00178 field='0,4,5~7'; field ids 0,4,5,6,7 00179 field='3C286,3C295'; field named 3C286 and 3C295 00180 field = '3,4C*'; field id 3, all names starting with 4C 00181 spw -- Select spectral window/channels 00182 NOTE: This selects the data passed as the INPUT to mode 00183 default: ''=all spectral windows and channels 00184 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00185 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00186 spw='0:5~61'; spw 0, channels 5 to 61 00187 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00188 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00189 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00190 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10, 00191 spw 1, channels 20-30, and spw 2, channels, 1,2 and 3 00192 timerange -- Time range: 00193 default = '' (all); examples, 00194 selectime = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00195 Note: if YYYY/MM/DD is missing date defaults to first day 00196 in data set 00197 timerange='09:14:0~09:54:0' picks 40 min on first day 00198 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00199 timerange='09:44:00' data within one integration of time 00200 timerange='>10:24:00' data after this time 00201 restfreq -- Specify rest frequency to use for image 00202 default='' 00203 Occasionally it is necessary to set this (for example some VLA 00204 spectral line data). For example for 00205 NH_3 (1,1) put restfreq='23.694496GHz' 00206 sdimage -- Input Single Dish image to use for model 00207 default='' (no image); example: sdimage='n4826_12mchan.im' 00208 modelimage -- Name of output(/input) model image 00209 default='' (none=imagename.model); modelimage='orion.model' 00210 Note: This specifies the output model if a single dish 00211 image is input or the output model name from the imaging 00212 weighting -- Weighting to apply to visibilities: 00213 default='natural'; example: weighting='uniform'; 00214 Options: 'natural','uniform','briggs','radial', 'superuniform' 00215 >>> Weighting expandable parameters 00216 For weighting='briggs' 00217 rmode -- Robustness mode (see help mosaic) 00218 default='norm'; example='abs'; 00219 Options: 'norm','abs','none' 00220 robust -- Brigg's robustness parameter 00221 default=0.0; example: robust=0.5; 00222 Options: -2.0 to 2.0; -2 (uniform)/+2 (natural) 00223 noise -- noise parameter to use for rmode='abs' in 00224 briggs weighting 00225 example noise='1.0mJy' 00226 For superuniform/briggs weighting 00227 npixels -- number of pixels to determine uv-cell size 00228 for weight calculation 00229 example npixels=7 00230 mosweight -- Individually weight the fields of the mosaic 00231 default: False; example: mosweight=True 00232 This can be useful if some of your fields are more 00233 sensitive than others (i.e. due to time spent on-source); 00234 this parameter will give more weight to higher sensitivity 00235 fields in the overlap regions. 00236 ftmachine -- Gridding method for the image; 00237 Options: ft (standard interferometric gridding), sd 00238 (standard single dish) both (ft and sd as appropriate), 00239 mosaic (gridding use PB as convolution function) 00240 default: 'mosaic'; example: ftmachine='ft' 00241 cyclefactor -- Change the threshold at which the deconvolution cycle will 00242 stop, degrid and subtract from the visibilities. For poor PSFs, 00243 reconcile often (cyclefactor=4 or 5); For good PSFs, use 00244 cyclefactor 1.5 to 2.0. 00245 default: 1.5; example: cyclefactor=4 00246 cycle threshold = cyclefactor * max sidelobe * max residual 00247 cyclespeedup -- Cycle threshold doubles in this number of iterations 00248 default: -1; example: cyclespeedup=500 00249 scaletype -- Controls scaling of pixels in the image plane. 00250 default='SAULT'; example: scaletype='PBCOR' 00251 Options: 'PBCOR','SAULT' 00252 'SAULT' scale makes an output image where the noise is constant 00253 across the whole mosaic. However, the image is NOT 00254 corrected for the PB pattern, and therefore is not "flux 00255 correct". Division of the SAULT image_name.image image 00256 by the image_name.flux image will produce a "flux correct image". 00257 The 'PBCOR' option uses the SAULT scaling scheme for 00258 deconvolution, but when interactively cleaning shows the 00259 primary beam corrected image; the final PBCOR image is "flux 00260 correct" 00261 minpb -- Minimum PB level to use 00262 default=0.1; example: minpb=0.01 00263 async -- Run asynchronously 00264 default = False; do not run asychronously 00265 00266 """ 00267 a=inspect.stack() 00268 stacklevel=0 00269 for k in range(len(a)): 00270 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00271 stacklevel=k 00272 break 00273 myf=sys._getframe(stacklevel).f_globals 00274 myf['__last_task'] = 'mosaic' 00275 myf['taskname'] = 'mosaic' 00276 ### 00277 myf['update_params'](func=myf['taskname'],printtext=False) 00278 ### 00279 ### 00280 #Handle globals or user over-ride of arguments 00281 # 00282 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00283 useLocalDefaults = False 00284 00285 for item in function_signature_defaults.iteritems(): 00286 key,val = item 00287 keyVal = eval(key) 00288 if (keyVal == None): 00289 #user hasn't set it - use global/default 00290 pass 00291 else: 00292 #user has set it - use over-ride 00293 if (key != 'self') : 00294 useLocalDefaults = True 00295 #myf[key]=keyVal 00296 00297 myparams = {} 00298 if useLocalDefaults : 00299 for item in function_signature_defaults.iteritems(): 00300 key,val = item 00301 keyVal = eval(key) 00302 exec('myparams[key] = keyVal') 00303 if (keyVal == None): 00304 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00305 keyVal = eval(key) 00306 if(type(keyVal) == dict) : 00307 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00308 00309 else : 00310 uselessvariable = None 00311 myparams['vis'] = vis = myf['vis'] 00312 myparams['imagename'] = imagename = myf['imagename'] 00313 myparams['mode'] = mode = myf['mode'] 00314 myparams['alg'] = alg = myf['alg'] 00315 myparams['imsize'] = imsize = myf['imsize'] 00316 myparams['cell'] = cell = myf['cell'] 00317 myparams['phasecenter'] = phasecenter = myf['phasecenter'] 00318 myparams['stokes'] = stokes = myf['stokes'] 00319 myparams['niter'] = niter = myf['niter'] 00320 myparams['gain'] = gain = myf['gain'] 00321 myparams['threshold'] = threshold = myf['threshold'] 00322 myparams['mask'] = mask = myf['mask'] 00323 myparams['cleanbox'] = cleanbox = myf['cleanbox'] 00324 myparams['nchan'] = nchan = myf['nchan'] 00325 myparams['start'] = start = myf['start'] 00326 myparams['width'] = width = myf['width'] 00327 myparams['field'] = field = myf['field'] 00328 myparams['spw'] = spw = myf['spw'] 00329 myparams['timerange'] = timerange = myf['timerange'] 00330 myparams['restfreq'] = restfreq = myf['restfreq'] 00331 myparams['sdimage'] = sdimage = myf['sdimage'] 00332 myparams['modelimage'] = modelimage = myf['modelimage'] 00333 myparams['weighting'] = weighting = myf['weighting'] 00334 myparams['mosweight'] = mosweight = myf['mosweight'] 00335 myparams['rmode'] = rmode = myf['rmode'] 00336 myparams['robust'] = robust = myf['robust'] 00337 myparams['ftmachine'] = ftmachine = myf['ftmachine'] 00338 myparams['cyclefactor'] = cyclefactor = myf['cyclefactor'] 00339 myparams['cyclespeedup'] = cyclespeedup = myf['cyclespeedup'] 00340 myparams['scaletype'] = scaletype = myf['scaletype'] 00341 myparams['minpb'] = minpb = myf['minpb'] 00342 myparams['sigma'] = sigma = myf['sigma'] 00343 myparams['targetflux'] = targetflux = myf['targetflux'] 00344 myparams['constrainflux'] = constrainflux = myf['constrainflux'] 00345 myparams['prior'] = prior = myf['prior'] 00346 myparams['negcomponent'] = negcomponent = myf['negcomponent'] 00347 myparams['scales'] = scales = myf['scales'] 00348 myparams['npercycle'] = npercycle = myf['npercycle'] 00349 myparams['npixels'] = npixels = myf['npixels'] 00350 myparams['noise'] = noise = myf['noise'] 00351 00352 if type(imsize)==int: imsize=[imsize] 00353 if type(cell)==float: cell=[cell] 00354 if type(mask)==str: mask=[mask] 00355 if type(prior)==str: prior=[prior] 00356 if type(scales)==int: scales=[scales] 00357 00358 result = None 00359 00360 # 00361 # The following is work around to avoid a bug with current python translation 00362 # 00363 mytmp = {} 00364 00365 mytmp['vis'] = vis 00366 mytmp['imagename'] = imagename 00367 mytmp['mode'] = mode 00368 mytmp['alg'] = alg 00369 mytmp['imsize'] = imsize 00370 if type(cell) == str : 00371 mytmp['cell'] = casac.quanta().quantity(cell) 00372 else : 00373 mytmp['cell'] = cell 00374 mytmp['phasecenter'] = phasecenter 00375 mytmp['stokes'] = stokes 00376 mytmp['niter'] = niter 00377 mytmp['gain'] = gain 00378 mytmp['threshold'] = threshold 00379 mytmp['mask'] = mask 00380 mytmp['cleanbox'] = cleanbox 00381 mytmp['nchan'] = nchan 00382 mytmp['start'] = start 00383 mytmp['width'] = width 00384 mytmp['field'] = field 00385 mytmp['spw'] = spw 00386 mytmp['timerange'] = timerange 00387 mytmp['restfreq'] = restfreq 00388 mytmp['sdimage'] = sdimage 00389 mytmp['modelimage'] = modelimage 00390 mytmp['weighting'] = weighting 00391 mytmp['mosweight'] = mosweight 00392 mytmp['rmode'] = rmode 00393 mytmp['robust'] = robust 00394 mytmp['ftmachine'] = ftmachine 00395 mytmp['cyclefactor'] = cyclefactor 00396 mytmp['cyclespeedup'] = cyclespeedup 00397 mytmp['scaletype'] = scaletype 00398 mytmp['minpb'] = minpb 00399 if type(sigma) == str : 00400 mytmp['sigma'] = casac.quanta().quantity(sigma) 00401 else : 00402 mytmp['sigma'] = sigma 00403 if type(targetflux) == str : 00404 mytmp['targetflux'] = casac.quanta().quantity(targetflux) 00405 else : 00406 mytmp['targetflux'] = targetflux 00407 mytmp['constrainflux'] = constrainflux 00408 mytmp['prior'] = prior 00409 mytmp['negcomponent'] = negcomponent 00410 mytmp['scales'] = scales 00411 mytmp['npercycle'] = npercycle 00412 mytmp['npixels'] = npixels 00413 if type(noise) == str : 00414 mytmp['noise'] = casac.quanta().quantity(noise) 00415 else : 00416 mytmp['noise'] = noise 00417 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00418 trec = casac.utils().torecord(pathname+'mosaic.xml') 00419 00420 casalog.origin('mosaic') 00421 if not trec.has_key('mosaic') or not casac.utils().verify(mytmp, trec['mosaic']) : 00422 return False 00423 00424 00425 try : 00426 casalog.post('') 00427 casalog.post('##########################################') 00428 casalog.post('##### Begin Task: mosaic #####') 00429 casalog.post('') 00430 result = 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) 00431 casalog.post('') 00432 casalog.post('##### End Task: mosaic #####') 00433 casalog.post('##########################################') 00434 00435 00436 # saveinputs for individule engine has no use 00437 # saveinputs should alos be removed from casa_in_py.py 00438 # 00439 # 00440 # saveinputs = myf['saveinputs'] 00441 # saveinputs('mosaic', 'mosaic.last', myparams) 00442 # 00443 # 00444 except Exception, instance: 00445 #print '**** Error **** ',instance 00446 pass 00447 00448 gc.collect() 00449 return result 00450 # 00451 # 00452 ## 00453 # def paramgui(self, useGlobals=True): 00454 # """ 00455 # Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00456 # """ 00457 # import paramgui 00458 # 00459 # a=inspect.stack() 00460 # stacklevel=0 00461 # for k in range(len(a)): 00462 # if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00463 # stacklevel=k 00464 # break 00465 # myf = sys._getframe(stacklevel).f_globals 00466 # 00467 # if useGlobals: 00468 # paramgui.setGlobals(myf) 00469 # else: 00470 # paramgui.setGlobals({}) 00471 # 00472 # paramgui.runTask('mosaic', myf['_ip']) 00473 # paramgui.setGlobals({}) 00474 # 00475 # 00476 # 00477 # 00478 def defaults(self, param=None): 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 a = odict() 00487 a['vis'] = '' 00488 a['imagename'] = '' 00489 a['mode'] = 'mfs' 00490 a['alg'] = 'clark' 00491 a['imsize'] = [256, 256] 00492 a['cell'] = ['1.0arcsec', '1.0arcsec'] 00493 a['phasecenter'] = '' 00494 a['stokes'] = 'I' 00495 a['niter'] = 500 00496 a['gain'] = 0.1 00497 a['threshold'] = 0.0 00498 a['mask'] = [''] 00499 a['cleanbox'] = [] 00500 a['field'] = '' 00501 a['spw'] = '' 00502 a['timerange'] = '' 00503 a['restfreq'] = '' 00504 a['sdimage'] = '' 00505 a['modelimage'] = '' 00506 a['weighting'] = 'natural' 00507 a['mosweight'] = False 00508 a['ftmachine'] = 'mosaic' 00509 a['cyclefactor'] = 1.5 00510 a['cyclespeedup'] = -1 00511 a['scaletype'] = 'SAULT' 00512 a['minpb'] = 0.1 00513 00514 a['async']=False 00515 a['mode'] = { 00516 0:{'value':'mfs'}, 00517 1:odict([{'value':'channel'}, {'nchan':1}, {'start':0}, {'width':1}]), 00518 2:odict([{'value':'velocity'}, {'nchan':1}, {'start':'0.0km/s'}, {'width':'1km/s'}]), 00519 3:odict([{'value':'frequency'}, {'nchan':1}, {'start':'1.4GHz'}, {'width':'10kHz'}])} 00520 a['alg'] = { 00521 0:{'value':'clark'}, 00522 1:{'value':'hogbom'}, 00523 2:odict([{'value':'multiscale'}, {'scales':[0, 3, 10]}, {'negcomponent':2}]), 00524 3:odict([{'value':'entropy'}, {'sigma':0.01}, {'targetflux':1.0}, {'constrainflux':False}, {'prior':['']}]), 00525 4:{'value':'emptiness'}} 00526 a['weighting'] = { 00527 0:{'value':'natural'}, 00528 1:{'value':'uniform'}, 00529 2:odict([{'value':'briggs'}, {'rmode':'none'}, {'robust':0.0}, {'noise':0.0}, {'npixels':0}]), 00530 3:odict([{'value':'superuniform'}, {'npixels':0}])} 00531 a['cleanbox'] = { 00532 0:{'value':[]}, 00533 1:odict([{'value':'interactive'}, {'npercycle':100}])} 00534 00535 ### This function sets the default values but also will return the list of 00536 ### parameters or the default value of a given parameter 00537 if(param == None): 00538 myf['__set_default_parameters'](a) 00539 elif(param == 'paramkeys'): 00540 return a.keys() 00541 else: 00542 if(a.has_key(param)): 00543 #if(type(a[param]) == dict) : 00544 # return a[param][len(a[param])-1]['value'] 00545 #else : 00546 return a[param] 00547 00548 00549 # 00550 # 00551 def check_params(self, param=None, value=None): 00552 a=inspect.stack() 00553 stacklevel=0 00554 for k in range(len(a)): 00555 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00556 stacklevel=k 00557 break 00558 myf=sys._getframe(stacklevel).f_globals 00559 00560 # print 'param:', param, 'value:', value 00561 try : 00562 if str(type(value)) != "<type 'instance'>" : 00563 value0 = value 00564 value = myf['cu'].expandparam(param, value) 00565 matchtype = False 00566 if(type(value) == numpy.ndarray): 00567 if(type(value) == type(value0)): 00568 myf[param] = value.tolist() 00569 else: 00570 #print 'value:', value, 'value0:', value0 00571 #print 'type(value):', type(value), 'type(value0):', type(value0) 00572 myf[param] = value0 00573 if type(value0) != list : 00574 matchtype = True 00575 else : 00576 myf[param] = value 00577 value = myf['cu'].verifyparam({param:value}) 00578 if matchtype: 00579 value = False 00580 except Exception, instance: 00581 #ignore the exception and just return it unchecked 00582 myf[param] = value 00583 return value 00584 00585 # 00586 # 00587 def description(self, key='mosaic', subkey=None): 00588 desc={'mosaic': 'Create a multi-field deconvolved image with selected algorithm', 00589 'vis': 'name of input visibility file', 00590 'imagename': 'Pre-name of output images', 00591 'mode': 'Type of selection (mfs, channel, velocity, frequency)', 00592 'alg': 'Algorithm to use (clark, hogbom, multiscale) ', 00593 'imsize': 'Image size in pixels (nx,ny), symmetric for single value', 00594 'cell': 'The image cell size in arcseconds [x,y]. ', 00595 'phasecenter': 'Field Identififier or direction of the image phase center', 00596 'stokes': 'Stokes params to image (I,IV,QU,IQUV,RR,LL,XX,YY,RRLL,XXYY)', 00597 'niter': 'Maximum number of iterations', 00598 'gain': 'Loop gain for cleaning', 00599 'threshold': 'Flux level to stop cleaning (unit mJy assumed)', 00600 'mask': 'Set of mask images used in cleaning', 00601 'cleanbox': 'clean box regions or file name or \'interactive\'', 00602 'nchan': 'Number of channels in output image', 00603 'start': 'Start channel', 00604 'width': 'Channel width (value > 1 indicates channel averaging)', 00605 'field': 'Field Name', 00606 'spw': 'Spectral windows:channels: \'\' is all ', 00607 'timerange': 'Range of time to select from data', 00608 'restfreq': 'rest frequency to use in image', 00609 'sdimage': 'Input single dish image to use for model', 00610 'modelimage': 'Name of output(/input) model image', 00611 'weighting': 'Weighting to apply to visibilities', 00612 'mosweight': 'Individually weight the fields of the mosaic', 00613 'rmode': 'Robustness mode (for Briggs weightting)', 00614 'robust': 'Briggs robustness parameter', 00615 'ftmachine': 'Gridding method for the image', 00616 'cyclefactor': 'Threshold for minor/major cycles (see pdoc)', 00617 'cyclespeedup': 'Cycle threshold doubles in this number of iterations', 00618 'scaletype': 'Controls scaling of pixels in the image plane', 00619 'minpb': 'Minimum PB level to use', 00620 'sigma': 'Target image sigma', 00621 'targetflux': 'Target flux for final image', 00622 'constrainflux': 'Constrain image to match target flux ', 00623 'prior': 'Name of MEM prior images', 00624 'negcomponent': 'Stop the component search when the largest scale has found this number of negative components', 00625 'scales': 'resolutions in pixel units', 00626 'npercycle': 'Number of iterations before interactive masking prompt', 00627 'npixels': 'number of pixels to determine cell size for superuniform or briggs weighting', 00628 'noise': 'noise parameter for briggs weighting when rmode=\'abs\'', 00629 00630 'async': 'If true the taskname must be started using mosaic(...)' 00631 } 00632 00633 # 00634 # Set subfields defaults if needed 00635 # 00636 if(subkey == 'channel'): 00637 desc['start'] = 'first channel in image relative to data channels' 00638 if(subkey == 'velocity'): 00639 desc['start'] = 'Velocity of first image channel: e.g \'0.0km/s\'' 00640 if(subkey == 'velocity'): 00641 desc['width'] = 'image channel width in velocity units: e.g \'-1.0km/s\'' 00642 if(subkey == 'frequency'): 00643 desc['start'] = 'Frequency of first image channel: e.q. \'1.4GHz\'' 00644 if(subkey == 'frequency'): 00645 desc['width'] = 'Image channel width in frequency units: e.g \'1.0kHz\'' 00646 if(subkey == 'briggs'): 00647 desc['npixels'] = 'number of pixels to determine uv-cell size 0=> field of view' 00648 if(subkey == 'superuniform'): 00649 desc['npixels'] = 'number of pixels to determine uv-cell size 0=> +/-3pixels' 00650 00651 if(desc.has_key(key)) : 00652 return desc[key] 00653 00654 def itsdefault(self, paramname) : 00655 a = {} 00656 a['vis'] = '' 00657 a['imagename'] = '' 00658 a['mode'] = 'mfs' 00659 a['alg'] = 'clark' 00660 a['imsize'] = [256, 256] 00661 a['cell'] = ['1.0arcsec', '1.0arcsec'] 00662 a['phasecenter'] = '' 00663 a['stokes'] = 'I' 00664 a['niter'] = 500 00665 a['gain'] = 0.1 00666 a['threshold'] = 0.0 00667 a['mask'] = [''] 00668 a['cleanbox'] = [] 00669 a['nchan'] = 1 00670 a['start'] = 0 00671 a['width'] = 1 00672 a['field'] = '' 00673 a['spw'] = '' 00674 a['timerange'] = '' 00675 a['restfreq'] = '' 00676 a['sdimage'] = '' 00677 a['modelimage'] = '' 00678 a['weighting'] = 'natural' 00679 a['mosweight'] = False 00680 a['rmode'] = 'norm' 00681 a['robust'] = 0.0 00682 a['ftmachine'] = 'mosaic' 00683 a['cyclefactor'] = 1.5 00684 a['cyclespeedup'] = -1 00685 a['scaletype'] = 'SAULT' 00686 a['minpb'] = 0.1 00687 a['sigma'] = '0.001Jy' 00688 a['targetflux'] = '1.0Jy' 00689 a['constrainflux'] = False 00690 a['prior'] = [''] 00691 a['negcomponent'] = 2 00692 a['scales'] = [0, 3, 10] 00693 a['npercycle'] = 100 00694 a['npixels'] = 0 00695 a['noise'] = '0.0Jy' 00696 00697 if a.has_key(paramname) : 00698 return a[paramname] 00699 mosaic_pg = mosaic_pg_()