casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2009, Associated Universities Inc., Washington DC 00005 # 00006 import sys 00007 import os 00008 from casac import * 00009 import string 00010 from taskinit import casalog 00011 #from taskmanager import tm 00012 import task_gaincal 00013 def gaincal(vis='', caltable='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', solint='inf', combine='', preavg=-1.0, refant='', minblperant=4, minsnr=3.0, solnorm=False, gaintype='G', smodel=[], calmode='ap', append=False, splinetime=3600.0, npointaver=3, phasewrap=180.0, gaintable=[''], gainfield=[''], interp=[''], spwmap=[], gaincurve=False, opacity=[], parang=False): 00014 00015 """Determine temporal gains from calibrator observations 00016 00017 The complex gains for each antenna/spwid are determined from the 00018 data column (raw data) divided by the model column. The gains can 00019 be obtained for a specified solution interval, spw combination and 00020 field combination. The GSPLINE spline (smooth) option is still under 00021 development. 00022 00023 Previous calibrations (egs, bandpass, opacity, parallactic angle) can 00024 be applied on the fly. At present with dual-polarized data, both 00025 polarizations must be unflagged for any solution to be obtained. 00026 00027 Keyword arguments: 00028 vis -- Name of input visibility file 00029 default: none; example: vis='ngc5921.ms' 00030 caltable -- Name of output gain calibration table 00031 default: none; example: caltable='ngc5921.gcal' 00032 00033 --- Data Selection (see help par.selectdata for more detailed information) 00034 00035 field -- Select field using field id(s) or field name(s). 00036 ['go listobs' to obtain the list id's or names] 00037 default: ''=all fields 00038 If field string is a non-negative integer, it is assumed a 00039 field index, otherwise, it is assumed a field name 00040 field='0~2'; field ids 0,1,2 00041 field='0,4,5~7'; field ids 0,4,5,6,7 00042 field='3C286,3C295'; field named 3C286 and 3C295 00043 field = '3,4C*'; field id 3, all names starting with 4C 00044 DON'T FORGET TO INCLUDE THE FLUX DENSITY CALIBRATOR IF YOU HAVE ONE 00045 spw -- Select spectral window/channels 00046 type 'help par.selection' for more examples. 00047 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00048 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00049 spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE 00050 spw='*:5~61'; all spw with channels 5 to 61 00051 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00052 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00053 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00054 NOTE ';' to separate channel selections 00055 spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10, 00056 spw 1, channels 20,25,30 00057 intent -- Select observing intent 00058 default: '' (no selection by intent) 00059 intent='*BANDPASS*' (selects data labelled with 00060 BANDPASS intent) 00061 selectdata -- Other data selection parameters 00062 default: False 00063 00064 Must set selectdata=True to use the following selections: 00065 00066 timerange -- Select data based on time range: 00067 default = '' (all); examples, 00068 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00069 Note: if YYYY/MM/DD is missing date defaults to first day in data set 00070 timerange='09:14:0~09:54:0' picks 40 min on first day 00071 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on NEXT day 00072 timerange='09:44:00' pick data within one integration of time 00073 timerange='>10:24:00' data after this time 00074 uvrange -- Select data within uvrange (default units meters) 00075 default: '' (all); example: 00076 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 00077 uvrange='>4klambda';uvranges greater than 4 kilo lambda 00078 antenna -- Select data based on antenna/baseline 00079 default: '' (all) 00080 If antenna string is a non-negative integer, it is assumed an 00081 antenna index, otherwise, it is assumed as an antenna name 00082 antenna='5&6'; baseline between antenna index 5 and index 6. 00083 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00084 antenna='5&6;7&8'; baselines with indices 5-6 and 7-8 00085 antenna='5'; all baselines with antenna index 5 00086 antenna='05'; all baselines with antenna number 05 (VLA old name) 00087 antenna='5,6,10'; all baselines with antennas 5,6,10 index numbers 00088 scan -- Scan number range. 00089 Check 'go listobs' to insure the scan numbers are in order. 00090 observation -- Observation ID(s). 00091 default: '' = all 00092 example: '0~2,4' 00093 msselect -- Optional complex data selection (ignore for now) 00094 00095 --- Solution parameters 00096 gaintype -- Type of gain solution (G, T, or GSPLINE) 00097 default: 'G'; example: gaintype='GSPLINE' 00098 'G' means determine gains for each polarization and sp_wid 00099 'T' obtains one solution for both polarizations; Hence. their 00100 phase offset must be first removed using a prior G. 00101 'GSPLINE' makes a spline fit to the calibrator data. It is 00102 useful for noisy data and fits a smooth curve through the 00103 calibrated amplitude and phase. However, 00104 at present GSPLINE is somewhat experimental. Use with 00105 caution and check solutions. 00106 'K' solves for simple antenna-based single-band delays 00107 via FFTs of the spectra on baselines to the 00108 reference antenna. (This is not global fringe-fitting.) 00109 'KCROSS' solves for a global cross-hand 00110 delay. Use parang=T and apply prior gain and 00111 bandpass solutions. 00112 smodel -- Point source Stokes parameters for source model (experimental) 00113 default: [] (use MODEL_DATA column) 00114 example: [1,0,0,0] (I=1, unpolarized) 00115 calmode -- Type of solution 00116 default: 'ap' (amp and phase); example: calmode='p' 00117 Options: 'p','a','ap' 00118 solint -- Solution interval (units optional) 00119 default: 'inf' (~infinite, up to boundaries controlled by combine); 00120 Options: 'inf' (~infinite), 00121 'int' (per integration) 00122 any float or integer value with or without units 00123 examples: solint='1min'; solint='60s'; solint=60 --> 1 minute 00124 solint='0s'; solint=0; solint='int' --> per integration 00125 solint-'-1s'; solint='inf' --> ~infinite, up to boundaries 00126 interacts with combine 00127 combine -- Data axes to combine for solving 00128 default: '' --> solutions will break at scan, field, and spw 00129 boundaries 00130 Options: '','scan','spw',field', or any comma-separated combination 00131 example: combine='scan,spw' --> extend solutions over scan boundaries 00132 (up to the solint), and combine spws for solving 00133 refant -- Reference antenna name(s); a prioritized list may be specified 00134 default: '' => no refant applied 00135 example: refant='4' (antenna with index 4) 00136 refant='VA04' (VLA antenna #4) 00137 refant='EA02,EA23,EA13' (EVLA antenna EA02, use 00138 EA23 and EA13 as alternates if/when EA02 00139 drops out) 00140 Use taskname=listobs for antenna listing 00141 minblperant -- Minimum number of baselines required per antenna for each solve 00142 default = 4 00143 Antennas with fewer baaselines are excluded from solutions. 00144 example: minblperant=10 => Antennas participating on 10 or more 00145 baselines are included in the solve 00146 minblperant = 1 will solve for all baseline pairs, even if only 00147 one is present in the data set. Unless closure errors are 00148 expected, use taskname=gaincal rather than taskname=blcal to 00149 obtain more options in data analysis. 00150 minsnr -- Reject solutions below this SNR 00151 default: 3.0 00152 solnorm -- Normalize average solution amps to 1.0 after solution (G, T only) 00153 default: False (no normalization) 00154 append -- Append solutions to the (existing) table 00155 default: False; overwrite existing table or make new table 00156 splinetime -- Spline timescale (sec); used for gaintype='GSPLINE' 00157 default: 3600 (1 hour); example: splinetime=1000 00158 Typical splinetime should cover about 3 to 5 calibrator scans. 00159 npointaver -- Tune phase-unwrapping algorithm for gaintype='GSPLINE' 00160 default: 3; Keep at this value 00161 phasewrap -- Wrap the phase for changes larger than this amoun (degrees) 00162 default: 180; Keep at this value 00163 00164 --- Other calibrations to apply on the fly before determining gaincal solution 00165 00166 gaintable -- Gain calibration table(s) to apply 00167 default: '' (none); 00168 examples: gaintable='ngc5921.gcal' 00169 gaintable=['ngc5921.ampcal','ngc5921.phcal'] 00170 gainfield -- Select a subset of calibrators from gaintable(s) to apply 00171 default:'' ==> all sources in table; 00172 'nearest' ==> nearest (on sky) available field in table 00173 otherwise, same syntax as field 00174 example: gainfield='0~2,5' means use fields 0,1,2,5 from gaintable 00175 gainfield=['0~3','4~6'] means use field 0 through 3 00176 from first gain file, field 4 through 6 for second. 00177 interp -- Interpolation type (in time[,freq]) to use for each gaintable. 00178 When frequency interpolation is relevant (B, Df, Xf), 00179 separate time-dependent and freq-dependent interp 00180 types with a comma (freq _after_ the comma). 00181 Specifications for frequency are ignored when the 00182 calibration table has no channel-dependence. 00183 Time-dependent interp options ending in 'PD' enable a 00184 "phase delay" correction per spw for non-channel-dependent 00185 calibration types. 00186 default: '' --> 'linear,linear' for all gaintable(s) 00187 example: interp='nearest' (in time, freq-dep will be 00188 linear, if relevant) 00189 interp='linear,cubic' (linear in time, cubic 00190 in freq) 00191 interp=',spline' (spline in freq; linear in 00192 time by default) 00193 interp=['nearest,spline','linear'] (for multiple gaintables) 00194 Options: Time: 'nearest', 'linear' 00195 Freq: 'nearest', 'linear', 'cubic', 'spline' 00196 spwmap -- Spectral windows combinations to form for gaintable(s) 00197 default: [] (apply solutions from each spw to that spw only) 00198 Example: spwmap=[0,0,1,1] means apply the caltable solutions 00199 from spw = 0 to the spw 0,1 and spw 1 to spw 2,3. 00200 spwmap=[[0,0,1,1],[0,1,0,1]] 00201 gaincurve -- Apply internal VLA antenna gain curve correction (True/False) 00202 default: False; 00203 Use gaincurve=True ONLY for VLA data 00204 opacity -- Opacity correction to apply (nepers), per spw 00205 default: [] (no opacity correction for any spw) 00206 examples: 00207 A global value for all spws: 00208 opacity=0.051 00209 Different values for spws 0,1,2: 00210 opacity=[0.051, 0.055, 0.057] 00211 (if more than 3 spws, spw 3 and higher will 00212 be assigned the last specified value, or 0.057) 00213 Typical VLA values are: 5 GHz - 0.013, 8 GHz - 0.013 00214 15 GHz - 0.016, 23 GHz - 0.051, 43 GHz - 0.07 00215 parang -- If True, apply the parallactic angle correction (required 00216 for polarization calibration) 00217 default: False 00218 preavg -- Pre-averaging interval (sec) 00219 default=-1 (none). 00220 Rarely needed. Will average data over periods shorter than 00221 the solution interval first. 00222 async -- Run asynchronously 00223 default = False; do not run asychronously 00224 00225 """ 00226 if type(smodel)==float: smodel=[smodel] 00227 if type(gaintable)==str: gaintable=[gaintable] 00228 if type(gainfield)==str: gainfield=[gainfield] 00229 if type(interp)==str: interp=[interp] 00230 if type(spwmap)==int: spwmap=[spwmap] 00231 if type(opacity)==float: opacity=[opacity] 00232 00233 # 00234 # The following is work around to avoid a bug with current python translation 00235 # 00236 mytmp = {} 00237 00238 mytmp['vis'] = vis 00239 mytmp['caltable'] = caltable 00240 mytmp['field'] = field 00241 mytmp['spw'] = spw 00242 mytmp['intent'] = intent 00243 mytmp['selectdata'] = selectdata 00244 mytmp['timerange'] = timerange 00245 mytmp['uvrange'] = uvrange 00246 mytmp['antenna'] = antenna 00247 mytmp['scan'] = scan 00248 mytmp['observation'] = observation 00249 mytmp['msselect'] = msselect 00250 mytmp['solint'] = solint 00251 mytmp['combine'] = combine 00252 mytmp['preavg'] = preavg 00253 mytmp['refant'] = refant 00254 mytmp['minblperant'] = minblperant 00255 mytmp['minsnr'] = minsnr 00256 mytmp['solnorm'] = solnorm 00257 mytmp['gaintype'] = gaintype 00258 mytmp['smodel'] = smodel 00259 mytmp['calmode'] = calmode 00260 mytmp['append'] = append 00261 mytmp['splinetime'] = splinetime 00262 mytmp['npointaver'] = npointaver 00263 mytmp['phasewrap'] = phasewrap 00264 mytmp['gaintable'] = gaintable 00265 mytmp['gainfield'] = gainfield 00266 mytmp['interp'] = interp 00267 mytmp['spwmap'] = spwmap 00268 mytmp['gaincurve'] = gaincurve 00269 mytmp['opacity'] = opacity 00270 mytmp['parang'] = parang 00271 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00272 trec = casac.utils().torecord(pathname+'gaincal.xml') 00273 00274 casalog.origin('gaincal') 00275 if trec.has_key('gaincal') and casac.utils().verify(mytmp, trec['gaincal']) : 00276 result = task_gaincal.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) 00277 00278 else : 00279 result = False 00280 return result