Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/accor.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 accor.xml #####################
2##################### 3885c342918e8dc7a2c14075c00c6996 ##############################
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_accor import accor as _accor_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 _accor:
15 """
16 accor ---- Normalize visibilities based on auto-correlations
19 Determines the amplitude corrections neede due to errors in sampler
20 thresholds using measurements of auto-correlation spectra. This
21 correction is typically requiered for data correlated with the DiFX
22 correlator (such as VLBA data). Other correlators (such as the SFXC
23 correlator used to correlate EVN data at JIVE) already apply this
24 correction at the correlator. In this case, running this task is not
25 necessary.
27 --------- parameter descriptions ---------------------------------------------
29 vis Name of input visibility file
30 default: none
32 example: vis='ngc5921.ms'
33 caltable Name of output gain calibration table
34 default: none
36 example: caltable='ngc5921.gcal'
37 field Select field using field id(s) or field name(s)
38 default: '' --> all fields
40 Use 'go listobs' to obtain the list id's or
41 names. If field string is a non-negative integer,
42 it is assumed a field index, otherwise, it is
43 assumed a field name.
45 Examples:
46 field='0~2'; field ids 0,1,2
47 field='0,4,5~7'; field ids 0,4,5,6,7
48 field='3C286,3C295'; field named 3C286 and
49 3C295
50 field = '3,4C\*'; field id 3, all names
51 starting with 4C
53 Note: do not forget to include the flux density
54 calibrator if you have one!
55 spw Select spectral window/channels
57 Examples:
58 spw='0~2,4'; spectral windows 0,1,2,4 (all
59 channels)
60 spw='<2'; spectral windows less than 2
61 (i.e. 0,1)
62 spw='0:5~61'; spw 0, channels 5 to 61,
63 INCLUSIVE
64 spw='\*:5~61'; all spw with channels 5 to 61
65 spw='0,10,3:3~45'; spw 0,10 all channels, spw
66 3, channels 3 to 45.
67 spw='0~2:2~6'; spw 0,1,2 with channels 2
68 through 6 in each.
69 spw='0:0~10;15~60'; spectral window 0 with
70 channels 0-10,15-60. (NOTE ';' to separate
71 channel selections)
72 spw='0:0~10^2,1:20~30^5'; spw 0, channels
73 0,2,4,6,8,10, spw 1, channels 20,25,30
74 type 'help par.selection' for more examples.
75 intent Select observing intent
76 default: '' (no selection by intent)
78 Example: intent='\*BANDPASS\*' (selects data
79 labelled with BANDPASS intent)
80 selectdata Other data selection parameters
81 default: True (Must set selectdata=True to select
82 other selection parameters.)
83 timerange Select data based on time range
84 Subparameter of selectdata=True
85 default = '' (all)
87 Examples:
88 timerange =
89 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
90 (Note: if YYYY/MM/DD is missing date defaults
91 to first day in data set.)
92 timerange='09:14:0~09:54:0' picks 40 min on
93 first day
94 timerange= '25:00:00~27:30:00' picks 1 hr to 3
95 hr 30min on NEXT day
96 timerange='09:44:00' pick data within one
97 integration of time
98 timerange='>10:24:00' data after this time
99 antenna Select data based on antenna/baseline
100 Subparameter of selectdata=True
101 default: '' (all)
103 Examples:
104 antenna='5&6'; baseline between antenna
105 index 5 and index 6.
106 antenna='VA05&VA06'; baseline between VLA
107 antenna 5 and 6.
108 antenna='5&6;7&8'; baselines with
109 indices 5-6 and 7-8
110 antenna='5'; all baselines with antenna index
111 5
112 antenna='05'; all baselines with antenna
113 number 05 (VLA old name)
114 antenna='5,6,10'; all baselines with antennas
115 5,6,10 index numbers
117 Note: just for antenna selection, an integer (or
118 integer list) is converted to a string and
119 matched against the antenna 'name' first. Only if
120 that fails, the integer is matched with the
121 antenna ID. The latter is the case for most
122 observatories, where the antenna name is not
123 strictly an integer.
124 scan Scan number range
125 Subparameter of selectdata=True
126 default: '' = all
128 Check 'go listobs' to insure the scan numbers are
129 in order.
130 observation Select by observation ID(s)
131 Subparameter of selectdata=True
132 default: '' = all
134 Example: observation='0~2,4'
135 msselect Optional complex data selection (ignore for now)
136 solint Solution interval (units optional)
137 default: 'inf' (~infinite, up to boundaries
138 controlled by combine)
139 Options: 'inf' (~infinite), 'int' (per
140 integration), any float or integer value with or
141 without units
143 Examples: solint='1min'; solint='60s';
144 solint=60 --> 1 minute
145 solint='0s'; solint=0; solint='int' --> per
146 integration
147 solint-'-1s'; solint='inf' --> ~infinite, up
148 to boundaries -interacts with combine
149 combine Data axes which to combine for solve
150 default: '' (solutions will break at obs, scan,
151 field, and spw)
152 Options: '','obs','scan','spw',field', or any
153 comma-separated combination in a single string
155 For gaintype='K', if combine includes 'spw',
156 multi-band delays will be determined; otherwise,
157 (per-spw) single-band delays will be determined.
159 Example: combine='scan,spw' (extend solutions
160 over scan boundaries)
161 corrdepflags f False (default), if any correlation is flagged, treat all correlations in
162 the visibility vector as flagged when solving (per channel, per baseline).
163 If True, use unflagged correlations in a visibility vector, even if one or more
164 other correlations are flagged.
166 Default: False (treat correlation vectors with one or more correlations flagged as entirely flagged)
168 Traditionally, CASA has observed a strict interpretation of
169 correlation-dependent flags: if one or more correlations
170 (for any baseline and channel) is flagged, then all available
171 correlations for the same baseline and channel are
172 treated as flagged. However, it is desirable in some
173 circumstances to relax this stricture, e.g., to preserve use
174 of data from antennas with only one good polarization (e.g., one polarization
175 is bad or entirely absent). Solutions for the bad or missing polarization
176 will be rendered as flagged.
177 append Append solutions to the (existing) table
178 default: False (overwrite existing table or make
179 new table)
181 Appended solutions must be derived from the same
182 MS as the existing caltable, and solution spws
183 must have the same meta-info (according to spw
184 selection and solint) or be non-overlapping.
185 docallib Control means of specifying the caltables
186 default: False --> Use gaintable, gainfield,
187 interp, spwmap, calwt.
189 If True, specify a file containing cal library in
190 callib
191 callib Cal Library filename
192 Subparameter of callib=True
194 If docallib=True, specify a file containing cal
195 library directives
196 gaintable Gain calibration table(s) to apply on the fly
197 Subparameter of callib=False
198 default: '' (none)
200 Examples: gaintable='ngc5921.gcal'
201 gaintable=['ngc5921.ampcal','ngc5921.phcal']
202 gainfield Select a subset of calibrators from gaintable(s)
203 Subparameter of callib=False
204 default:'' --> all sources in table
206 gaintable='nearest' --> nearest (on sky)
207 available field in table. Otherwise, same syntax
208 as field
210 Examples:
211 gainfield='0~2,5' means use fields 0,1,2,5
212 from gaintable
213 gainfield=['0~3','4~6'] means use field 0
214 through 3 from first gain file, field 4
215 through 6 for second.
216 interp Interpolation parmameters (in time[,freq]) for each gaintable, as a list of strings.
217 Default: '' --> 'linear,linear' for all gaintable(s)
218 Options: Time: 'nearest', 'linear'
219 Freq: 'nearest', 'linear', 'cubic',
220 'spline'
221 Specify a list of strings, aligned with the list of caltable specified
222 in gaintable, that contain the required interpolation parameters
223 for each caltable.
225 - When frequency interpolation is relevant (B, Df,
226 Xf), separate time-dependent and freq-dependent
227 interp types with a comma (freq_after\_ the
228 comma).
229 - Specifications for frequency are ignored when the
230 calibration table has no channel-dependence.
231 - Time-dependent interp options ending in 'PD'
232 enable a "phase delay" correction per spw for
233 non-channel-dependent calibration types.
234 - For multi-obsId datasets, 'perobs' can be
235 appended to the time-dependent interpolation
236 specification to enforce obsId boundaries when
237 interpolating in time.
238 - For multi-scan datasets, 'perscan' can be
239 appended to the time-dependent interpolation
240 specification to enforce scan boundaries when
241 interpolating in time.
242 - Freq-dependent interp options can have 'flag' appended
243 to enforce channel-dependent flagging, and/or 'rel'
244 appended to invoke relative frequency interpolation
246 Examples:
247 interp='nearest' (in time, freq-dep will be
248 linear, if relevant)
249 interp='linear,cubic' (linear in time, cubic
250 in freq)
251 interp='linearperobs,splineflag' (linear in
252 time per obsId, spline in freq with
253 channelized flagging)
254 interp='nearest,linearflagrel' (nearest in
255 time, linear in freq with with channelized
256 flagging and relative-frequency interpolation)
257 interp=',spline' (spline in freq; linear in
258 time by default)
259 interp=['nearest,spline','linear'] (for
260 multiple gaintables)
261 spwmap Spectral windows combinations to form for gaintables(s)
262 Subparameter of callib=False
263 default: [] (apply solutions from each spw to
264 that spw only)
266 Examples:
267 spwmap=[0,0,1,1] means apply the caltable
268 solutions from spw = 0 to the spw 0,1 and spw
269 1 to spw 2,3.
270 spwmap=[[0,0,1,1],[0,1,0,1]]
272 --------- examples -----------------------------------------------------------
275 For more information, see the task pages of accor in CASA Docs:
277 https://casa.nrao.edu/casadocs/
280 """
282 _info_group_ = """calibration"""
283 _info_desc_ = """Normalize visibilities based on auto-correlations"""
285 def __call__( self, vis='', caltable='', field='', spw='', intent='', selectdata=True, timerange='', antenna='', scan='', observation='', msselect='', solint='inf', combine='', corrdepflags=False, append=False, docallib=False, callib='', gaintable=[ ], gainfield=[ ], interp=[ ], spwmap=[ ] ):
286 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}, '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}, 'corrdepflags': {'type': 'cBool'}, 'append': {'type': 'cBool'}, '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]}}
287 doc = {'vis': vis, 'caltable': caltable, 'field': field, 'spw': spw, 'intent': intent, 'selectdata': selectdata, 'timerange': timerange, 'antenna': antenna, 'scan': scan, 'observation': observation, 'msselect': msselect, 'solint': solint, 'combine': combine, 'corrdepflags': corrdepflags, 'append': append, 'docallib': docallib, 'callib': callib, 'gaintable': gaintable, 'gainfield': gainfield, 'interp': interp, 'spwmap': spwmap}
288 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
289 _logging_state_ = _start_log( 'accor', [ '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']), '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']), 'corrdepflags=' + repr(_pc.document['corrdepflags']), 'append=' + repr(_pc.document['append']), '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']) ] )
290 task_result = None
291 try:
292 task_result = _accor_t( _pc.document['vis'], _pc.document['caltable'], _pc.document['field'], _pc.document['spw'], _pc.document['intent'], _pc.document['selectdata'], _pc.document['timerange'], _pc.document['antenna'], _pc.document['scan'], _pc.document['observation'], _pc.document['msselect'], _pc.document['solint'], _pc.document['combine'], _pc.document['corrdepflags'], _pc.document['append'], _pc.document['docallib'], _pc.document['callib'], _pc.document['gaintable'], _pc.document['gainfield'], _pc.document['interp'], _pc.document['spwmap'] )
293 except Exception as exc:
294 _except_log('accor', exc)
295 raise
296 finally:
297 task_result = _end_log( _logging_state_, 'accor', task_result )
298 return task_result
300accor = _accor( )