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