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_listvis import listvis 00016 from task_listvis import casalog 00017 00018 class listvis_pg_: 00019 __name__ = "listvis" 00020 00021 def __init__(self) : 00022 self.__bases__ = (listvis_pg_,) 00023 self.__doc__ = self.__call__.__doc__ 00024 00025 00026 def __call__(self, vis=None, options=None, datacolumn=None, field=None, spw=None, selectdata=None, antenna=None, timerange=None, correlation=None, scan=None, feed=None, array=None, observation=None, uvrange=None, average=None, showflags=None, pagerows=None, listfile=None, async=None): 00027 00028 """List measurement set visibilities. 00029 00030 This task lists measurement set visibility data under a number of 00031 input selection conditions. The measurement set data columns that 00032 can be listed are: the raw data, float_data, corrected data, model data, 00033 and residual (corrected - model) data. 00034 00035 The output table format is dynamic. Field, Spectral Window, and 00036 Channel columns are not displayed if the column contents are uniform. 00037 For example, if "spw = '1'" is specified, the spw column will not be 00038 displayed. When a column is not displayed, a message is sent to the 00039 logger and terminal indicating that the column values are uniform and 00040 listing the uniform value. 00041 00042 Table column descriptions: 00043 00044 COLUMN NAME DESCRIPTION 00045 ----------- ----------- 00046 Date/Time Time stamp of data sample (YYMMDD/HH:MM:SS UT) 00047 Intrf Interferometer baseline (antenna names) 00048 UVDist uv-distance (units of wavelength) 00049 Fld Field ID (if more than 1) 00050 SpW Spectral Window ID (if more than 1) 00051 Chn Channel number (if more than 1) 00052 (Correlated Correlated polarizations (eg: RR, LL, XY) 00053 polarization) Sub-columns are: Amp, Phs, Wt, F 00054 Amp Visibility amplitude 00055 Phs Visibility phase (deg) 00056 Wt Weight of visibility measurement 00057 F Flag: 'F' = flagged datum; ' ' = unflagged 00058 UVW UVW coordinates (meters) 00059 00060 00061 Input Parameters: 00062 vis Name of input visibility file 00063 default: none; example: vis='ngc5921.ms' 00064 00065 options List options: default = 'ap' 00066 Not yet implemented for suboptions 00067 00068 datacolumn Visibility file data column: 00069 default = 'data': options are 00070 data, float_data, corrected, model, residual (corrected-model) 00071 00072 field Select data based on field id(s) or name(s) 00073 default: ''==>all; example: field='1' 00074 field='0~2' field ids inclusive from 0 to 2 00075 field='3C*' all field names starting with 3C 00076 00077 spw Select spectral window, channel to list 00078 default: '0:0' --> spw=0, chan=0 00079 spw='2:34' spectral window 2, channel 34 00080 00081 selectdata Toggle the following 7 selection parameters. 00082 default: False; example: selectdata=True 00083 If false, the following parameters are reset 00084 to default values. 00085 00086 antenna Select calibration data based on antenna 00087 default: ''-->all; examples: 00088 antenna = '5,6'; antenna index 5 and 6 solutions 00089 antenna = '05,06'; antenna names '05' and '06 solutions 00090 00091 timerange Select time range to list 00092 default: ''-->all; examples: 00093 timerange='10:37:50.1'; list data for this sampling interval 00094 timerange='<10:37:25'; list data before 10:37:25 00095 00096 correlation Select polarization correlations to list 00097 default: ''-->all; examples: 00098 correlation='RR LL'; list RR and LL correlations 00099 correlation='XX XY'; list XX and XY correlations 00100 00101 scan Select scans to list 00102 default: ''-->all; examples: 00103 scan='2'; list scan 2 00104 scan='>2'; list scan numbers greater than 2 00105 00106 feed (not yet implemented) 00107 00108 array (not yet implemented) 00109 00110 observation Select by observation ID(s). 00111 default: ''-->all; 00112 example: observation='0' (select obsID 0) 00113 00114 uvrange Select baseline lengths to list. 00115 default: ''--> all; examples: 00116 uvrange='<5kl'; less than 5 kilo-wavelengths 00117 Caution: Input units default to meters. 00118 Listed units are always wavelengths. 00119 00120 average (not yet implemented) 00121 00122 showflags (not yet implemented) 00123 00124 pagerows rows per page of listing 00125 default: 50; 0 --> do not paginate 00126 00127 listfile write output to disk; will not overwrite 00128 default: '' --> write to screen 00129 listfile = 'solutions.txt' 00130 00131 async Run asynchronously 00132 default = False; do not run asychronously 00133 00134 00135 """ 00136 a=inspect.stack() 00137 stacklevel=0 00138 for k in range(len(a)): 00139 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00140 stacklevel=k 00141 break 00142 myf=sys._getframe(stacklevel).f_globals 00143 myf['__last_task'] = 'listvis' 00144 myf['taskname'] = 'listvis' 00145 ### 00146 myf['update_params'](func=myf['taskname'],printtext=False) 00147 ### 00148 ### 00149 #Handle globals or user over-ride of arguments 00150 # 00151 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00152 useLocalDefaults = False 00153 00154 for item in function_signature_defaults.iteritems(): 00155 key,val = item 00156 keyVal = eval(key) 00157 if (keyVal == None): 00158 #user hasn't set it - use global/default 00159 pass 00160 else: 00161 #user has set it - use over-ride 00162 if (key != 'self') : 00163 useLocalDefaults = True 00164 #myf[key]=keyVal 00165 00166 myparams = {} 00167 if useLocalDefaults : 00168 for item in function_signature_defaults.iteritems(): 00169 key,val = item 00170 keyVal = eval(key) 00171 exec('myparams[key] = keyVal') 00172 if (keyVal == None): 00173 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00174 keyVal = eval(key) 00175 if(type(keyVal) == dict) : 00176 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00177 00178 else : 00179 uselessvariable = None 00180 myparams['vis'] = vis = myf['vis'] 00181 myparams['options'] = options = myf['options'] 00182 myparams['datacolumn'] = datacolumn = myf['datacolumn'] 00183 myparams['field'] = field = myf['field'] 00184 myparams['spw'] = spw = myf['spw'] 00185 myparams['selectdata'] = selectdata = myf['selectdata'] 00186 myparams['antenna'] = antenna = myf['antenna'] 00187 myparams['timerange'] = timerange = myf['timerange'] 00188 myparams['correlation'] = correlation = myf['correlation'] 00189 myparams['scan'] = scan = myf['scan'] 00190 myparams['feed'] = feed = myf['feed'] 00191 myparams['array'] = array = myf['array'] 00192 myparams['observation'] = observation = myf['observation'] 00193 myparams['uvrange'] = uvrange = myf['uvrange'] 00194 myparams['average'] = average = myf['average'] 00195 myparams['showflags'] = showflags = myf['showflags'] 00196 myparams['pagerows'] = pagerows = myf['pagerows'] 00197 myparams['listfile'] = listfile = myf['listfile'] 00198 00199 00200 result = None 00201 00202 # 00203 # The following is work around to avoid a bug with current python translation 00204 # 00205 mytmp = {} 00206 00207 mytmp['vis'] = vis 00208 mytmp['options'] = options 00209 mytmp['datacolumn'] = datacolumn 00210 mytmp['field'] = field 00211 mytmp['spw'] = spw 00212 mytmp['selectdata'] = selectdata 00213 mytmp['antenna'] = antenna 00214 mytmp['timerange'] = timerange 00215 mytmp['correlation'] = correlation 00216 mytmp['scan'] = scan 00217 mytmp['feed'] = feed 00218 mytmp['array'] = array 00219 mytmp['observation'] = observation 00220 mytmp['uvrange'] = uvrange 00221 mytmp['average'] = average 00222 mytmp['showflags'] = showflags 00223 mytmp['pagerows'] = pagerows 00224 mytmp['listfile'] = listfile 00225 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00226 trec = casac.utils().torecord(pathname+'listvis.xml') 00227 00228 casalog.origin('listvis') 00229 if not trec.has_key('listvis') or not casac.utils().verify(mytmp, trec['listvis']) : 00230 return False 00231 00232 00233 try : 00234 casalog.post('') 00235 casalog.post('##########################################') 00236 casalog.post('##### Begin Task: listvis #####') 00237 casalog.post('') 00238 result = listvis(vis, options, datacolumn, field, spw, selectdata, antenna, timerange, correlation, scan, feed, array, observation, uvrange, average, showflags, pagerows, listfile) 00239 casalog.post('') 00240 casalog.post('##### End Task: listvis #####') 00241 casalog.post('##########################################') 00242 00243 00244 # saveinputs for individule engine has no use 00245 # saveinputs should alos be removed from casa_in_py.py 00246 # 00247 # 00248 # saveinputs = myf['saveinputs'] 00249 # saveinputs('listvis', 'listvis.last', myparams) 00250 # 00251 # 00252 except Exception, instance: 00253 #print '**** Error **** ',instance 00254 pass 00255 00256 gc.collect() 00257 return result 00258 # 00259 # 00260 ## 00261 # def paramgui(self, useGlobals=True): 00262 # """ 00263 # Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00264 # """ 00265 # import paramgui 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 # 00275 # if useGlobals: 00276 # paramgui.setGlobals(myf) 00277 # else: 00278 # paramgui.setGlobals({}) 00279 # 00280 # paramgui.runTask('listvis', myf['_ip']) 00281 # paramgui.setGlobals({}) 00282 # 00283 # 00284 # 00285 # 00286 def defaults(self, param=None): 00287 a=inspect.stack() 00288 stacklevel=0 00289 for k in range(len(a)): 00290 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00291 stacklevel=k 00292 break 00293 myf=sys._getframe(stacklevel).f_globals 00294 a = odict() 00295 a['vis'] = '' 00296 a['options'] = 'ap' 00297 a['datacolumn'] = 'data' 00298 a['field'] = '' 00299 a['spw'] = '*' 00300 a['selectdata'] = False 00301 a['observation'] = '' 00302 a['average'] = '' 00303 a['showflags'] = False 00304 a['pagerows'] = 50 00305 a['listfile'] = '' 00306 00307 a['async']=False 00308 a['selectdata'] = { 00309 0:{'value':False}, 00310 1:odict([{'value':True}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'feed':''}, {'array':''}, {'observation':''}, {'uvrange':''}])} 00311 00312 ### This function sets the default values but also will return the list of 00313 ### parameters or the default value of a given parameter 00314 if(param == None): 00315 myf['__set_default_parameters'](a) 00316 elif(param == 'paramkeys'): 00317 return a.keys() 00318 else: 00319 if(a.has_key(param)): 00320 #if(type(a[param]) == dict) : 00321 # return a[param][len(a[param])-1]['value'] 00322 #else : 00323 return a[param] 00324 00325 00326 # 00327 # 00328 def check_params(self, param=None, value=None): 00329 a=inspect.stack() 00330 stacklevel=0 00331 for k in range(len(a)): 00332 if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0): 00333 stacklevel=k 00334 break 00335 myf=sys._getframe(stacklevel).f_globals 00336 00337 # print 'param:', param, 'value:', value 00338 try : 00339 if str(type(value)) != "<type 'instance'>" : 00340 value0 = value 00341 value = myf['cu'].expandparam(param, value) 00342 matchtype = False 00343 if(type(value) == numpy.ndarray): 00344 if(type(value) == type(value0)): 00345 myf[param] = value.tolist() 00346 else: 00347 #print 'value:', value, 'value0:', value0 00348 #print 'type(value):', type(value), 'type(value0):', type(value0) 00349 myf[param] = value0 00350 if type(value0) != list : 00351 matchtype = True 00352 else : 00353 myf[param] = value 00354 value = myf['cu'].verifyparam({param:value}) 00355 if matchtype: 00356 value = False 00357 except Exception, instance: 00358 #ignore the exception and just return it unchecked 00359 myf[param] = value 00360 return value 00361 00362 # 00363 # 00364 def description(self, key='listvis', subkey=None): 00365 desc={'listvis': 'List measurement set visibilities.', 00366 'vis': 'Name of input visibility file', 00367 'options': 'List options: ap only ', 00368 'datacolumn': 'Column to list: data, float_data, corrected, model, residual', 00369 'field': 'Field names or index to be listed: \'\'==>all', 00370 'spw': 'Spectral window:channels: \'\*\'==>all, spw=\'1:5~57\'', 00371 'selectdata': 'Other data selection parameters', 00372 'antenna': 'Antenna/baselines: \'\'==>all, antenna = \'3\'', 00373 'timerange': 'Time range: \'\'==>all', 00374 'correlation': 'Correlations: \'\'==>all, correlation = \'RR RL\'', 00375 'scan': 'Scan numbers', 00376 'feed': 'Multi-feed numbers (Not yet implemented)', 00377 'array': 'Array numbers (Not yet implemented)', 00378 'observation': 'Select by observation ID(s)', 00379 'uvrange': 'uv range: \'\'==>all; not yet implemented ', 00380 'average': 'Averaging mode: ''==>none (Not yet implemented)', 00381 'showflags': 'Show flagged data (Not yet implemented)', 00382 'pagerows': 'Rows per page', 00383 'listfile': 'Output file', 00384 00385 'async': 'If true the taskname must be started using listvis(...)' 00386 } 00387 00388 # 00389 # Set subfields defaults if needed 00390 # 00391 00392 if(desc.has_key(key)) : 00393 return desc[key] 00394 00395 def itsdefault(self, paramname) : 00396 a = {} 00397 a['vis'] = '' 00398 a['options'] = 'ap' 00399 a['datacolumn'] = 'data' 00400 a['field'] = '' 00401 a['spw'] = '*' 00402 a['selectdata'] = False 00403 a['antenna'] = '' 00404 a['timerange'] = '' 00405 a['correlation'] = '' 00406 a['scan'] = '' 00407 a['feed'] = '' 00408 a['array'] = '' 00409 a['observation'] = '' 00410 a['uvrange'] = '' 00411 a['average'] = '' 00412 a['showflags'] = False 00413 a['pagerows'] = 50 00414 a['listfile'] = '' 00415 00416 if a.has_key(paramname) : 00417 return a[paramname] 00418 listvis_pg = listvis_pg_()