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_applycal 00013 def applycal(vis='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', gaintable=[''], gainfield=[''], interp=[''], spwmap=[], gaincurve=False, opacity=[], parang=False, calwt=True, applymode='', flagbackup=True): 00014 00015 """Apply calibrations solutions(s) to data 00016 00017 00018 Applycal reads the specified gain calibration tables, applies 00019 them to the (raw) data column (with the specified selection), 00020 and writes the calibrated results into the corrected column. 00021 This is done in one step, so all available calibration tables must 00022 be specified. Included parang, gaincurve, and opacity are used in 00023 obtaining previous calibration tables. 00024 00025 Applycal will overwrite existing corrected data, and will flag data 00026 for which there is no calibration available. 00027 00028 All calibration tables (both temporal, frequency, polarization 00029 calibrations) are specified in the gaintable parameter. The 00030 calibration values associated with a restricted list of fields 00031 can also be selected for each table in gainfield. 00032 00033 See task accum for instructions on forming calibration 00034 incrementally. See task split for copying out any portion of the data 00035 and selected columns to a new visibility file. 00036 00037 Keyword arguments: 00038 vis -- Name of input visibility file 00039 default: < none>; example: vis='ngc5921.ms' 00040 00041 --- Data Selection: the data to which the calibration will be applied 00042 (see help par.selectdata for more detailed information) 00043 00044 field -- Select field id(s) or field name(s) to apply calibration. 00045 [run listobs to obtain the list id's or names] 00046 default: ''=all fields 00047 If field's string is an integer >=0, it is assumed to be an index 00048 otherwise, it is assumed to be a field name 00049 field='0~2'; field ids 0,1,2 00050 field='0,4,5~7'; field ids 0,4,5,6,7 00051 field='3C286,3C295'; fields named 3C286 and 3C295 00052 field = '3,4C*'; field id 3, all names starting with 4C 00053 spw -- Select spectral window/channels 00054 type 'help par.selection' for more examples. 00055 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00056 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00057 spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE 00058 spw='*:5~61'; all spw with channels 5 to 62 00059 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00060 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00061 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00062 NOTE ';' to separate channel selections 00063 spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10, 00064 spw 1, channels 20,25,30 00065 intent -- Select observing intent 00066 default: '' (no selection by intent) 00067 intent='*BANDPASS*' (selects data labelled with 00068 BANDPASS intent) 00069 selectdata -- Other data selection parameters 00070 default: True 00071 timerange -- Select data based on time range: 00072 default = '' (all); examples, 00073 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00074 Note: if YYYY/MM/DD is missing, date defaults to first day in 00075 data set 00076 timerange='09:14:0~09:54:0' picks 40 min on first day 00077 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00078 timerange='09:44:00' data within one integration of time 00079 timerange='>10:24:00' data after this time 00080 uvrange -- Select data within uvrange (default units meters) 00081 default: '' (all); example: 00082 uvrange='0~1000kl'; uvrange from 0-1000 kilo-lambda 00083 uvrange='>4kl';uvranges greater than 4 kilolambda 00084 antenna -- Select data based on antenna/baseline 00085 default: '' (all) 00086 If antenna's string is an integer >=0, it is taken to be an index 00087 otherwise, it is assumed to be an antenna name 00088 antenna='5&6'; baseline between antenna index 5 and index 6. 00089 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00090 antenna='5&6;7&8'; baseline 5-6 and 7-8 00091 antenna='5'; all baselines with antenna index 5 00092 antenna='05'; all baselines with antenna name 05--vla antenna 5. 00093 antenna='5,6,10'; all baselines with antennas 5,6 and 10 00094 scan -- Scan number range 00095 observation -- Select by observation ID(s). 00096 default: '' = all 00097 example: '0~3,6' 00098 msselect -- Optional complex data selection (ignore for now) 00099 00100 --- Calibration files to apply 00101 gaintable -- Gain calibration table(s) to apply 00102 default: '' (none); 00103 examples: gaintable='ngc5921.gcal' 00104 gaintable=['n5921.ampcal','n5921.phcal','n5921.bpass'] 00105 All gain table types: 'G', GSPLINE, 'T', 'B', 'BPOLY', 'D's' 00106 can be applied. 00107 gainfield -- Select a subset of calibrators from each gaintable 00108 default:'' ==> all sources in table; 00109 'nearest' ==> nearest (on sky) available field in table 00110 otherwise, same syntax as field 00111 example: gainfield='0~3' 00112 gainfield=['0~3','4~6'] (for multiple gaintables) 00113 interp -- Interpolation type (in time[,freq]) to use for each gaintable. 00114 When frequency interpolation is relevant (B, Df, Xf), 00115 separate time-dependent and freq-dependent interp 00116 types with a comma (freq _after_ the comma). 00117 Specifications for frequency are ignored when the 00118 calibration table has no channel-dependence. 00119 Time-dependent interp options ending in 'PD' enable a 00120 "phase delay" correction per spw for non-channel-dependent 00121 calibration types. 00122 default: '' --> 'linear,linear' for all gaintable(s) 00123 example: interp='nearest' (in time, freq-dep will be 00124 linear, if relevant) 00125 interp='linear,cubic' (linear in time, cubic 00126 in freq) 00127 interp=',spline' (spline in freq; linear in 00128 time by default) 00129 interp=['nearest,spline','linear'] (for multiple gaintables) 00130 Options: Time: 'nearest', 'linear', 'nearestPD', 'linearPD' 00131 Freq: 'nearest', 'linear', 'cubic', 'spline' 00132 spwmap -- Spectral windows combinations to form for gaintable(s) 00133 default: [] (apply solutions from each spw to that spw only) 00134 Example: spwmap=[0,0,1,1] means apply the caltable solutions 00135 from spw = 0 to the spw 0,1 and spw 1 to spw 2,3. 00136 spwmap=[[0,0,1,1],[0,1,0,1]] (for multiple gaintables) 00137 00138 Complicated example: 00139 00140 gaintable=['tab1','tab2','tab3'] 00141 gainfield='3C286' 00142 interp=['linear','nearest'] 00143 spwmap=[[],[0,0,2]] 00144 00145 This means: apply 3 cal tables, selecting only solutions for 3C286 00146 from tab1 (but all fields from tab2 and tab3, indicated by 00147 no gainfield entry for these files). Linear interpolation 00148 (in time) will be used for 'tab1' and 'tab3' (default); 'tab2' will 00149 use nearest. For the 'tab2', the calibration spws map 00150 will be mapped to the data spws according to 0->0, 0->1, 2->2. 00151 (I.e., for data spw=0 and 2, the spw mapping is one to one, 00152 but data spw 1 will be calibrated by solutions from spw 0.) 00153 00154 gaincurve -- Apply internal VLA/EVLA antenna gain curve correction (True/False) 00155 default: False; 00156 Use gaincurve=True ONLY for VLA or EVLA data 00157 opacity -- Opacity correction to apply (nepers), per spw 00158 default: [] (no opacity correction for any spw) 00159 examples: 00160 A global value for all spws: 00161 opacity=0.051 00162 Different values for spws 0,1,2: 00163 opacity=[0.051, 0.055, 0.057] 00164 (if fewer opacity values than spws are specified, 00165 then the last-specified value will be duplicated 00166 for all higher-numbered spws, e.g., in the above 00167 example, 0.057 will be used for spws 3 and higher, 00168 if they exist) 00169 Typical VLA values are: 5 GHz - 0.013, 8 GHz - 0.013 00170 15 GHz - 0.016, 23 GHz - 0.051, 43 GHz - 0.07 00171 parang -- If True, apply the parallactic angle correction. FOR ANY 00172 POLARIZATION CALIBRATION AND IMAGING, parang = True 00173 default: False 00174 calwt -- Calibrate weights along with data for all 00175 relevant calibrations 00176 default: True; example: calwt=False 00177 applymode -- Calibration apply mode: 00178 ''='calflag' (default) calibrate data and apply flags from solutions 00179 'trial' report on flags from solutions, dataset entirely unchanged 00180 'flagonly' apply flags from solutions only, data not calibrated 00181 'calonly' calibrate data only (by unflagged solutions), flags from solutions NOT applied (use with extreme caution!) 00182 flagbackup -- Back up the state of the flags before applying calibration 00183 default: True 00184 async -- Run task in a separate process 00185 default: False; example: async=True 00186 00187 00188 00189 """ 00190 if type(gaintable)==str: gaintable=[gaintable] 00191 if type(gainfield)==str: gainfield=[gainfield] 00192 if type(interp)==str: interp=[interp] 00193 if type(spwmap)==int: spwmap=[spwmap] 00194 if type(opacity)==float: opacity=[opacity] 00195 00196 # 00197 # The following is work around to avoid a bug with current python translation 00198 # 00199 mytmp = {} 00200 00201 mytmp['vis'] = vis 00202 mytmp['field'] = field 00203 mytmp['spw'] = spw 00204 mytmp['intent'] = intent 00205 mytmp['selectdata'] = selectdata 00206 mytmp['timerange'] = timerange 00207 mytmp['uvrange'] = uvrange 00208 mytmp['antenna'] = antenna 00209 mytmp['scan'] = scan 00210 mytmp['observation'] = observation 00211 mytmp['msselect'] = msselect 00212 mytmp['gaintable'] = gaintable 00213 mytmp['gainfield'] = gainfield 00214 mytmp['interp'] = interp 00215 mytmp['spwmap'] = spwmap 00216 mytmp['gaincurve'] = gaincurve 00217 mytmp['opacity'] = opacity 00218 mytmp['parang'] = parang 00219 mytmp['calwt'] = calwt 00220 mytmp['applymode'] = applymode 00221 mytmp['flagbackup'] = flagbackup 00222 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00223 trec = casac.utils().torecord(pathname+'applycal.xml') 00224 00225 casalog.origin('applycal') 00226 if trec.has_key('applycal') and casac.utils().verify(mytmp, trec['applycal']) : 00227 result = task_applycal.applycal(vis, field, spw, intent, selectdata, timerange, uvrange, antenna, scan, observation, msselect, gaintable, gainfield, interp, spwmap, gaincurve, opacity, parang, calwt, applymode, flagbackup) 00228 00229 else : 00230 result = False 00231 return result