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_bandpass 00013 def bandpass(vis='', caltable='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', solint='inf', combine='scan', refant='', minblperant=4, minsnr=3.0, solnorm=False, bandtype='B', smodel=[], append=False, fillgaps=0, degamp=3, degphase=3, visnorm=False, maskcenter=0, maskedge=5, gaintable=[''], gainfield=[''], interp=[''], spwmap=[], gaincurve=False, opacity=[], parang=False): 00014 00015 """Calculates a bandpass calibration solution 00016 00017 Determines the amplitude and phase as a function of frequency for 00018 each spectral window containing more than one channel. Strong sources 00019 (or many observations of moderately strong sources) are needed to obtain 00020 accurate bandpass functions. The two solution choices are: Individual 00021 antenna/based channel solutions 'B'; and a polynomial fit over the channels 00022 'BPOLY'. The 'B' solutions can determined at any specified time interval, and 00023 is recommended if each channel has good signal-to-noise. Other, 'BPOLY' is 00024 recommended. 00025 00026 Keyword arguments: 00027 vis -- Name of input visibility file 00028 default: none; example: vis='ngc5921.ms' 00029 caltable -- Name of output bandpass calibration table 00030 default: none; example: caltable='ngc5921.bcal' 00031 00032 --- Data Selection (see help par.selectdata for more detailed information) 00033 00034 field -- Select field using field id(s) or field name(s). 00035 [run listobs to obtain the list id's or names] 00036 default: ''=all fields 00037 If field string is a non-negative integer, it is assumed a field index 00038 otherwise, it is assumed a field name 00039 field='0~2'; field ids 0,1,2 00040 field='0,4,5~7'; field ids 0,4,5,6,7 00041 field='3C286,3C295'; field named 3C286 adn 3C295 00042 field = '3,4C*'; field id 3, all names starting with 4C 00043 spw -- Select spectral window/channels 00044 default: ''=all spectral windows and channels 00045 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00046 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00047 spw='0:5~61'; spw 0, channels 5 to 61 00048 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00049 spw='0~2:2:6'; spw 0,1,2 with channels 2 through 6 in each. 00050 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00051 NOTE: ';' to separate channel selections 00052 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10, 00053 spw 1, channels 20-30, and spw 2, channels, 1,2 and 3 00054 intent -- Select observing intent 00055 default: '' (no selection by intent) 00056 intent='*BANDPASS*' (selects data labelled with 00057 BANDPASS intent) 00058 selectdata -- Other data selection parameters 00059 default: True 00060 timerange -- Select data based on time range: 00061 default = '' (all); examples, 00062 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00063 Note: if YYYY/MM/DD is missing dat defaults to first day in data set 00064 timerange='09:14:0~09:54:0' picks 40 min on first day 00065 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00066 timerange='09:44:00' data within one integration of time 00067 timerange='>10:24:00' data after this time 00068 uvrange -- Select data within uvrange (default meters) 00069 default: '' (all); example: 00070 uvrange='0~1000kl'; uvrange from 0-1000 kilo-lamgda 00071 uvrange='>4kl';uvranges greater than 4 kilo-lambda 00072 antenna -- Select data based on antenna/baseline 00073 default: '' (all) 00074 If antenna string is a non-negative integer, it is assumed an antenna index 00075 otherwise, it is assumed as an antenna name 00076 antenna='5&6'; baseline between antenna index 5 and index 6. 00077 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00078 antenna='5&6;7&8'; baseline 5-6 and 7-8 00079 antenna='5'; all baselines with antenna 5 00080 antenna='5,6,10'; all baselines with antennas 5, 6 and 10 00081 scan -- Select data based on scan number - New, under developement 00082 default: '' (all); example: scan='>3' 00083 observation -- Observation ID(s). 00084 default: '' = all 00085 example: '0~2,4' 00086 msselect -- Optional complex data selection (ignore for now) 00087 00088 --- Solution parameters 00089 solint -- Solution interval in time (units optional), and (optionally) 00090 in frequency. Frequency pre-averaging can be 00091 specified after a comma in units of channels or Hz. 00092 If nothing is specified for frequency, no freq pre-averaging 00093 will be done. 00094 default: 'inf' (~infinite, up to boundaries controlled by combine, 00095 with no pre-averaging in frequency) 00096 Options for time: 'inf' (~infinite), 'int' (per integration), any float 00097 or integer value with or without units 00098 Options for freq: an integer with 'ch' suffix will enforce 00099 pre-averaging by the specified number 00100 of channels. 00101 a numeric value suffixed with frequency 00102 units (e.g., 'Hz','kHz','MHz') will enforce 00103 pre-averaging by an integral number of 00104 channels amounting to no more than the 00105 specified bandwidth 00106 examples: solint='1min'; solint='60s', solint=60 --> 1 minute 00107 solint='0s'; solint=0; solint='int' --> per integration 00108 solint='-1s'; solint='inf' --> ~infinite, up to boundaries 00109 enforced by combine 00110 solint='inf,8Mhz' --> ~infinite in time, with 00111 8MHz pre-average in freq 00112 solint='int,32ch' --> per-integration in time, 00113 with 32-channel pre-average 00114 in freq 00115 combine -- Data axes to combine for solving 00116 default: 'scan' --> solutions will break at field and spw boundaries, 00117 but may extend over multiple scans (per field and spw) up 00118 to solint. 00119 Options: '','scan','spw',field', or any comma-separated combination 00120 example: combine='scan,spw' --> extend solutions over scan boundaries 00121 (up to the solint), and combine spws for solving 00122 refant -- Reference antenna name(s); a prioritized list may be specified 00123 default: '' (no reference antenna) 00124 example: refant='13' (antenna with index 13) 00125 refant='VA04' (VLA antenna #4) 00126 refant='EA02,EA23,EA13' (EVLA antenna EA02, use 00127 EA23 and EA13 as alternates if/when EA02 00128 drops out) 00129 Use 'go listobs' for antenna listing 00130 minblperant -- Minimum number of baselines required per antenna for each solve 00131 Antennas with fewer baaselines are excluded from solutions. Amplitude 00132 solutions with fewer than 4 baselines, and phase solutions with fewer 00133 than 3 baselines are only trivially constrained, and are no better 00134 than baseline-based solutions. 00135 default: 4 00136 example: minblperant=10 => Antennas participating on 10 or more 00137 baselines are included in the solve 00138 minsnr -- Reject solutions below this SNR (only applies for bandtype = B) 00139 default: 3.0 00140 solnorm -- Normalize bandpass amplitudes and phase for each 00141 spw, pol, ant, and timestamp 00142 default: False (no normalization) 00143 bandtype -- Type of bandpass solution (B or BPOLY) 00144 default: 'B'; example: bandtype='BPOLY' 00145 'B' does a channel by channel solution for each 00146 specified spw. 00147 'BPOLY' is somewhat experimental. It will fit an 00148 nth order polynomial for the amplitude and phase 00149 as a function of frequency. Only one fit is made 00150 for all specified spw, and edge channels should be 00151 omitted. 00152 Use taskname=plotcal in order to compare the results from 00153 B and BPOLY. 00154 fillgaps -- Fill flagged solution channels by interpolation 00155 default: 0 (don't interpolate) 00156 example: fillgaps=3 (interpolate gaps 3 channels wide and narrower) 00157 degamp -- Polynomial degree for BPOLY amplitude solution 00158 default: 3; example: degamp=2 00159 degphase -- Polynomial degree for BPOLY phase solution 00160 default: 3; example: degphase=2 00161 visnorm -- Normalize data prior to BPOLY solution 00162 default: False; example: visnorm=True 00163 maskcenter -- Number of channels to avoid in center of each band 00164 default: 0; example: maskcenter=5 (BPOLY only) 00165 maskedge -- Fraction of channels to avoid at each band edge (in %) 00166 default: 5; example: maskedge=3 (BPOLY only) 00167 append -- Append solutions to the (existing) table 00168 default: False; example: append=True 00169 00170 --- Other calibrations to apply on the fly before determining bandpass solution 00171 00172 gaintable -- Gain calibration table(s) to apply 00173 default: '' (none); 00174 examples: gaintable='ngc5921.gcal' 00175 gaintable=['ngc5921.ampcal','ngc5921.phcal'] 00176 gainfield -- Select a subset of calibrators from gaintable(s) 00177 default:'' ==> all sources in table; 00178 'nearest' ==> nearest (on sky) available field in table 00179 otherwise, same syntax as field 00180 example: gainfield='0~3' 00181 gainfield=['0~3','4~6'] 00182 interp -- Interpolation type (in time[,freq]) to use for each gaintable. 00183 When frequency interpolation is relevant (B, Df, Xf), 00184 separate time-dependent and freq-dependent interp 00185 types with a comma (freq _after_ the comma). 00186 Specifications for frequency are ignored when the 00187 calibration table has no channel-dependence. 00188 Time-dependent interp options ending in 'PD' enable a 00189 "phase delay" correction per spw for non-channel-dependent 00190 calibration types. 00191 default: '' --> 'linear,linear' for all gaintable(s) 00192 example: interp='nearest' (in time, freq-dep will be 00193 linear, if relevant) 00194 interp='linear,cubic' (linear in time, cubic 00195 in freq) 00196 interp=',spline' (spline in freq; linear in 00197 time by default) 00198 interp=['nearest,spline','linear'] (for multiple gaintables) 00199 Options: Time: 'nearest', 'linear' 00200 Freq: 'nearest', 'linear', 'cubic', 'spline' 00201 spwmap -- Spectral windows combinations to form for gaintable(s) 00202 default: [] (apply solutions from each spw to that spw only) 00203 Example: spwmap=[0,0,1,1] means apply the caltable solutions 00204 from spw = 0 to the spw 0,1 and spw 1 to spw 2,3. 00205 spwmap=[[0,0,1,1],[0,1,0,1]] 00206 gaincurve -- Apply internal VLA antenna gain curve correction (True/False) 00207 default: False; 00208 Use gaincurve=True ONLY for VLA data 00209 opacity -- Opacity correction to apply (nepers), per spw 00210 default: [] (no opacity correction for any spw) 00211 examples: 00212 A global value for all spws: 00213 opacity=0.051 00214 Different values for spws 0,1,2: 00215 opacity=[0.051, 0.055, 0.057] 00216 (if more than 3 spws, spw 3 and higher will 00217 be assigned the last specified value, or 0.057) 00218 Typical VLA values are: 5 GHz - 0.013, 8 GHz - 0.013 00219 15 GHz - 0.016, 23 GHz - 0.051, 43 GHz - 0.07 00220 parang -- If True, apply the parallactic angle correction (required 00221 for polarization calibration) 00222 default: False 00223 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['refant'] = refant 00253 mytmp['minblperant'] = minblperant 00254 mytmp['minsnr'] = minsnr 00255 mytmp['solnorm'] = solnorm 00256 mytmp['bandtype'] = bandtype 00257 mytmp['smodel'] = smodel 00258 mytmp['append'] = append 00259 mytmp['fillgaps'] = fillgaps 00260 mytmp['degamp'] = degamp 00261 mytmp['degphase'] = degphase 00262 mytmp['visnorm'] = visnorm 00263 mytmp['maskcenter'] = maskcenter 00264 mytmp['maskedge'] = maskedge 00265 mytmp['gaintable'] = gaintable 00266 mytmp['gainfield'] = gainfield 00267 mytmp['interp'] = interp 00268 mytmp['spwmap'] = spwmap 00269 mytmp['gaincurve'] = gaincurve 00270 mytmp['opacity'] = opacity 00271 mytmp['parang'] = parang 00272 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00273 trec = casac.utils().torecord(pathname+'bandpass.xml') 00274 00275 casalog.origin('bandpass') 00276 if trec.has_key('bandpass') and casac.utils().verify(mytmp, trec['bandpass']) : 00277 result = task_bandpass.bandpass(vis, caltable, field, spw, intent, selectdata, timerange, uvrange, antenna, scan, observation, msselect, solint, combine, refant, minblperant, minsnr, solnorm, bandtype, smodel, append, fillgaps, degamp, degphase, visnorm, maskcenter, maskedge, gaintable, gainfield, interp, spwmap, gaincurve, opacity, parang) 00278 00279 else : 00280 result = False 00281 return result