Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/bandpass.py: 89%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 07:19 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 07:19 +0000
1##################### generated by xml-casa (v2) from bandpass.xml ##################
2##################### 83925879e747e0b20387dd8ace9a53fa ##############################
3from __future__ import absolute_import
4import numpy
5from casatools.typecheck import CasaValidator as _val_ctor
6_pc = _val_ctor( )
7from casatools.coercetype import coerce as _coerce
8from casatools.errors import create_error_string
9from .private.task_bandpass import bandpass as _bandpass_t
10from casatasks.private.task_logging import start_log as _start_log
11from casatasks.private.task_logging import end_log as _end_log
12from casatasks.private.task_logging import except_log as _except_log
14class _bandpass:
15 """
16 bandpass ---- Calculates a bandpass calibration solution
19 Determines the amplitude and phase as a function of frequency for each
20 spectral window containing more than one channel. Strong sources (or
21 many observations of moderately strong sources) are needed to obtain
22 accurate bandpass functions. The two solution choices are: Individual
23 antenna/based channel solutions 'B'; and a polynomial fit over the
24 channels 'BPOLY'. The 'B' solutions can determined at any specified
25 time interval, and is recommended if each channel has good
26 signal-to-noise.
28 --------- parameter descriptions ---------------------------------------------
30 vis Name of input visibility file
31 default: non
33 Example: vis='ngc5921.ms'
34 caltable Name of output bandpass calibration table
35 default: none
37 Example: caltable='ngc5921.bcal'
38 field Select field using field id(s) or field name(s)
39 default: '' --> all fields
41 Use 'go listobs' to obtain the list id's or
42 names. If field string is a non-negative integer,
43 it is assumed a field index, otherwise, it is
44 assumed a field name.
46 Examples:
47 field='0~2'; field ids 0,1,2
48 field='0,4,5~7'; field ids 0,4,5,6,7
49 field='3C286,3C295'; field named 3C286 and
50 3C295
51 field = '3,4C\*'; field id 3, all names
52 starting with 4C
53 spw Select spectral window/channels
55 Examples:
56 spw='0~2,4'; spectral windows 0,1,2,4 (all
57 channels)
58 spw='<2'; spectral windows less than 2
59 (i.e. 0,1)
60 spw='0:5~61'; spw 0, channels 5 to 61,
61 INCLUSIVE
62 spw='\*:5~61'; all spw with channels 5 to 61
63 spw='0,10,3:3~45'; spw 0,10 all channels, spw
64 3, channels 3 to 45.
65 spw='0~2:2~6'; spw 0,1,2 with channels 2
66 through 6 in each.
67 spw='0:0~10;15~60'; spectral window 0 with
68 channels 0-10,15-60. (NOTE ';' to separate
69 channel selections)
70 spw='0:0~10^2,1:20~30^5'; spw 0, channels
71 0,2,4,6,8,10, spw 1, channels 20,25,30
72 type 'help par.selection' for more examples.
73 intent Select observing intent
74 default: '' (no selection by intent)
76 Example: intent='\*BANDPASS\*' (selects data
77 labelled with BANDPASS intent)
78 selectdata Other data selection parameters
79 default: True
80 timerange Select data based on time range
81 Subparameter of selectdata=True
82 default = '' (all)
84 Examples:
85 timerange =
86 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
87 (Note: if YYYY/MM/DD is missing date defaults
88 to first day in data set.)
89 timerange='09:14:0~09:54:0' picks 40 min on
90 first day
91 timerange= '25:00:00~27:30:00' picks 1 hr to 3
92 hr 30min on NEXT day
93 timerange='09:44:00' pick data within one
94 integration of time
95 timerange='>10:24:00' data after this time
96 uvrange Select data within uvrange (default units meters)
97 Subparameter of selectdata=True
98 default: '' (all)
100 Examples:
101 uvrange='0~1000klambda'; uvrange from 0-1000
102 kilo-lambda
103 uvrange='>4klambda';uvranges greater than 4
104 kilolambda
105 antenna Select data based on antenna/baseline
106 Subparameter of selectdata=True
107 default: '' (all)
109 Examples:
110 antenna='5&6'; baseline between antenna
111 index 5 and index 6.
112 antenna='VA05&VA06'; baseline between VLA
113 antenna 5 and 6.
114 antenna='5&6;7&8'; baselines with
115 indices 5-6 and 7-8
116 antenna='5'; all baselines with antenna index
117 5
118 antenna='05'; all baselines with antenna
119 number 05 (VLA old name)
120 antenna='5,6,10'; all baselines with antennas
121 5,6,10 index numbers
123 Note: just for antenna selection, an integer (or
124 integer list) is converted to a string and
125 matched against the antenna 'name' first. Only if
126 that fails, the integer is matched with the
127 antenna ID. The latter is the case for most
128 observatories, where the antenna name is not
129 strictly an integer.
130 scan Scan number range
131 Subparameter of selectdata=True
132 default: '' = all
134 Check 'go listobs' to insure the scan numbers are
135 in order.
136 observation Select by observation ID(s)
137 Subparameter of selectdata=True
138 default: '' = all
140 Example: observation='0~2,4'
141 msselect Optional complex data selection (ignore for now)
142 solint Solution interval in time[,freq]
143 default: 'inf' (~infinite, up to boundaries
144 controlled by combine, with no pre-averaging in
145 frequency)
146 Options for time: 'inf' (~infinite), 'int' (per
147 integration), any float or integer value with or
148 without units
149 Options for freq: an integer with 'ch' suffix
150 will enforce pre-averaging by the specified
151 number of channels. A numeric value suffixed with
152 frequency units (e.g., 'Hz','kHz','MHz') will
153 enforce pre-averaging by an integral number of
154 channels amounting to no more than the specified
155 bandwidth.
157 Examples: solint='1min'; solint='60s',
158 solint=60 --> 1 minute
159 solint='0s'; solint=0; solint='int' --> per
160 integration
161 solint='-1s'; solint='inf' --> ~infinite, up
162 to boundaries enforced by combine
163 solint='inf,8Mhz' --> ~infinite in time, with
164 8MHz pre-average in freq
165 solint='int,32ch' --> per-integration in time,
166 with 32-channel pre-average in freq
167 combine Data axes to combine for solving
168 default: 'scan' --> solutions will break at obs,
169 field, and spw boundaries but may extend over
170 multiple scans (per obs, field and spw) up to
171 solint.
172 Options: '','obs','scan','spw',field', or any
173 comma-separated combination in a single string.
175 Example: combine='scan,spw' --> extend
176 solutions over scan boundaries (up to the
177 solint), and combine spws for solving.
178 refant Reference antenna name(s); a prioritized list may be
179 specified
180 default: '' (no reference antenna)
182 Examples:
183 refant='13' (antenna with index 13)
184 refant='VA04' (VLA antenna #4)
185 refant='EA02,EA23,EA13' (EVLA antenna EA02,
186 use EA23 and EA13 as alternates if/when EA02
187 drops out)
189 Use 'go listobs' for antenna listing
190 minblperant Minimum baselines _per antenna_ required for solve
191 default: 4
193 Antennas with fewer baselines are excluded from
194 solutions. Amplitude solutions with fewer than 4
195 baselines, and phase solutions with fewer than 3
196 baselines are only trivially constrained, and are
197 no better than baseline-based solutions.
199 example: minblperant=10 --> Antennas
200 participating on 10 or more baselines are
201 included in the solve.
202 minsnr Reject solutions below this SNR (only applies for
203 bandtype = B)
204 default: 3.0
205 solnorm Normalize bandpass amplitudes and phase for each spw,
206 pol, ant, and timestamp
207 default: False (no normalization)
208 bandtype Type of bandpass solution (B or BPOLY)
209 default: 'B'
211 'B' does a channel by channel solution for each
212 specified spw.
213 'BPOLY' is somewhat experimental. It will fit an
214 nth order polynomial for the amplitude and phase
215 as a function of frequency. Only one fit is made
216 for all specified spw, and edge channels should
217 be omitted.
218 Use taskname=plotms in order to compare the
219 results from B and BPOLY.
221 Example: bandtype='BPOLY'
222 smodel Point source Stokes parameters for source model.
223 corrdepflags f False (default), if any correlation is flagged, treat all correlations in
224 the visibility vector as flagged when solving (per channel, per baseline).
225 If True, use unflagged correlations in a visibility vector, even if one or more
226 other correlations are flagged.
228 Default: False (treat correlation vectors with one or more correlations flagged as entirely flagged)
230 Traditionally, CASA has observed a strict interpretation of
231 correlation-dependent flags: if one or more correlations
232 (for any baseline and channel) is flagged, then all available
233 correlations for the same baseline and channel are
234 treated as flagged. However, it is desirable in some
235 circumstances to relax this stricture, e.g., to preserve use
236 of data from antennas with only one good polarization (e.g., one polarization
237 is bad or entirely absent). Solutions for the bad or missing polarization
238 will be rendered as flagged.
239 append Append solutions to the (existing) table
240 default: False (overwrite existing table or make
241 new table)
243 Append solutions to the (existing) table.
244 Appended solutions must be derived from the same
245 MS as the existing caltable, and solution spws
246 must have the same meta-info (according to spw
247 selection and solint) or be non-overlapping.
248 fillgaps Fill flagged solution channels by interpolation
249 Subparameter of bandtype='B'
250 default: 0 (don't interpolate)
252 Example: fillgaps=3 (interpolate gaps 3
253 channels wide and narrower)
254 degamp Polynomial degree for BPOLY amplitude solution
255 Subparameter of bandtype='BPOLY'
256 default: 3
258 Example: degamp=2
259 degphase Polynomial degree for BPOLY phase solution
260 Subparameter of bandtype='BPOLY'
261 default: 3
263 Example: degphase=2
264 visnorm Normalize data prior to BPOLY solution
265 Subparameter of bandtype='BPOLY'
266 default: False
268 Example: visnorm=True
269 maskcenter Number of channels to avoid in center of each band
270 Subparameter of bandtype='BPOLY'
271 default: 0
273 Example: maskcenter=5 (BPOLY only)
274 maskedge Fraction of channels to avoid at each band edge (in %)
275 Subparameter of bandtype='BPOLY'
276 default: 5
278 Example: maskedge=3 (BPOLY only)
279 docallib Control means of specifying the caltables
280 default: False --> Use gaintable, gainfield,
281 interp, spwmap, calwt.
283 If True, specify a file containing cal library in
284 callib
285 callib Cal Library filename
286 Subparameter of callib=True
288 If docallib=True, specify a file containing cal
289 library directives
290 gaintable Gain calibration table(s) to apply on the fly
291 Subparameter of callib=False
292 default: '' (none)
294 Examples: gaintable='ngc5921.gcal'
295 gaintable=['ngc5921.ampcal','ngc5921.phcal']
296 gainfield Select a subset of calibrators from gaintable(s)
297 Subparameter of callib=False
298 default:'' --> all sources in table
300 gaintable='nearest' --> nearest (on sky)
301 available field in table. Otherwise, same syntax
302 as field
304 Examples:
305 gainfield='0~2,5' means use fields 0,1,2,5
306 from gaintable
307 gainfield=['0~3','4~6'] (for multiple
308 gaintables)
309 interp Interpolation parmameters (in time[,freq]) for each gaintable, as a list of strings.
310 Default: '' --> 'linear,linear' for all gaintable(s)
311 Options: Time: 'nearest', 'linear'
312 Freq: 'nearest', 'linear', 'cubic',
313 'spline'
314 Specify a list of strings, aligned with the list of caltable specified
315 in gaintable, that contain the required interpolation parameters
316 for each caltable.
318 - When frequency interpolation is relevant (B, Df,
319 Xf), separate time-dependent and freq-dependent
320 interp types with a comma (freq after the
321 comma).
322 - Specifications for frequency are ignored when the
323 calibration table has no channel-dependence.
324 - Time-dependent interp options ending in 'PD'
325 enable a "phase delay" correction per spw for
326 non-channel-dependent calibration types.
327 - For multi-obsId datasets, 'perobs' can be
328 appended to the time-dependent interpolation
329 specification to enforce obsId boundaries when
330 interpolating in time.
331 - For multi-scan datasets, 'perscan' can be
332 appended to the time-dependent interpolation
333 specification to enforce scan boundaries when
334 interpolating in time.
335 - Freq-dependent interp options can have 'flag' appended
336 to enforce channel-dependent flagging, and/or 'rel'
337 appended to invoke relative frequency interpolation
339 Examples:
340 interp='nearest' (in time, freq-dep will be
341 linear, if relevant)
342 interp='linear,cubic' (linear in time, cubic
343 in freq)
344 interp='linearperobs,splineflag' (linear in
345 time per obsId, spline in freq with
346 channelized flagging)
347 interp='nearest,linearflagrel' (nearest in
348 time, linear in freq with with channelized
349 flagging and relative-frequency interpolation)
350 interp=',spline' (spline in freq; linear in
351 time by default)
352 interp=['nearest,spline','linear'] (for
353 multiple gaintables)
354 spwmap Spectral window mappings to form for gaintable(s)
355 Only used if callib=False
356 default: [] (apply solutions from each calibration spw to
357 the same MS spw only)
358 Any available calibration spw can be mechanically mapped to any
359 MS spw.
360 Examples:
361 spwmap=[0,0,1,1] means apply calibration
362 from cal spw = 0 to MS spw 0,1 and cal spw 1 to MS spws 2,3.
363 spwmap=[[0,0,1,1],[0,1,0,1]] (use a list of lists for multiple
364 gaintables)
365 parang Apply parallactic angle correction
366 default: False
368 If True, apply the parallactic angle correction
369 (required for polarization calibration)
371 --------- examples -----------------------------------------------------------
375 For more information, see the task pages of bandpass in CASA Docs:
377 https://casa.nrao.edu/casadocs/
380 """
382 _info_group_ = """calibration"""
383 _info_desc_ = """Calculates a bandpass calibration solution"""
385 def __call__( self, vis='', caltable='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', solint='inf', combine='scan', refant='', minblperant=int(4), minsnr=float(3.0), solnorm=False, bandtype='B', smodel=[ ], corrdepflags=False, append=False, fillgaps=int(0), degamp=int(3), degphase=int(3), visnorm=False, maskcenter=int(0), maskedge=int(5), docallib=False, callib='', gaintable=[ ], gainfield=[ ], interp=[ ], spwmap=[ ], parang=False ):
386 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'caltable': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'selectdata': {'type': 'cBool'}, 'timerange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'uvrange': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'scan': {'type': 'cStr', 'coerce': _coerce.to_str}, 'observation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}]}, 'msselect': {'type': 'cStr', 'coerce': _coerce.to_str}, 'solint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'combine': {'type': 'cStr', 'coerce': _coerce.to_str}, 'refant': {'type': 'cStr', 'coerce': _coerce.to_str}, 'minblperant': {'type': 'cInt'}, 'minsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'solnorm': {'type': 'cBool'}, 'bandtype': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'B', 'BPOLY' ]}, 'smodel': {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, 'corrdepflags': {'type': 'cBool'}, 'append': {'type': 'cBool'}, 'fillgaps': {'type': 'cInt'}, 'degamp': {'type': 'cInt'}, 'degphase': {'type': 'cInt'}, 'visnorm': {'type': 'cBool'}, 'maskcenter': {'type': 'cInt'}, 'maskedge': {'type': 'cInt'}, 'docallib': {'type': 'cBool'}, 'callib': {'type': 'cStr', 'coerce': _coerce.to_str}, 'gaintable': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'gainfield': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'interp': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'spwmap': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'parang': {'type': 'cBool'}}
387 doc = {'vis': vis, 'caltable': caltable, 'field': field, 'spw': spw, 'intent': intent, 'selectdata': selectdata, 'timerange': timerange, 'uvrange': uvrange, 'antenna': antenna, 'scan': scan, 'observation': observation, 'msselect': msselect, 'solint': solint, 'combine': combine, 'refant': refant, 'minblperant': minblperant, 'minsnr': minsnr, 'solnorm': solnorm, 'bandtype': bandtype, 'smodel': smodel, 'corrdepflags': corrdepflags, 'append': append, 'fillgaps': fillgaps, 'degamp': degamp, 'degphase': degphase, 'visnorm': visnorm, 'maskcenter': maskcenter, 'maskedge': maskedge, 'docallib': docallib, 'callib': callib, 'gaintable': gaintable, 'gainfield': gainfield, 'interp': interp, 'spwmap': spwmap, 'parang': parang}
388 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
389 _logging_state_ = _start_log( 'bandpass', [ 'vis=' + repr(_pc.document['vis']), 'caltable=' + repr(_pc.document['caltable']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'intent=' + repr(_pc.document['intent']), 'selectdata=' + repr(_pc.document['selectdata']), 'timerange=' + repr(_pc.document['timerange']), 'uvrange=' + repr(_pc.document['uvrange']), 'antenna=' + repr(_pc.document['antenna']), 'scan=' + repr(_pc.document['scan']), 'observation=' + repr(_pc.document['observation']), 'msselect=' + repr(_pc.document['msselect']), 'solint=' + repr(_pc.document['solint']), 'combine=' + repr(_pc.document['combine']), 'refant=' + repr(_pc.document['refant']), 'minblperant=' + repr(_pc.document['minblperant']), 'minsnr=' + repr(_pc.document['minsnr']), 'solnorm=' + repr(_pc.document['solnorm']), 'bandtype=' + repr(_pc.document['bandtype']), 'smodel=' + repr(_pc.document['smodel']), 'corrdepflags=' + repr(_pc.document['corrdepflags']), 'append=' + repr(_pc.document['append']), 'fillgaps=' + repr(_pc.document['fillgaps']), 'degamp=' + repr(_pc.document['degamp']), 'degphase=' + repr(_pc.document['degphase']), 'visnorm=' + repr(_pc.document['visnorm']), 'maskcenter=' + repr(_pc.document['maskcenter']), 'maskedge=' + repr(_pc.document['maskedge']), 'docallib=' + repr(_pc.document['docallib']), 'callib=' + repr(_pc.document['callib']), 'gaintable=' + repr(_pc.document['gaintable']), 'gainfield=' + repr(_pc.document['gainfield']), 'interp=' + repr(_pc.document['interp']), 'spwmap=' + repr(_pc.document['spwmap']), 'parang=' + repr(_pc.document['parang']) ] )
390 task_result = None
391 try:
392 task_result = _bandpass_t( _pc.document['vis'], _pc.document['caltable'], _pc.document['field'], _pc.document['spw'], _pc.document['intent'], _pc.document['selectdata'], _pc.document['timerange'], _pc.document['uvrange'], _pc.document['antenna'], _pc.document['scan'], _pc.document['observation'], _pc.document['msselect'], _pc.document['solint'], _pc.document['combine'], _pc.document['refant'], _pc.document['minblperant'], _pc.document['minsnr'], _pc.document['solnorm'], _pc.document['bandtype'], _pc.document['smodel'], _pc.document['corrdepflags'], _pc.document['append'], _pc.document['fillgaps'], _pc.document['degamp'], _pc.document['degphase'], _pc.document['visnorm'], _pc.document['maskcenter'], _pc.document['maskedge'], _pc.document['docallib'], _pc.document['callib'], _pc.document['gaintable'], _pc.document['gainfield'], _pc.document['interp'], _pc.document['spwmap'], _pc.document['parang'] )
393 except Exception as exc:
394 _except_log('bandpass', exc)
395 raise
396 finally:
397 task_result = _end_log( _logging_state_, 'bandpass', task_result )
398 return task_result
400bandpass = _bandpass( )