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_gaincal import gaincal 00018 class gaincal_cli_: 00019 __name__ = "gaincal" 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__ = (gaincal_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, 'solnorm':None, 'gaintype':None, 'smodel':None, 'calmode':None, 'append':None, 'splinetime':None, 'npointaver':None, 'phasewrap':None, 'gaintable':None, 'gainfield':None, 'interp':None, 'spwmap':None, 'gaincurve':None, 'opacity':None, 'parang':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, solnorm=None, gaintype=None, smodel=None, calmode=None, append=None, splinetime=None, npointaver=None, phasewrap=None, gaintable=None, gainfield=None, interp=None, spwmap=None, gaincurve=None, opacity=None, parang=None, async=None): 00047 00048 """Determine temporal gains from calibrator observations 00049 00050 The complex gains for each antenna/spwid are determined from the 00051 data column (raw data) divided by the model column. The gains can 00052 be obtained for a specified solution interval, spw combination and 00053 field combination. The GSPLINE spline (smooth) option is still under 00054 development. 00055 00056 Previous calibrations (egs, bandpass, opacity, parallactic angle) can 00057 be applied on the fly. At present with dual-polarized data, both 00058 polarizations must be unflagged for any solution to be obtained. 00059 00060 Keyword arguments: 00061 vis -- Name of input visibility file 00062 default: none; example: vis='ngc5921.ms' 00063 caltable -- Name of output gain calibration table 00064 default: none; example: caltable='ngc5921.gcal' 00065 00066 --- Data Selection (see help par.selectdata for more detailed information) 00067 00068 field -- Select field using field id(s) or field name(s). 00069 ['go listobs' to obtain the list id's or names] 00070 default: ''=all fields 00071 If field string is a non-negative integer, it is assumed a 00072 field index, otherwise, it is assumed a field name 00073 field='0~2'; field ids 0,1,2 00074 field='0,4,5~7'; field ids 0,4,5,6,7 00075 field='3C286,3C295'; field named 3C286 and 3C295 00076 field = '3,4C*'; field id 3, all names starting with 4C 00077 DON'T FORGET TO INCLUDE THE FLUX DENSITY CALIBRATOR IF YOU HAVE ONE 00078 spw -- Select spectral window/channels 00079 type 'help par.selection' for more examples. 00080 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00081 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00082 spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE 00083 spw='*:5~61'; all spw with channels 5 to 61 00084 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00085 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00086 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00087 NOTE ';' to separate channel selections 00088 spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10, 00089 spw 1, channels 20,25,30 00090 intent -- Select observing intent 00091 default: '' (no selection by intent) 00092 intent='*BANDPASS*' (selects data labelled with 00093 BANDPASS intent) 00094 selectdata -- Other data selection parameters 00095 default: False 00096 00097 Must set selectdata=True to use the following selections: 00098 00099 timerange -- Select data based on time range: 00100 default = '' (all); examples, 00101 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00102 Note: if YYYY/MM/DD is missing date defaults to first day in data set 00103 timerange='09:14:0~09:54:0' picks 40 min on first day 00104 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on NEXT day 00105 timerange='09:44:00' pick data within one integration of time 00106 timerange='>10:24:00' data after this time 00107 uvrange -- Select data within uvrange (default units meters) 00108 default: '' (all); example: 00109 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 00110 uvrange='>4klambda';uvranges greater than 4 kilo lambda 00111 antenna -- Select data based on antenna/baseline 00112 default: '' (all) 00113 If antenna string is a non-negative integer, it is assumed an 00114 antenna index, otherwise, it is assumed as an antenna name 00115 antenna='5&6'; baseline between antenna index 5 and index 6. 00116 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00117 antenna='5&6;7&8'; baselines with indices 5-6 and 7-8 00118 antenna='5'; all baselines with antenna index 5 00119 antenna='05'; all baselines with antenna number 05 (VLA old name) 00120 antenna='5,6,10'; all baselines with antennas 5,6,10 index numbers 00121 scan -- Scan number range. 00122 Check 'go listobs' to insure the scan numbers are in order. 00123 observation -- Observation ID(s). 00124 default: '' = all 00125 example: '0~2,4' 00126 msselect -- Optional complex data selection (ignore for now) 00127 00128 --- Solution parameters 00129 gaintype -- Type of gain solution (G, T, or GSPLINE) 00130 default: 'G'; example: gaintype='GSPLINE' 00131 'G' means determine gains for each polarization and sp_wid 00132 'T' obtains one solution for both polarizations; Hence. their 00133 phase offset must be first removed using a prior G. 00134 'GSPLINE' makes a spline fit to the calibrator data. It is 00135 useful for noisy data and fits a smooth curve through the 00136 calibrated amplitude and phase. However, 00137 at present GSPLINE is somewhat experimental. Use with 00138 caution and check solutions. 00139 'K' solves for simple antenna-based single-band delays 00140 via FFTs of the spectra on baselines to the 00141 reference antenna. (This is not global fringe-fitting.) 00142 'KCROSS' solves for a global cross-hand 00143 delay. Use parang=T and apply prior gain and 00144 bandpass solutions. 00145 smodel -- Point source Stokes parameters for source model (experimental) 00146 default: [] (use MODEL_DATA column) 00147 example: [1,0,0,0] (I=1, unpolarized) 00148 calmode -- Type of solution 00149 default: 'ap' (amp and phase); example: calmode='p' 00150 Options: 'p','a','ap' 00151 solint -- Solution interval (units optional) 00152 default: 'inf' (~infinite, up to boundaries controlled by combine); 00153 Options: 'inf' (~infinite), 00154 'int' (per integration) 00155 any float or integer value with or without units 00156 examples: solint='1min'; solint='60s'; solint=60 --> 1 minute 00157 solint='0s'; solint=0; solint='int' --> per integration 00158 solint-'-1s'; solint='inf' --> ~infinite, up to boundaries 00159 interacts with combine 00160 combine -- Data axes to combine for solving 00161 default: '' --> solutions will break at scan, field, and spw 00162 boundaries 00163 Options: '','scan','spw',field', or any comma-separated combination 00164 example: combine='scan,spw' --> extend solutions over scan boundaries 00165 (up to the solint), and combine spws for solving 00166 refant -- Reference antenna name(s); a prioritized list may be specified 00167 default: '' => no refant applied 00168 example: refant='4' (antenna with index 4) 00169 refant='VA04' (VLA antenna #4) 00170 refant='EA02,EA23,EA13' (EVLA antenna EA02, use 00171 EA23 and EA13 as alternates if/when EA02 00172 drops out) 00173 Use taskname=listobs for antenna listing 00174 minblperant -- Minimum number of baselines required per antenna for each solve 00175 default = 4 00176 Antennas with fewer baaselines are excluded from solutions. 00177 example: minblperant=10 => Antennas participating on 10 or more 00178 baselines are included in the solve 00179 minblperant = 1 will solve for all baseline pairs, even if only 00180 one is present in the data set. Unless closure errors are 00181 expected, use taskname=gaincal rather than taskname=blcal to 00182 obtain more options in data analysis. 00183 minsnr -- Reject solutions below this SNR 00184 default: 3.0 00185 solnorm -- Normalize average solution amps to 1.0 after solution (G, T only) 00186 default: False (no normalization) 00187 append -- Append solutions to the (existing) table 00188 default: False; overwrite existing table or make new table 00189 splinetime -- Spline timescale (sec); used for gaintype='GSPLINE' 00190 default: 3600 (1 hour); example: splinetime=1000 00191 Typical splinetime should cover about 3 to 5 calibrator scans. 00192 npointaver -- Tune phase-unwrapping algorithm for gaintype='GSPLINE' 00193 default: 3; Keep at this value 00194 phasewrap -- Wrap the phase for changes larger than this amoun (degrees) 00195 default: 180; Keep at this value 00196 00197 --- Other calibrations to apply on the fly before determining gaincal solution 00198 00199 gaintable -- Gain calibration table(s) to apply 00200 default: '' (none); 00201 examples: gaintable='ngc5921.gcal' 00202 gaintable=['ngc5921.ampcal','ngc5921.phcal'] 00203 gainfield -- Select a subset of calibrators from gaintable(s) to apply 00204 default:'' ==> all sources in table; 00205 'nearest' ==> nearest (on sky) available field in table 00206 otherwise, same syntax as field 00207 example: gainfield='0~2,5' means use fields 0,1,2,5 from gaintable 00208 gainfield=['0~3','4~6'] means use field 0 through 3 00209 from first gain file, field 4 through 6 for second. 00210 interp -- Interpolation type (in time[,freq]) to use for each gaintable. 00211 When frequency interpolation is relevant (B, Df, Xf), 00212 separate time-dependent and freq-dependent interp 00213 types with a comma (freq _after_ the comma). 00214 Specifications for frequency are ignored when the 00215 calibration table has no channel-dependence. 00216 Time-dependent interp options ending in 'PD' enable a 00217 "phase delay" correction per spw for non-channel-dependent 00218 calibration types. 00219 default: '' --> 'linear,linear' for all gaintable(s) 00220 example: interp='nearest' (in time, freq-dep will be 00221 linear, if relevant) 00222 interp='linear,cubic' (linear in time, cubic 00223 in freq) 00224 interp=',spline' (spline in freq; linear in 00225 time by default) 00226 interp=['nearest,spline','linear'] (for multiple gaintables) 00227 Options: Time: 'nearest', 'linear' 00228 Freq: 'nearest', 'linear', 'cubic', 'spline' 00229 spwmap -- Spectral windows combinations to form for gaintable(s) 00230 default: [] (apply solutions from each spw to that spw only) 00231 Example: spwmap=[0,0,1,1] means apply the caltable solutions 00232 from spw = 0 to the spw 0,1 and spw 1 to spw 2,3. 00233 spwmap=[[0,0,1,1],[0,1,0,1]] 00234 gaincurve -- Apply internal VLA antenna gain curve correction (True/False) 00235 default: False; 00236 Use gaincurve=True ONLY for VLA data 00237 opacity -- Opacity correction to apply (nepers), per spw 00238 default: [] (no opacity correction for any spw) 00239 examples: 00240 A global value for all spws: 00241 opacity=0.051 00242 Different values for spws 0,1,2: 00243 opacity=[0.051, 0.055, 0.057] 00244 (if more than 3 spws, spw 3 and higher will 00245 be assigned the last specified value, or 0.057) 00246 Typical VLA values are: 5 GHz - 0.013, 8 GHz - 0.013 00247 15 GHz - 0.016, 23 GHz - 0.051, 43 GHz - 0.07 00248 parang -- If True, apply the parallactic angle correction (required 00249 for polarization calibration) 00250 default: False 00251 preavg -- Pre-averaging interval (sec) 00252 default=-1 (none). 00253 Rarely needed. Will average data over periods shorter than 00254 the solution interval first. 00255 async -- Run asynchronously 00256 default = False; do not run asychronously 00257 00258 """ 00259 if not hasattr(self, "__globals__") or self.__globals__ == None : 00260 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00261 #casac = self.__globals__['casac'] 00262 casalog = self.__globals__['casalog'] 00263 #casalog = casac.casac.logsink() 00264 self.__globals__['__last_task'] = 'gaincal' 00265 self.__globals__['taskname'] = 'gaincal' 00266 ### 00267 self.__globals__['update_params'](func=self.__globals__['taskname'],printtext=False,ipython_globals=self.__globals__) 00268 ### 00269 ### 00270 #Handle globals or user over-ride of arguments 00271 # 00272 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00273 useLocalDefaults = False 00274 00275 for item in function_signature_defaults.iteritems(): 00276 key,val = item 00277 keyVal = eval(key) 00278 if (keyVal == None): 00279 #user hasn't set it - use global/default 00280 pass 00281 else: 00282 #user has set it - use over-ride 00283 if (key != 'self') : 00284 useLocalDefaults = True 00285 00286 myparams = {} 00287 if useLocalDefaults : 00288 for item in function_signature_defaults.iteritems(): 00289 key,val = item 00290 keyVal = eval(key) 00291 exec('myparams[key] = keyVal') 00292 self.parameters[key] = keyVal 00293 if (keyVal == None): 00294 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00295 keyVal = eval(key) 00296 if(type(keyVal) == dict) : 00297 if len(keyVal) > 0 : 00298 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00299 else : 00300 exec('myparams[key] = ' + key + ' = {}') 00301 00302 else : 00303 async = self.parameters['async'] 00304 myparams['vis'] = vis = self.parameters['vis'] 00305 myparams['caltable'] = caltable = self.parameters['caltable'] 00306 myparams['field'] = field = self.parameters['field'] 00307 myparams['spw'] = spw = self.parameters['spw'] 00308 myparams['intent'] = intent = self.parameters['intent'] 00309 myparams['selectdata'] = selectdata = self.parameters['selectdata'] 00310 myparams['timerange'] = timerange = self.parameters['timerange'] 00311 myparams['uvrange'] = uvrange = self.parameters['uvrange'] 00312 myparams['antenna'] = antenna = self.parameters['antenna'] 00313 myparams['scan'] = scan = self.parameters['scan'] 00314 myparams['observation'] = observation = self.parameters['observation'] 00315 myparams['msselect'] = msselect = self.parameters['msselect'] 00316 myparams['solint'] = solint = self.parameters['solint'] 00317 myparams['combine'] = combine = self.parameters['combine'] 00318 myparams['preavg'] = preavg = self.parameters['preavg'] 00319 myparams['refant'] = refant = self.parameters['refant'] 00320 myparams['minblperant'] = minblperant = self.parameters['minblperant'] 00321 myparams['minsnr'] = minsnr = self.parameters['minsnr'] 00322 myparams['solnorm'] = solnorm = self.parameters['solnorm'] 00323 myparams['gaintype'] = gaintype = self.parameters['gaintype'] 00324 myparams['smodel'] = smodel = self.parameters['smodel'] 00325 myparams['calmode'] = calmode = self.parameters['calmode'] 00326 myparams['append'] = append = self.parameters['append'] 00327 myparams['splinetime'] = splinetime = self.parameters['splinetime'] 00328 myparams['npointaver'] = npointaver = self.parameters['npointaver'] 00329 myparams['phasewrap'] = phasewrap = self.parameters['phasewrap'] 00330 myparams['gaintable'] = gaintable = self.parameters['gaintable'] 00331 myparams['gainfield'] = gainfield = self.parameters['gainfield'] 00332 myparams['interp'] = interp = self.parameters['interp'] 00333 myparams['spwmap'] = spwmap = self.parameters['spwmap'] 00334 myparams['gaincurve'] = gaincurve = self.parameters['gaincurve'] 00335 myparams['opacity'] = opacity = self.parameters['opacity'] 00336 myparams['parang'] = parang = self.parameters['parang'] 00337 00338 if type(smodel)==float: smodel=[smodel] 00339 if type(gaintable)==str: gaintable=[gaintable] 00340 if type(gainfield)==str: gainfield=[gainfield] 00341 if type(interp)==str: interp=[interp] 00342 if type(spwmap)==int: spwmap=[spwmap] 00343 if type(opacity)==float: opacity=[opacity] 00344 00345 result = None 00346 00347 # 00348 # The following is work around to avoid a bug with current python translation 00349 # 00350 mytmp = {} 00351 00352 mytmp['vis'] = vis 00353 mytmp['caltable'] = caltable 00354 mytmp['field'] = field 00355 mytmp['spw'] = spw 00356 mytmp['intent'] = intent 00357 mytmp['selectdata'] = selectdata 00358 mytmp['timerange'] = timerange 00359 mytmp['uvrange'] = uvrange 00360 mytmp['antenna'] = antenna 00361 mytmp['scan'] = scan 00362 mytmp['observation'] = observation 00363 mytmp['msselect'] = msselect 00364 mytmp['solint'] = solint 00365 mytmp['combine'] = combine 00366 mytmp['preavg'] = preavg 00367 mytmp['refant'] = refant 00368 mytmp['minblperant'] = minblperant 00369 mytmp['minsnr'] = minsnr 00370 mytmp['solnorm'] = solnorm 00371 mytmp['gaintype'] = gaintype 00372 mytmp['smodel'] = smodel 00373 mytmp['calmode'] = calmode 00374 mytmp['append'] = append 00375 mytmp['splinetime'] = splinetime 00376 mytmp['npointaver'] = npointaver 00377 mytmp['phasewrap'] = phasewrap 00378 mytmp['gaintable'] = gaintable 00379 mytmp['gainfield'] = gainfield 00380 mytmp['interp'] = interp 00381 mytmp['spwmap'] = spwmap 00382 mytmp['gaincurve'] = gaincurve 00383 mytmp['opacity'] = opacity 00384 mytmp['parang'] = parang 00385 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00386 trec = casac.casac.utils().torecord(pathname+'gaincal.xml') 00387 00388 casalog.origin('gaincal') 00389 try : 00390 #if not trec.has_key('gaincal') or not casac.casac.utils().verify(mytmp, trec['gaincal']) : 00391 #return False 00392 00393 casac.casac.utils().verify(mytmp, trec['gaincal'], True) 00394 scriptstr=[''] 00395 saveinputs = self.__globals__['saveinputs'] 00396 saveinputs('gaincal', 'gaincal.last', myparams, self.__globals__,scriptstr=scriptstr) 00397 if async : 00398 count = 0 00399 keybase = time.strftime("%y%m%d.%H%M%S") 00400 key = keybase + "_" + str(count) 00401 while self.__async__.has_key(key) : 00402 count += 1 00403 key = keybase + "_" + str(count) 00404 result = tm.execute('gaincal', vis, caltable, field, spw, intent, selectdata, timerange, uvrange, antenna, scan, observation, msselect, solint, combine, preavg, refant, minblperant, minsnr, solnorm, gaintype, smodel, calmode, append, splinetime, npointaver, phasewrap, gaintable, gainfield, interp, spwmap, gaincurve, opacity, parang) 00405 print "Use: " 00406 print " tm.retrieve(return_value) # to retrieve the status" 00407 print 00408 self.rkey = key 00409 self.__async__[key] = result 00410 else : 00411 tname = 'gaincal' 00412 spaces = ' '*(18-len(tname)) 00413 casalog.post('\n##########################################'+ 00414 '\n##### Begin Task: ' + tname + spaces + ' #####') 00415 casalog.post(scriptstr[1][1:]+'\n', 'INFO') 00416 result = gaincal(vis, caltable, field, spw, intent, selectdata, timerange, uvrange, antenna, scan, observation, msselect, solint, combine, preavg, refant, minblperant, minsnr, solnorm, gaintype, smodel, calmode, append, splinetime, npointaver, phasewrap, gaintable, gainfield, interp, spwmap, gaincurve, opacity, parang) 00417 casalog.post('##### End Task: ' + tname + ' ' + spaces + ' #####'+ 00418 '\n##########################################') 00419 00420 except Exception, instance: 00421 if(self.__globals__.has_key('__rethrow_casa_exceptions') and self.__globals__['__rethrow_casa_exceptions']) : 00422 raise 00423 else : 00424 #print '**** Error **** ',instance 00425 tname = 'gaincal' 00426 casalog.post('An error occurred running task '+tname+'.', 'ERROR') 00427 pass 00428 00429 gc.collect() 00430 return result 00431 # 00432 # 00433 # 00434 def paramgui(self, useGlobals=True, ipython_globals=None): 00435 """ 00436 Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00437 """ 00438 import paramgui 00439 if not hasattr(self, "__globals__") or self.__globals__ == None : 00440 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00441 00442 if useGlobals: 00443 if ipython_globals == None: 00444 myf=self.__globals__ 00445 else: 00446 myf=ipython_globals 00447 00448 paramgui.setGlobals(myf) 00449 else: 00450 paramgui.setGlobals({}) 00451 00452 paramgui.runTask('gaincal', myf['_ip']) 00453 paramgui.setGlobals({}) 00454 00455 # 00456 # 00457 # 00458 def defaults(self, param=None, ipython_globals=None, paramvalue=None, subparam=None): 00459 if not hasattr(self, "__globals__") or self.__globals__ == None : 00460 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00461 if ipython_globals == None: 00462 myf=self.__globals__ 00463 else: 00464 myf=ipython_globals 00465 00466 a = odict() 00467 a['vis'] = '' 00468 a['caltable'] = '' 00469 a['field'] = '' 00470 a['spw'] = '' 00471 a['intent'] = '' 00472 a['selectdata'] = True 00473 a['solint'] = 'inf' 00474 a['combine'] = '' 00475 a['preavg'] = -1.0 00476 a['refant'] = '' 00477 a['minblperant'] = 4 00478 a['minsnr'] = 3.0 00479 a['solnorm'] = False 00480 a['gaintype'] = 'G' 00481 a['smodel'] = [] 00482 a['calmode'] = 'ap' 00483 a['append'] = False 00484 a['gaintable'] = [''] 00485 a['gainfield'] = [''] 00486 a['interp'] = [''] 00487 a['spwmap'] = [] 00488 a['gaincurve'] = False 00489 a['opacity'] = [] 00490 a['parang'] = False 00491 00492 a['async']=False 00493 a['selectdata'] = { 00494 0:{'value':False}, 00495 1:odict([{'value':True}, {'timerange':''}, {'uvrange':''}, {'antenna':''}, {'scan':''}, {'observation':''}, {'msselect':''}])} 00496 a['gaintype'] = { 00497 0:{'value':'G'}, 00498 1:{'value':'T'}, 00499 2:{'value':'K'}, 00500 3:{'value':'KCROSS'}, 00501 4:{'value':'XY+QU'}, 00502 5:odict([{'value':'GSPLINE'}, {'splinetime':3600.0}, {'npointaver':3}, {'phasewrap':180.0}])} 00503 00504 ### This function sets the default values but also will return the list of 00505 ### parameters or the default value of a given parameter 00506 if(param == None): 00507 myf['__set_default_parameters'](a) 00508 elif(param == 'paramkeys'): 00509 return a.keys() 00510 else: 00511 if(paramvalue==None and subparam==None): 00512 if(a.has_key(param)): 00513 return a[param] 00514 else: 00515 return self.itsdefault(param) 00516 else: 00517 retval=a[param] 00518 if(type(a[param])==dict): 00519 for k in range(len(a[param])): 00520 valornotval='value' 00521 if(a[param][k].has_key('notvalue')): 00522 valornotval='notvalue' 00523 if((a[param][k][valornotval])==paramvalue): 00524 retval=a[param][k].copy() 00525 retval.pop(valornotval) 00526 if(subparam != None): 00527 if(retval.has_key(subparam)): 00528 retval=retval[subparam] 00529 else: 00530 retval=self.itsdefault(subparam) 00531 else: 00532 retval=self.itsdefault(subparam) 00533 return retval 00534 00535 00536 # 00537 # 00538 def check_params(self, param=None, value=None, ipython_globals=None): 00539 if ipython_globals == None: 00540 myf=self.__globals__ 00541 else: 00542 myf=ipython_globals 00543 # print 'param:', param, 'value:', value 00544 try : 00545 if str(type(value)) != "<type 'instance'>" : 00546 value0 = value 00547 value = myf['cu'].expandparam(param, value) 00548 matchtype = False 00549 if(type(value) == numpy.ndarray): 00550 if(type(value) == type(value0)): 00551 myf[param] = value.tolist() 00552 else: 00553 #print 'value:', value, 'value0:', value0 00554 #print 'type(value):', type(value), 'type(value0):', type(value0) 00555 myf[param] = value0 00556 if type(value0) != list : 00557 matchtype = True 00558 else : 00559 myf[param] = value 00560 value = myf['cu'].verifyparam({param:value}) 00561 if matchtype: 00562 value = False 00563 except Exception, instance: 00564 #ignore the exception and just return it unchecked 00565 myf[param] = value 00566 return value 00567 # 00568 # 00569 def description(self, key='gaincal', subkey=None): 00570 desc={'gaincal': 'Determine temporal gains from calibrator observations', 00571 'vis': 'Name of input visibility file', 00572 'caltable': 'Name of output gain calibration table', 00573 'field': 'Select field using field id(s) or field name(s)', 00574 'spw': 'Select spectral window/channels', 00575 'intent': 'Select observing intent', 00576 'selectdata': 'Other data selection parameters', 00577 'timerange': 'Select data based on time range', 00578 'uvrange': 'Select data within uvrange (default units meters)', 00579 'antenna': 'Select data based on antenna/baseline', 00580 'scan': 'Scan number range', 00581 'observation': 'Select by observation ID(s)', 00582 'msselect': 'Optional complex data selection (ignore for now)', 00583 'solint': 'Solution interval: egs. \'inf\', \'60s\' (see help)', 00584 'combine': 'Data axes which to combine for solve (scan, spw, and/or field)', 00585 'preavg': 'Pre-averaging interval (sec) (rarely needed)', 00586 'refant': 'Reference antenna name(s)', 00587 'minblperant': 'Minimum baselines _per antenna_ required for solve', 00588 'minsnr': 'Reject solutions below this SNR', 00589 'solnorm': 'Normalize average solution amplitudes to 1.0 (G, T only)', 00590 'gaintype': 'Type of gain solution (G,T,GSPLINE,K,KCROSS)', 00591 'smodel': 'Point source Stokes parameters for source model.', 00592 'calmode': 'Type of solution: (\'ap\', \'p\', \'a\')', 00593 'append': 'Append solutions to the (existing) table', 00594 'splinetime': 'Spline timescale(sec); All spw\'s are first averaged.', 00595 'npointaver': 'The phase-unwrapping algorithm', 00596 'phasewrap': 'Wrap the phase for jumps greater than this value (degrees)', 00597 'gaintable': 'Gain calibration table(s) to apply on the fly', 00598 'gainfield': 'Select a subset of calibrators from gaintable(s)', 00599 'interp': 'Temporal interpolation for each gaintable (''=linear)', 00600 'spwmap': 'Spectral windows combinations to form for gaintables(s)', 00601 'gaincurve': 'Apply internal VLA antenna gain curve correction', 00602 'opacity': 'Opacity correction to apply (nepers), per spw', 00603 'parang': 'Apply parallactic angle correction on the fly', 00604 00605 'async': 'If true the taskname must be started using gaincal(...)' 00606 } 00607 00608 # 00609 # Set subfields defaults if needed 00610 # 00611 00612 if(desc.has_key(key)) : 00613 return desc[key] 00614 00615 def itsdefault(self, paramname) : 00616 a = {} 00617 a['vis'] = '' 00618 a['caltable'] = '' 00619 a['field'] = '' 00620 a['spw'] = '' 00621 a['intent'] = '' 00622 a['selectdata'] = True 00623 a['timerange'] = '' 00624 a['uvrange'] = '' 00625 a['antenna'] = '' 00626 a['scan'] = '' 00627 a['observation'] = '' 00628 a['msselect'] = '' 00629 a['solint'] = 'inf' 00630 a['combine'] = '' 00631 a['preavg'] = -1.0 00632 a['refant'] = '' 00633 a['minblperant'] = 4 00634 a['minsnr'] = 3.0 00635 a['solnorm'] = False 00636 a['gaintype'] = 'G' 00637 a['smodel'] = [] 00638 a['calmode'] = 'ap' 00639 a['append'] = False 00640 a['splinetime'] = 3600.0 00641 a['npointaver'] = 3 00642 a['phasewrap'] = 180.0 00643 a['gaintable'] = [''] 00644 a['gainfield'] = [''] 00645 a['interp'] = [''] 00646 a['spwmap'] = [] 00647 a['gaincurve'] = False 00648 a['opacity'] = [] 00649 a['parang'] = False 00650 00651 #a = sys._getframe(len(inspect.stack())-1).f_globals 00652 00653 if self.parameters['selectdata'] == True: 00654 a['timerange'] = '' 00655 a['uvrange'] = '' 00656 a['antenna'] = '' 00657 a['scan'] = '' 00658 a['observation'] = '' 00659 a['msselect'] = '' 00660 00661 if self.parameters['gaintype'] == 'GSPLINE': 00662 a['splinetime'] = 3600.0 00663 a['npointaver'] = 3 00664 a['phasewrap'] = 180.0 00665 00666 if a.has_key(paramname) : 00667 return a[paramname] 00668 gaincal_cli = gaincal_cli_()