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_polcal import polcal 00018 class polcal_cli_: 00019 __name__ = "polcal" 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__ = (polcal_cli_,) 00028 self.__doc__ = self.__call__.__doc__ 00029 00030 self.parameters={'vis':None, 'caltable':None, 'field':None, 'spw':None, 'intent':None, 'selectdata':None, 'timerange':None, 'uvrange':None, 'antenna':None, 'scan':None, 'observation':None, 'msselect':None, 'solint':None, 'combine':None, 'preavg':None, 'refant':None, 'minblperant':None, 'minsnr':None, 'poltype':None, 'smodel':None, 'append':None, 'gaintable':None, 'gainfield':None, 'interp':None, 'spwmap':None, 'gaincurve':None, 'opacity':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, caltable=None, field=None, spw=None, intent=None, selectdata=None, timerange=None, uvrange=None, antenna=None, scan=None, observation=None, msselect=None, solint=None, combine=None, preavg=None, refant=None, minblperant=None, minsnr=None, poltype=None, smodel=None, append=None, gaintable=None, gainfield=None, interp=None, spwmap=None, gaincurve=None, opacity=None, async=None): 00047 00048 """Determine instrumental polarization calibrations 00049 00050 The instrumental polarization factors (D-terms), the calibrator polarization, 00051 and the R-L polarization angle can be determined using polcal. The solutions 00052 can be obtained for each antenna/spwid and even individual channels, if desired. 00053 Previous calibrations of the total intensity data should be applied on the fly 00054 when running polcal, since polcal uses the 'data' column, not the 'corrected' 00055 column. 00056 00057 After calibrating the gain, bandpass, and (if relevant, for channelized data) 00058 cross-hand delay, the simplest way to calibrate the polarization data is: 00059 00060 a) Run polcal with poltype = 'D+QU' on the main 'calibrator' source. The D terms 00061 and polarization (QU) of the calibrator will be determined. Relatively good 00062 parallactic angle coverage is needed. 00063 00064 b) If there is little parallactic angle coverage, place the known polarization of 00065 the main calibrator (or 0) using setjy with the appropriate fluxdensity. Then 00066 run polcal with poltype = 'D'. Run plotcal with xaxis = 'real'; yaxis ='imag' 00067 to view solutions. It is best to use an unpolarized calibrator in this 00068 instance; large systematic offsets from zero indicate significant source 00069 polarization that will bias the polarization calibration. A mechanism 00070 to constrain this bias will be made available in the near future. 00071 00072 c) To determine R-L polarization angle, use setjy to put the fluxdensity of the 00073 polarization calibrator [I,Q,U,0.0] in the model column. For resolved sources 00074 put in values associated with an appropriate u-v range. Polarized models are 00075 not yet available for the major polarization standard sources, so very 00076 resolved polarized sources should not be used. 00077 00078 d) Run polcal with poltype = 'X' and include polarization standard. Make sure to 00079 include all previous calibrations, especially the D results. Run plotxy with 00080 correlation = 'RL LR' and make sure polarization angles are as expected. 00081 00082 e) Run applycal with all calibration table, include the D and X tables. Make sure 00083 that parang = T 00084 00085 NOTE: For very high dynamic range, use poltype='Df' or 'Df+QU' to determine 00086 D terms for each channel. Similarly, poltype='Xf' can 00087 be used to determine a channel-dependent R-L phase 00088 "bandpass". 00089 NOTE: Rather than use setjy in b and c above, the new smodel 00090 parameter may be used in polcal to specify a simple 00091 point source Stokes model. 00092 00093 Keyword arguments: 00094 vis -- Name of input visibility file 00095 default: none; example: vis='ngc5921.ms' 00096 caltable -- Name of output gain calibration table 00097 default: none; example: caltable='ngc5921.dcal' 00098 00099 --- Data Selection (see help par.selectdata for more detailed information) 00100 00101 field -- Select field using field id(s) or field name(s). 00102 [run listobs to obtain the list id's or names] 00103 default: ''=all fields. 00104 Most likely, the main calibrator source should be picked. 00105 If field string is a non-negative integer, it is assumed a field index 00106 otherwise, it is assumed a field name 00107 field='0~2'; field ids 0,1,2 00108 field='0,4,5~7'; field ids 0,4,5,6,7 00109 field='3C286,3C295'; field named 3C286 adn 3C295 00110 field = '3,4C*'; field id 3, all names starting with 4C 00111 spw -- Select spectral window/channels 00112 type 'help par.selection' for more examples. 00113 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00114 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00115 spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE 00116 spw='*:5~61'; all spw with channels 5 to 62 00117 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00118 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00119 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00120 NOTE ';' to separate channel selections 00121 spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10, 00122 spw 1, channels 20,25,30 00123 intent -- Select observing intent 00124 default: '' (no selection by intent) 00125 intent='*BANDPASS*' (selects data labelled with 00126 BANDPASS intent) 00127 selectdata -- Other data selection parameters 00128 default: True 00129 timerange -- Select data based on time range: 00130 default = '' (all); examples, 00131 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00132 Note: if YYYY/MM/DD is missing dat defaults to first day in data set 00133 timerange='09:14:0~09:54:0' picks 40 min on first day 00134 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00135 timerange='09:44:00' data within one integration of time 00136 timerange='>10:24:00' data after this time 00137 uvrange -- Select data within uvrange (default units meters) 00138 default: '' (all); example: 00139 uvrange='0~1000'; uvrange from 0-1000 kilo-lamgda 00140 uvrange='>4';uvranges greater than 4 kilo-lambda 00141 antenna -- Select data based on antenna/baseline 00142 default: '' (all) 00143 If antenna string is a non-negative integer, it is assumed an antenna index 00144 otherwise, it is assumed as an antenna name 00145 antenna='5&6'; baseline between antenna index 5 and index 6. 00146 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00147 antenna='5&6;7&8'; baseline 5-6 and 7-8 00148 antenna='5'; all baselines with antenna index 5 00149 antenna='05'; all baselines with antenna name 05, i.e. VLA ant 5 00150 antenna='5,6,10'; all baselines with antennas 5, 6 and 10 00151 scan -- Scan number range 00152 observation -- Observation ID(s). 00153 default: '' = all 00154 example: '0~2,4' 00155 msselect -- Optional complex data selection (ignore for now) 00156 00157 --- Solution parameters 00158 poltype -- Type of instrumental polarization solution 00159 'D+QU' (or 'Df+QU') solve also for apparent source polarization (channelized D) 00160 Need relatively good parallactic angle coverage for this 00161 'D' (or 'Df') solve only for instrumental polarization (channelized). The 00162 I, Q, U flux density of the source can be placed in the model column using 00163 setjy. Use for poor parallactic angle coverage. 00164 'X' (or 'Xf') = solve only for position angle correction (channelized). 00165 The source must have its I, Q, U flux density in the model column 00166 or specified in smodel. If the source is resolved, use a limited 00167 uvrange that is appropriate. 00168 'D+X' (or 'Df+X') = solve also for position angle offset (channelized D) as 00169 well as the D-term. Not normally done. 00170 default: 'D+QU' 00171 The solution used the traditional linear approximation. Non-linearized options 00172 will be avaible soon. 00173 smodel -- Point source Stokes parameters for source model (experimental) 00174 default: [] (use MODEL_DATA column) 00175 examples: [1,0,0,0] (I=1, unpolarized) 00176 [5.2,0.2,0.3,0.0] (I=5.2, Q=0.2, U=0.3, V=0.0) 00177 solint -- Solution interval (units optional) 00178 default: 'inf' (~infinite, up to boundaries controlled by combine); 00179 Options: 'inf' (~infinite), 'int' (per integration), any float 00180 or integer value with or without units 00181 examples: solint='1min'; solint='60s', solint=60 --> 1 minute 00182 solint='0s'; solint=0; solint='int' --> per integration 00183 solint-'-1s'; solint='inf' --> ~infinite, up to boundaries 00184 enforced by combine 00185 combine -- Data axes to combine for solving 00186 default: 'scan' --> solutions will break at field and spw boundaries, 00187 but may extend over multiple scans (per field and spw) up 00188 to solint. 00189 Options: '','scan','spw',field', or any comma-separated combination 00190 example: combine='scan,spw' --> extend solutions over scan boundaries 00191 (up to the solint), and combine spws for solving 00192 preavg -- Pre-averaging interval (sec) 00193 default=300 00194 Interval to apply parallactic angle. 00195 refant -- Reference antenna name 00196 default: '' => refant = '0' 00197 example: refant='13' (antenna with index 13) 00198 refant='VA04' (VLA antenna #4) 00199 refant='EA02,EA23,EA13' (EVLA antenna EA02, use 00200 EA23 and EA13 as alternates if/when EA02 00201 drops out) 00202 Use 'go listobs' for antenna listing. 00203 USE SAME REFERENCE ANTENNA AS USED FOR I CALIBRATION. 00204 minblperant -- Minimum number of baselines required per antenna for each solve 00205 Antennas with fewer baaselines are excluded from solutions. Amplitude 00206 solutions with fewer than 4 baselines, and phase solutions with fewer 00207 than 3 baselines are only trivially constrained, and are no better 00208 than baseline-based solutions. 00209 default: 4 00210 example: minblperant=10 => Antennas participating on 10 or more 00211 baselines are included in the solve 00212 minsnr -- Reject solutions below this SNR 00213 default: 3.0 00214 append -- Append solutions to the (existing) table 00215 default: False; overwrite existing table or make new table 00216 00217 --- Other calibrations to apply on the fly before determining gaincal solution 00218 00219 gaintable -- Gain calibration table(s) to apply 00220 default: '' (none); BUT I CALIBRATION TABLES SHOULD GENERALLY BE INCLUDED 00221 examples: gaintable='ngc5921.gcal' 00222 gaintable=['ngc5921.ampcal','ngc5921.phcal'] 00223 gainfield -- Select a subset of calibrators from gaintable(s) 00224 default:'' ==> all sources in table; 00225 'nearest' ==> nearest (on sky) available field in table 00226 otherwise, same syntax as field 00227 example: gainfield='0~3' 00228 gainfield=['0~3','4~6'] means use field 0 through 3 00229 from first gain file, field 4 through 6 for second. 00230 interp -- Interpolation type (in time[,freq]) to use for each gaintable. 00231 When frequency interpolation is relevant (B, Df, Xf), 00232 separate time-dependent and freq-dependent interp 00233 types with a comma (freq _after_ the comma). 00234 Specifications for frequency are ignored when the 00235 calibration table has no channel-dependence. 00236 Time-dependent interp options ending in 'PD' enable a 00237 "phase delay" correction per spw for non-channel-dependent 00238 calibration types. 00239 default: '' --> 'linear,linear' for all gaintable(s) 00240 example: interp='nearest' (in time, freq-dep will be 00241 linear, if relevant) 00242 interp='linear,cubic' (linear in time, cubic 00243 in freq) 00244 interp=',spline' (spline in freq; linear in 00245 time by default) 00246 interp=['nearest,spline','linear'] (for multiple gaintables) 00247 Options: Time: 'nearest', 'linear' 00248 Freq: 'nearest', 'linear', 'cubic', 'spline' 00249 spwmap -- Spectral windows combinations to form for gaintable(s) 00250 default: [] (apply solutions from each spw to that spw only) 00251 Example: spwmap=[0,0,1,1] means apply the caltable solutions 00252 from spw = 0 to the spw 0,1 and spw 1 to spw 2,3. 00253 spwmap=[[0,0,1,1],[0,1,0,1]] 00254 gaincurve -- Apply internal VLA antenna gain curve correction (True/False) 00255 default: False; 00256 Use gaincurve=True ONLY for VLA data 00257 opacity -- Opacity correction to apply (nepers), per spw 00258 default: [] (no opacity correction for any spw) 00259 examples: 00260 A global value for all spws: 00261 opacity=0.051 00262 Different values for spws 0,1,2: 00263 opacity=[0.051, 0.055, 0.057] 00264 (if more than 3 spws, spw 3 and higher will 00265 be assigned the last specified value, or 0.057) 00266 Typical VLA values are: 5 GHz - 0.013, 8 GHz - 0.013 00267 15 GHz - 0.016, 23 GHz - 0.051, 43 GHz - 0.07 00268 async -- Run asynchronously 00269 default = False; do not run asychronously 00270 00271 """ 00272 if not hasattr(self, "__globals__") or self.__globals__ == None : 00273 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00274 #casac = self.__globals__['casac'] 00275 casalog = self.__globals__['casalog'] 00276 #casalog = casac.casac.logsink() 00277 self.__globals__['__last_task'] = 'polcal' 00278 self.__globals__['taskname'] = 'polcal' 00279 ### 00280 self.__globals__['update_params'](func=self.__globals__['taskname'],printtext=False,ipython_globals=self.__globals__) 00281 ### 00282 ### 00283 #Handle globals or user over-ride of arguments 00284 # 00285 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00286 useLocalDefaults = False 00287 00288 for item in function_signature_defaults.iteritems(): 00289 key,val = item 00290 keyVal = eval(key) 00291 if (keyVal == None): 00292 #user hasn't set it - use global/default 00293 pass 00294 else: 00295 #user has set it - use over-ride 00296 if (key != 'self') : 00297 useLocalDefaults = True 00298 00299 myparams = {} 00300 if useLocalDefaults : 00301 for item in function_signature_defaults.iteritems(): 00302 key,val = item 00303 keyVal = eval(key) 00304 exec('myparams[key] = keyVal') 00305 self.parameters[key] = keyVal 00306 if (keyVal == None): 00307 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00308 keyVal = eval(key) 00309 if(type(keyVal) == dict) : 00310 if len(keyVal) > 0 : 00311 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00312 else : 00313 exec('myparams[key] = ' + key + ' = {}') 00314 00315 else : 00316 async = self.parameters['async'] 00317 myparams['vis'] = vis = self.parameters['vis'] 00318 myparams['caltable'] = caltable = self.parameters['caltable'] 00319 myparams['field'] = field = self.parameters['field'] 00320 myparams['spw'] = spw = self.parameters['spw'] 00321 myparams['intent'] = intent = self.parameters['intent'] 00322 myparams['selectdata'] = selectdata = self.parameters['selectdata'] 00323 myparams['timerange'] = timerange = self.parameters['timerange'] 00324 myparams['uvrange'] = uvrange = self.parameters['uvrange'] 00325 myparams['antenna'] = antenna = self.parameters['antenna'] 00326 myparams['scan'] = scan = self.parameters['scan'] 00327 myparams['observation'] = observation = self.parameters['observation'] 00328 myparams['msselect'] = msselect = self.parameters['msselect'] 00329 myparams['solint'] = solint = self.parameters['solint'] 00330 myparams['combine'] = combine = self.parameters['combine'] 00331 myparams['preavg'] = preavg = self.parameters['preavg'] 00332 myparams['refant'] = refant = self.parameters['refant'] 00333 myparams['minblperant'] = minblperant = self.parameters['minblperant'] 00334 myparams['minsnr'] = minsnr = self.parameters['minsnr'] 00335 myparams['poltype'] = poltype = self.parameters['poltype'] 00336 myparams['smodel'] = smodel = self.parameters['smodel'] 00337 myparams['append'] = append = self.parameters['append'] 00338 myparams['gaintable'] = gaintable = self.parameters['gaintable'] 00339 myparams['gainfield'] = gainfield = self.parameters['gainfield'] 00340 myparams['interp'] = interp = self.parameters['interp'] 00341 myparams['spwmap'] = spwmap = self.parameters['spwmap'] 00342 myparams['gaincurve'] = gaincurve = self.parameters['gaincurve'] 00343 myparams['opacity'] = opacity = self.parameters['opacity'] 00344 00345 if type(smodel)==float: smodel=[smodel] 00346 if type(gaintable)==str: gaintable=[gaintable] 00347 if type(gainfield)==str: gainfield=[gainfield] 00348 if type(interp)==str: interp=[interp] 00349 if type(spwmap)==int: spwmap=[spwmap] 00350 if type(opacity)==float: opacity=[opacity] 00351 00352 result = None 00353 00354 # 00355 # The following is work around to avoid a bug with current python translation 00356 # 00357 mytmp = {} 00358 00359 mytmp['vis'] = vis 00360 mytmp['caltable'] = caltable 00361 mytmp['field'] = field 00362 mytmp['spw'] = spw 00363 mytmp['intent'] = intent 00364 mytmp['selectdata'] = selectdata 00365 mytmp['timerange'] = timerange 00366 mytmp['uvrange'] = uvrange 00367 mytmp['antenna'] = antenna 00368 mytmp['scan'] = scan 00369 mytmp['observation'] = observation 00370 mytmp['msselect'] = msselect 00371 mytmp['solint'] = solint 00372 mytmp['combine'] = combine 00373 mytmp['preavg'] = preavg 00374 mytmp['refant'] = refant 00375 mytmp['minblperant'] = minblperant 00376 mytmp['minsnr'] = minsnr 00377 mytmp['poltype'] = poltype 00378 mytmp['smodel'] = smodel 00379 mytmp['append'] = append 00380 mytmp['gaintable'] = gaintable 00381 mytmp['gainfield'] = gainfield 00382 mytmp['interp'] = interp 00383 mytmp['spwmap'] = spwmap 00384 mytmp['gaincurve'] = gaincurve 00385 mytmp['opacity'] = opacity 00386 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00387 trec = casac.casac.utils().torecord(pathname+'polcal.xml') 00388 00389 casalog.origin('polcal') 00390 try : 00391 #if not trec.has_key('polcal') or not casac.casac.utils().verify(mytmp, trec['polcal']) : 00392 #return False 00393 00394 casac.casac.utils().verify(mytmp, trec['polcal'], True) 00395 scriptstr=[''] 00396 saveinputs = self.__globals__['saveinputs'] 00397 saveinputs('polcal', 'polcal.last', myparams, self.__globals__,scriptstr=scriptstr) 00398 if async : 00399 count = 0 00400 keybase = time.strftime("%y%m%d.%H%M%S") 00401 key = keybase + "_" + str(count) 00402 while self.__async__.has_key(key) : 00403 count += 1 00404 key = keybase + "_" + str(count) 00405 result = tm.execute('polcal', vis, caltable, field, spw, intent, selectdata, timerange, uvrange, antenna, scan, observation, msselect, solint, combine, preavg, refant, minblperant, minsnr, poltype, smodel, append, gaintable, gainfield, interp, spwmap, gaincurve, opacity) 00406 print "Use: " 00407 print " tm.retrieve(return_value) # to retrieve the status" 00408 print 00409 self.rkey = key 00410 self.__async__[key] = result 00411 else : 00412 tname = 'polcal' 00413 spaces = ' '*(18-len(tname)) 00414 casalog.post('\n##########################################'+ 00415 '\n##### Begin Task: ' + tname + spaces + ' #####') 00416 casalog.post(scriptstr[1][1:]+'\n', 'INFO') 00417 result = polcal(vis, caltable, field, spw, intent, selectdata, timerange, uvrange, antenna, scan, observation, msselect, solint, combine, preavg, refant, minblperant, minsnr, poltype, smodel, append, gaintable, gainfield, interp, spwmap, gaincurve, opacity) 00418 casalog.post('##### End Task: ' + tname + ' ' + spaces + ' #####'+ 00419 '\n##########################################') 00420 00421 except Exception, instance: 00422 if(self.__globals__.has_key('__rethrow_casa_exceptions') and self.__globals__['__rethrow_casa_exceptions']) : 00423 raise 00424 else : 00425 #print '**** Error **** ',instance 00426 tname = 'polcal' 00427 casalog.post('An error occurred running task '+tname+'.', 'ERROR') 00428 pass 00429 00430 gc.collect() 00431 return result 00432 # 00433 # 00434 # 00435 def paramgui(self, useGlobals=True, ipython_globals=None): 00436 """ 00437 Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00438 """ 00439 import paramgui 00440 if not hasattr(self, "__globals__") or self.__globals__ == None : 00441 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00442 00443 if useGlobals: 00444 if ipython_globals == None: 00445 myf=self.__globals__ 00446 else: 00447 myf=ipython_globals 00448 00449 paramgui.setGlobals(myf) 00450 else: 00451 paramgui.setGlobals({}) 00452 00453 paramgui.runTask('polcal', myf['_ip']) 00454 paramgui.setGlobals({}) 00455 00456 # 00457 # 00458 # 00459 def defaults(self, param=None, ipython_globals=None, paramvalue=None, subparam=None): 00460 if not hasattr(self, "__globals__") or self.__globals__ == None : 00461 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00462 if ipython_globals == None: 00463 myf=self.__globals__ 00464 else: 00465 myf=ipython_globals 00466 00467 a = odict() 00468 a['vis'] = '' 00469 a['caltable'] = '' 00470 a['field'] = '' 00471 a['spw'] = '' 00472 a['intent'] = '' 00473 a['selectdata'] = True 00474 a['solint'] = 'inf' 00475 a['combine'] = 'scan' 00476 a['preavg'] = 300.0 00477 a['refant'] = '' 00478 a['minblperant'] = 4 00479 a['minsnr'] = 3.0 00480 a['poltype'] = 'D+QU' 00481 a['smodel'] = [] 00482 a['append'] = False 00483 a['gaintable'] = [''] 00484 a['gainfield'] = [''] 00485 a['interp'] = [''] 00486 a['spwmap'] = [] 00487 a['gaincurve'] = False 00488 a['opacity'] = [] 00489 00490 a['async']=False 00491 a['selectdata'] = { 00492 0:odict([{'value':True}, {'timerange':''}, {'uvrange':''}, {'antenna':''}, {'scan':''}, {'observation':''}, {'msselect':''}]), 00493 1:{'value':False}} 00494 00495 ### This function sets the default values but also will return the list of 00496 ### parameters or the default value of a given parameter 00497 if(param == None): 00498 myf['__set_default_parameters'](a) 00499 elif(param == 'paramkeys'): 00500 return a.keys() 00501 else: 00502 if(paramvalue==None and subparam==None): 00503 if(a.has_key(param)): 00504 return a[param] 00505 else: 00506 return self.itsdefault(param) 00507 else: 00508 retval=a[param] 00509 if(type(a[param])==dict): 00510 for k in range(len(a[param])): 00511 valornotval='value' 00512 if(a[param][k].has_key('notvalue')): 00513 valornotval='notvalue' 00514 if((a[param][k][valornotval])==paramvalue): 00515 retval=a[param][k].copy() 00516 retval.pop(valornotval) 00517 if(subparam != None): 00518 if(retval.has_key(subparam)): 00519 retval=retval[subparam] 00520 else: 00521 retval=self.itsdefault(subparam) 00522 else: 00523 retval=self.itsdefault(subparam) 00524 return retval 00525 00526 00527 # 00528 # 00529 def check_params(self, param=None, value=None, ipython_globals=None): 00530 if ipython_globals == None: 00531 myf=self.__globals__ 00532 else: 00533 myf=ipython_globals 00534 # print 'param:', param, 'value:', value 00535 try : 00536 if str(type(value)) != "<type 'instance'>" : 00537 value0 = value 00538 value = myf['cu'].expandparam(param, value) 00539 matchtype = False 00540 if(type(value) == numpy.ndarray): 00541 if(type(value) == type(value0)): 00542 myf[param] = value.tolist() 00543 else: 00544 #print 'value:', value, 'value0:', value0 00545 #print 'type(value):', type(value), 'type(value0):', type(value0) 00546 myf[param] = value0 00547 if type(value0) != list : 00548 matchtype = True 00549 else : 00550 myf[param] = value 00551 value = myf['cu'].verifyparam({param:value}) 00552 if matchtype: 00553 value = False 00554 except Exception, instance: 00555 #ignore the exception and just return it unchecked 00556 myf[param] = value 00557 return value 00558 # 00559 # 00560 def description(self, key='polcal', subkey=None): 00561 desc={'polcal': 'Determine instrumental polarization calibrations', 00562 'vis': 'Name of input visibility file', 00563 'caltable': 'Name of output gain calibration table', 00564 'field': 'Select field using field id(s) or field name(s)', 00565 'spw': 'Select spectral window/channels', 00566 'intent': 'Select observing intent', 00567 'selectdata': 'Other data selection parameters', 00568 'timerange': 'Select data based on time range', 00569 'uvrange': 'Select data within uvrange (default units meters)', 00570 'antenna': 'Select data based on antenna/baseline', 00571 'scan': 'Scan number range', 00572 'observation': 'Select by observation ID(s)', 00573 'msselect': 'Optional complex data selection (ignore for now)', 00574 'solint': 'Solution interval', 00575 'combine': 'Data axes which to combine for solve (scan, spw, and/or field)', 00576 'preavg': 'Pre-averaging interval (sec)', 00577 'refant': 'Reference antenna name(s)', 00578 'minblperant': 'Minimum baselines _per antenna_ required for solve', 00579 'minsnr': 'Reject solutions below this SNR', 00580 'poltype': 'Type of instrumental polarization solution (see help)', 00581 'smodel': 'Point source Stokes parameters for source model.', 00582 'append': 'Append solutions to the (existing) table', 00583 'gaintable': 'Gain calibration table(s) to apply', 00584 'gainfield': 'Select a subset of calibrators from gaintable(s)', 00585 'interp': 'Interpolation mode (in time) to use for each gaintable', 00586 'spwmap': 'Spectral windows combinations to form for gaintables(s)', 00587 'gaincurve': 'Apply internal VLA antenna gain curve correction', 00588 'opacity': 'Opacity correction to apply (nepers), per spw', 00589 00590 'async': 'If true the taskname must be started using polcal(...)' 00591 } 00592 00593 # 00594 # Set subfields defaults if needed 00595 # 00596 00597 if(desc.has_key(key)) : 00598 return desc[key] 00599 00600 def itsdefault(self, paramname) : 00601 a = {} 00602 a['vis'] = '' 00603 a['caltable'] = '' 00604 a['field'] = '' 00605 a['spw'] = '' 00606 a['intent'] = '' 00607 a['selectdata'] = True 00608 a['timerange'] = '' 00609 a['uvrange'] = '' 00610 a['antenna'] = '' 00611 a['scan'] = '' 00612 a['observation'] = '' 00613 a['msselect'] = '' 00614 a['solint'] = 'inf' 00615 a['combine'] = 'scan' 00616 a['preavg'] = 300.0 00617 a['refant'] = '' 00618 a['minblperant'] = 4 00619 a['minsnr'] = 3.0 00620 a['poltype'] = 'D+QU' 00621 a['smodel'] = [] 00622 a['append'] = False 00623 a['gaintable'] = [''] 00624 a['gainfield'] = [''] 00625 a['interp'] = [''] 00626 a['spwmap'] = [] 00627 a['gaincurve'] = False 00628 a['opacity'] = [] 00629 00630 #a = sys._getframe(len(inspect.stack())-1).f_globals 00631 00632 if self.parameters['selectdata'] == True: 00633 a['timerange'] = '' 00634 a['uvrange'] = '' 00635 a['antenna'] = '' 00636 a['scan'] = '' 00637 a['observation'] = '' 00638 a['msselect'] = '' 00639 00640 if a.has_key(paramname) : 00641 return a[paramname] 00642 polcal_cli = polcal_cli_()