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_polcal 00013 def polcal(vis='', caltable='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', solint='inf', combine='scan', preavg=300.0, refant='', minblperant=4, minsnr=3.0, poltype='D+QU', smodel=[], append=False, gaintable=[''], gainfield=[''], interp=[''], spwmap=[], gaincurve=False, opacity=[]): 00014 00015 """Determine instrumental polarization calibrations 00016 00017 The instrumental polarization factors (D-terms), the calibrator polarization, 00018 and the R-L polarization angle can be determined using polcal. The solutions 00019 can be obtained for each antenna/spwid and even individual channels, if desired. 00020 Previous calibrations of the total intensity data should be applied on the fly 00021 when running polcal, since polcal uses the 'data' column, not the 'corrected' 00022 column. 00023 00024 After calibrating the gain, bandpass, and (if relevant, for channelized data) 00025 cross-hand delay, the simplest way to calibrate the polarization data is: 00026 00027 a) Run polcal with poltype = 'D+QU' on the main 'calibrator' source. The D terms 00028 and polarization (QU) of the calibrator will be determined. Relatively good 00029 parallactic angle coverage is needed. 00030 00031 b) If there is little parallactic angle coverage, place the known polarization of 00032 the main calibrator (or 0) using setjy with the appropriate fluxdensity. Then 00033 run polcal with poltype = 'D'. Run plotcal with xaxis = 'real'; yaxis ='imag' 00034 to view solutions. It is best to use an unpolarized calibrator in this 00035 instance; large systematic offsets from zero indicate significant source 00036 polarization that will bias the polarization calibration. A mechanism 00037 to constrain this bias will be made available in the near future. 00038 00039 c) To determine R-L polarization angle, use setjy to put the fluxdensity of the 00040 polarization calibrator [I,Q,U,0.0] in the model column. For resolved sources 00041 put in values associated with an appropriate u-v range. Polarized models are 00042 not yet available for the major polarization standard sources, so very 00043 resolved polarized sources should not be used. 00044 00045 d) Run polcal with poltype = 'X' and include polarization standard. Make sure to 00046 include all previous calibrations, especially the D results. Run plotxy with 00047 correlation = 'RL LR' and make sure polarization angles are as expected. 00048 00049 e) Run applycal with all calibration table, include the D and X tables. Make sure 00050 that parang = T 00051 00052 NOTE: For very high dynamic range, use poltype='Df' or 'Df+QU' to determine 00053 D terms for each channel. Similarly, poltype='Xf' can 00054 be used to determine a channel-dependent R-L phase 00055 "bandpass". 00056 NOTE: Rather than use setjy in b and c above, the new smodel 00057 parameter may be used in polcal to specify a simple 00058 point source Stokes model. 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.dcal' 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 [run listobs to obtain the list id's or names] 00070 default: ''=all fields. 00071 Most likely, the main calibrator source should be picked. 00072 If field string is a non-negative integer, it is assumed a field index 00073 otherwise, it is assumed a field name 00074 field='0~2'; field ids 0,1,2 00075 field='0,4,5~7'; field ids 0,4,5,6,7 00076 field='3C286,3C295'; field named 3C286 adn 3C295 00077 field = '3,4C*'; field id 3, all names starting with 4C 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 62 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: True 00096 timerange -- Select data based on time range: 00097 default = '' (all); examples, 00098 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00099 Note: if YYYY/MM/DD is missing dat defaults to first day in data set 00100 timerange='09:14:0~09:54:0' picks 40 min on first day 00101 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00102 timerange='09:44:00' data within one integration of time 00103 timerange='>10:24:00' data after this time 00104 uvrange -- Select data within uvrange (default units meters) 00105 default: '' (all); example: 00106 uvrange='0~1000'; uvrange from 0-1000 kilo-lamgda 00107 uvrange='>4';uvranges greater than 4 kilo-lambda 00108 antenna -- Select data based on antenna/baseline 00109 default: '' (all) 00110 If antenna string is a non-negative integer, it is assumed an antenna index 00111 otherwise, it is assumed as an antenna name 00112 antenna='5&6'; baseline between antenna index 5 and index 6. 00113 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00114 antenna='5&6;7&8'; baseline 5-6 and 7-8 00115 antenna='5'; all baselines with antenna index 5 00116 antenna='05'; all baselines with antenna name 05, i.e. VLA ant 5 00117 antenna='5,6,10'; all baselines with antennas 5, 6 and 10 00118 scan -- Scan number range 00119 observation -- Observation ID(s). 00120 default: '' = all 00121 example: '0~2,4' 00122 msselect -- Optional complex data selection (ignore for now) 00123 00124 --- Solution parameters 00125 poltype -- Type of instrumental polarization solution 00126 'D+QU' (or 'Df+QU') solve also for apparent source polarization (channelized D) 00127 Need relatively good parallactic angle coverage for this 00128 'D' (or 'Df') solve only for instrumental polarization (channelized). The 00129 I, Q, U flux density of the source can be placed in the model column using 00130 setjy. Use for poor parallactic angle coverage. 00131 'X' (or 'Xf') = solve only for position angle correction (channelized). 00132 The source must have its I, Q, U flux density in the model column 00133 or specified in smodel. If the source is resolved, use a limited 00134 uvrange that is appropriate. 00135 'D+X' (or 'Df+X') = solve also for position angle offset (channelized D) as 00136 well as the D-term. Not normally done. 00137 default: 'D+QU' 00138 The solution used the traditional linear approximation. Non-linearized options 00139 will be avaible soon. 00140 smodel -- Point source Stokes parameters for source model (experimental) 00141 default: [] (use MODEL_DATA column) 00142 examples: [1,0,0,0] (I=1, unpolarized) 00143 [5.2,0.2,0.3,0.0] (I=5.2, Q=0.2, U=0.3, V=0.0) 00144 solint -- Solution interval (units optional) 00145 default: 'inf' (~infinite, up to boundaries controlled by combine); 00146 Options: 'inf' (~infinite), 'int' (per integration), any float 00147 or integer value with or without units 00148 examples: solint='1min'; solint='60s', solint=60 --> 1 minute 00149 solint='0s'; solint=0; solint='int' --> per integration 00150 solint-'-1s'; solint='inf' --> ~infinite, up to boundaries 00151 enforced by combine 00152 combine -- Data axes to combine for solving 00153 default: 'scan' --> solutions will break at field and spw boundaries, 00154 but may extend over multiple scans (per field and spw) up 00155 to solint. 00156 Options: '','scan','spw',field', or any comma-separated combination 00157 example: combine='scan,spw' --> extend solutions over scan boundaries 00158 (up to the solint), and combine spws for solving 00159 preavg -- Pre-averaging interval (sec) 00160 default=300 00161 Interval to apply parallactic angle. 00162 refant -- Reference antenna name 00163 default: '' => refant = '0' 00164 example: refant='13' (antenna with index 13) 00165 refant='VA04' (VLA antenna #4) 00166 refant='EA02,EA23,EA13' (EVLA antenna EA02, use 00167 EA23 and EA13 as alternates if/when EA02 00168 drops out) 00169 Use 'go listobs' for antenna listing. 00170 USE SAME REFERENCE ANTENNA AS USED FOR I CALIBRATION. 00171 minblperant -- Minimum number of baselines required per antenna for each solve 00172 Antennas with fewer baaselines are excluded from solutions. Amplitude 00173 solutions with fewer than 4 baselines, and phase solutions with fewer 00174 than 3 baselines are only trivially constrained, and are no better 00175 than baseline-based solutions. 00176 default: 4 00177 example: minblperant=10 => Antennas participating on 10 or more 00178 baselines are included in the solve 00179 minsnr -- Reject solutions below this SNR 00180 default: 3.0 00181 append -- Append solutions to the (existing) table 00182 default: False; overwrite existing table or make new table 00183 00184 --- Other calibrations to apply on the fly before determining gaincal solution 00185 00186 gaintable -- Gain calibration table(s) to apply 00187 default: '' (none); BUT I CALIBRATION TABLES SHOULD GENERALLY BE INCLUDED 00188 examples: gaintable='ngc5921.gcal' 00189 gaintable=['ngc5921.ampcal','ngc5921.phcal'] 00190 gainfield -- Select a subset of calibrators from gaintable(s) 00191 default:'' ==> all sources in table; 00192 'nearest' ==> nearest (on sky) available field in table 00193 otherwise, same syntax as field 00194 example: gainfield='0~3' 00195 gainfield=['0~3','4~6'] means use field 0 through 3 00196 from first gain file, field 4 through 6 for second. 00197 interp -- Interpolation type (in time[,freq]) to use for each gaintable. 00198 When frequency interpolation is relevant (B, Df, Xf), 00199 separate time-dependent and freq-dependent interp 00200 types with a comma (freq _after_ the comma). 00201 Specifications for frequency are ignored when the 00202 calibration table has no channel-dependence. 00203 Time-dependent interp options ending in 'PD' enable a 00204 "phase delay" correction per spw for non-channel-dependent 00205 calibration types. 00206 default: '' --> 'linear,linear' for all gaintable(s) 00207 example: interp='nearest' (in time, freq-dep will be 00208 linear, if relevant) 00209 interp='linear,cubic' (linear in time, cubic 00210 in freq) 00211 interp=',spline' (spline in freq; linear in 00212 time by default) 00213 interp=['nearest,spline','linear'] (for multiple gaintables) 00214 Options: Time: 'nearest', 'linear' 00215 Freq: 'nearest', 'linear', 'cubic', 'spline' 00216 spwmap -- Spectral windows combinations to form for gaintable(s) 00217 default: [] (apply solutions from each spw to that spw only) 00218 Example: spwmap=[0,0,1,1] means apply the caltable solutions 00219 from spw = 0 to the spw 0,1 and spw 1 to spw 2,3. 00220 spwmap=[[0,0,1,1],[0,1,0,1]] 00221 gaincurve -- Apply internal VLA antenna gain curve correction (True/False) 00222 default: False; 00223 Use gaincurve=True ONLY for VLA data 00224 opacity -- Opacity correction to apply (nepers), per spw 00225 default: [] (no opacity correction for any spw) 00226 examples: 00227 A global value for all spws: 00228 opacity=0.051 00229 Different values for spws 0,1,2: 00230 opacity=[0.051, 0.055, 0.057] 00231 (if more than 3 spws, spw 3 and higher will 00232 be assigned the last specified value, or 0.057) 00233 Typical VLA values are: 5 GHz - 0.013, 8 GHz - 0.013 00234 15 GHz - 0.016, 23 GHz - 0.051, 43 GHz - 0.07 00235 async -- Run asynchronously 00236 default = False; do not run asychronously 00237 00238 """ 00239 if type(smodel)==float: smodel=[smodel] 00240 if type(gaintable)==str: gaintable=[gaintable] 00241 if type(gainfield)==str: gainfield=[gainfield] 00242 if type(interp)==str: interp=[interp] 00243 if type(spwmap)==int: spwmap=[spwmap] 00244 if type(opacity)==float: opacity=[opacity] 00245 00246 # 00247 # The following is work around to avoid a bug with current python translation 00248 # 00249 mytmp = {} 00250 00251 mytmp['vis'] = vis 00252 mytmp['caltable'] = caltable 00253 mytmp['field'] = field 00254 mytmp['spw'] = spw 00255 mytmp['intent'] = intent 00256 mytmp['selectdata'] = selectdata 00257 mytmp['timerange'] = timerange 00258 mytmp['uvrange'] = uvrange 00259 mytmp['antenna'] = antenna 00260 mytmp['scan'] = scan 00261 mytmp['observation'] = observation 00262 mytmp['msselect'] = msselect 00263 mytmp['solint'] = solint 00264 mytmp['combine'] = combine 00265 mytmp['preavg'] = preavg 00266 mytmp['refant'] = refant 00267 mytmp['minblperant'] = minblperant 00268 mytmp['minsnr'] = minsnr 00269 mytmp['poltype'] = poltype 00270 mytmp['smodel'] = smodel 00271 mytmp['append'] = append 00272 mytmp['gaintable'] = gaintable 00273 mytmp['gainfield'] = gainfield 00274 mytmp['interp'] = interp 00275 mytmp['spwmap'] = spwmap 00276 mytmp['gaincurve'] = gaincurve 00277 mytmp['opacity'] = opacity 00278 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00279 trec = casac.utils().torecord(pathname+'polcal.xml') 00280 00281 casalog.origin('polcal') 00282 if trec.has_key('polcal') and casac.utils().verify(mytmp, trec['polcal']) : 00283 result = task_polcal.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) 00284 00285 else : 00286 result = False 00287 return result