Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/applycal.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 17:39 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 17:39 +0000
1##################### generated by xml-casa (v2) from applycal.xml ##################
2##################### ee4997fc71a7d759055cb0074229e58f ##############################
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_applycal import applycal as _applycal_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 _applycal:
15 """
16 applycal ---- Apply calibrations solutions(s) to data
19 Applycal reads the specified gain calibration tables or cal library,
20 applies them to the (raw) data column (with the specified selection),
21 and writes the calibrated results into the corrected column. This is
22 done in one step, so all available calibration tables must be
23 specified.
25 Applycal will overwrite existing corrected data, and will flag data
26 for which there is no calibration available.
28 Standard data selection is supported. See help par.selectdata for
29 more information.
31 --------- parameter descriptions ---------------------------------------------
33 vis Name of input visibility file
34 default: non
36 Example: vis='ngc5921.ms'
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
52 spw Select spectral window/channels
54 Examples:
55 spw='0~2,4'; spectral windows 0,1,2,4 (all
56 channels)
57 spw='<2'; spectral windows less than 2
58 (i.e. 0,1)
59 spw='0:5~61'; spw 0, channels 5 to 61,
60 INCLUSIVE
61 spw='\*:5~61'; all spw with channels 5 to 61
62 spw='0,10,3:3~45'; spw 0,10 all channels, spw
63 3, channels 3 to 45.
64 spw='0~2:2~6'; spw 0,1,2 with channels 2
65 through 6 in each.
66 spw='0:0~10;15~60'; spectral window 0 with
67 channels 0-10,15-60. (NOTE ';' to separate
68 channel selections)
69 spw='0:0~10^2,1:20~30^5'; spw 0, channels
70 0,2,4,6,8,10, spw 1, channels 20,25,30
71 type 'help par.selection' for more examples.
72 intent Select observing intent
73 default: '' (no selection by intent)
75 Example: intent='\*BANDPASS\*' (selects data
76 labelled with BANDPASS intent)
77 selectdata Other data selection parameters
78 default: True
79 timerange Select data based on time range
80 Subparameter of selectdata=True
81 default = '' (all)
83 Examples:
84 timerange =
85 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
86 (Note: if YYYY/MM/DD is missing date defaults
87 to first day in data set.)
88 timerange='09:14:0~09:54:0' picks 40 min on
89 first day
90 timerange= '25:00:00~27:30:00' picks 1 hr to 3
91 hr 30min on NEXT day
92 timerange='09:44:00' pick data within one
93 integration of time
94 timerange='>10:24:00' data after this time
95 uvrange Select data within uvrange (default units meters)
96 Subparameter of selectdata=True
97 default: '' (all)
99 Examples:
100 uvrange='0~1000klambda'; uvrange from 0-1000
101 kilo-lambda
102 uvrange='>4klambda';uvranges greater than 4
103 kilolambda
104 antenna Select data based on antenna/baseline
105 Subparameter of selectdata=True
106 default: '' (all)
108 If antenna string is a non-negative integer, it
109 is assumed an antenna index, otherwise, it is
110 assumed as an antenna name
112 Examples:
113 antenna='5&6'; baseline between antenna
114 index 5 and index 6.
115 antenna='VA05&VA06'; baseline between VLA
116 antenna 5 and 6.
117 antenna='5&6;7&8'; baselines with
118 indices 5-6 and 7-8
119 antenna='5'; all baselines with antenna index
120 5
121 antenna='05'; all baselines with antenna
122 number 05 (VLA old name)
123 antenna='5,6,10'; all baselines with antennas
124 5,6,10 index numbers
125 scan Scan number range
126 Subparameter of selectdata=True
127 default: '' = all
128 observation Select by observation ID(s)
129 Subparameter of selectdata=True
130 default: '' = all
132 Example: observation='0~2,4'
133 msselect Optional complex data selection (ignore for now)
134 docallib Control means of specifying the caltables
135 default: False --> Use gaintable, gainfield,
136 interp, spwmap, calwt.
138 If True, specify a file containing cal library in
139 callib
140 callib Cal Library filename
141 Subparameter of callib=True
143 If docallib=True, specify a file containing cal
144 library directives
145 gaintable Gain calibration table(s) to apply on the fly
146 Subparameter of callib=False
147 default: '' (none)
149 All gain table types: 'G', GSPLINE, 'T', 'B',
150 'BPOLY', 'D's' can be applied.
152 Examples: gaintable='ngc5921.gcal'
153 gaintable=['ngc5921.ampcal','ngc5921.phcal']
154 gainfield Select a subset of calibrators from gaintable(s)
155 Subparameter of callib=False
156 default:'' --> all sources in table
158 gaintable='nearest' --> nearest (on sky)
159 available field in table. Otherwise, same syntax
160 as field
162 Examples:
163 gainfield='0~2,5' means use fields 0,1,2,5
164 from gaintable
165 gainfield=['0~3','4~6'] (for multiple
166 gaintables)
167 interp Interpolation parmameters (in time[,freq]) for each gaintable, as a list of strings.
168 Default: '' --> 'linear,linear' for all gaintable(s)
169 Options: Time: 'nearest', 'linear'
170 Freq: 'nearest', 'linear', 'cubic',
171 'spline'
172 Specify a list of strings, aligned with the list of caltable specified
173 in gaintable, that contain the required interpolation parameters
174 for each caltable.
176 - When frequency interpolation is relevant (B, Df,
177 Xf), separate time-dependent and freq-dependent
178 interp types with a comma (freq after the
179 comma).
180 - Specifications for frequency are ignored when the
181 calibration table has no channel-dependence.
182 - Time-dependent interp options ending in 'PD'
183 enable a "phase delay" correction per spw for
184 non-channel-dependent calibration types.
185 - For multi-obsId datasets, 'perobs' can be
186 appended to the time-dependent interpolation
187 specification to enforce obsId boundaries when
188 interpolating in time.
189 - For multi-scan datasets, 'perscan' can be
190 appended to the time-dependent interpolation
191 specification to enforce scan boundaries when
192 interpolating in time.
193 - Freq-dependent interp options can have 'flag' appended
194 to enforce channel-dependent flagging, and/or 'rel'
195 appended to invoke relative frequency interpolation
197 Examples:
198 interp='nearest' (in time, freq-dep will be
199 linear, if relevant)
200 interp='linear,cubic' (linear in time, cubic
201 in freq)
202 interp='linearperobs,splineflag' (linear in
203 time per obsId, spline in freq with
204 channelized flagging)
205 interp='nearest,linearflagrel' (nearest in
206 time, linear in freq with with channelized
207 flagging and relative-frequency interpolation)
208 interp=',spline' (spline in freq; linear in
209 time by default)
210 interp=['nearest,spline','linear'] (for
211 multiple gaintables)
212 spwmap Spectral windows combinations to form for gaintables(s)
213 Subparameter of callib=False
214 default: [] (apply solutions from each spw to
215 that spw only)
217 Examples:
218 spwmap=[0,0,1,1] means apply the caltable
219 solutions from spw = 0 to the spw 0,1 and spw
220 1 to spw 2,3.
221 spwmap=[[0,0,1,1],[0,1,0,1]] (for multiple
222 gaintables)
223 calwt Calibrate data weights per gaintable.
224 default: True (for all specified gaintables)
226 Examples:
227 calwt=False (for all specified gaintables)
228 calwt=[True,False,True] (specified per
229 gaintable)
230 parang Apply parallactic angle correction
231 default: False
233 If True, apply the parallactic angle
234 correction. FOR ANY POLARIZATION CALIBRATION AND
235 IMAGING, parang = True
236 applymode Calibration apply mode
237 default: 'calflag'
238 Options: "calflag", "calflagstrict", "trial",
239 "flagonly", "flagonlystrict", "calonly"
241 -- applymode='calflag': calibrate data and apply
242 flags from solutions
243 -- applymode='trial': report on flags from
244 solutions, dataset entirely unchanged
245 -- applymode='flagonly': apply flags from
246 solutions only, data not calibrated
247 -- applymode='calonly' calibrate data only, flags
248 from solutions NOT applied (use with extreme
249 caution!)
250 -- applymode='calflagstrict' or 'flagonlystrict'
251 same as above except flag spws for which
252 calibration is unavailable in one or more tables
253 (instead of allowing them to pass uncalibrated
254 and unflagged)
255 flagbackup Automatically back up the state of flags before the run?
256 default: True
258 --------- examples -----------------------------------------------------------
262 For more information, see the task pages of applycal in CASA Docs:
264 https://casa.nrao.edu/casadocs/
267 """
269 _info_group_ = """calibration"""
270 _info_desc_ = """Apply calibrations solutions(s) to data"""
272 def __call__( self, vis='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', docallib=False, callib='', gaintable=[ ], gainfield=[ ], interp=[ ], spwmap=[ ], calwt=[ bool(True) ], parang=False, applymode='', flagbackup=True ):
273 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, '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}, 'docallib': {'type': 'cBool'}, 'callib': {'type': 'cStr', 'coerce': _coerce.to_str}, 'gaintable': {'type': 'cPathVec', 'coerce': [_coerce.to_list,_coerce.expand_pathvec]}, '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]}, 'calwt': {'type': 'cBoolVec', 'coerce': [_coerce.to_list,_coerce.to_boolvec]}, 'parang': {'type': 'cBool'}, 'applymode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'calonly', 'flagonlystrict', 'calflag', 'flagonly', 'trial', '', 'calflagstrict' ]}, 'flagbackup': {'type': 'cBool'}}
274 doc = {'vis': vis, 'field': field, 'spw': spw, 'intent': intent, 'selectdata': selectdata, 'timerange': timerange, 'uvrange': uvrange, 'antenna': antenna, 'scan': scan, 'observation': observation, 'msselect': msselect, 'docallib': docallib, 'callib': callib, 'gaintable': gaintable, 'gainfield': gainfield, 'interp': interp, 'spwmap': spwmap, 'calwt': calwt, 'parang': parang, 'applymode': applymode, 'flagbackup': flagbackup}
275 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
276 _logging_state_ = _start_log( 'applycal', [ 'vis=' + repr(_pc.document['vis']), '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']), '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']), 'calwt=' + repr(_pc.document['calwt']), 'parang=' + repr(_pc.document['parang']), 'applymode=' + repr(_pc.document['applymode']), 'flagbackup=' + repr(_pc.document['flagbackup']) ] )
277 task_result = None
278 try:
279 task_result = _applycal_t( _pc.document['vis'], _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['docallib'], _pc.document['callib'], _pc.document['gaintable'], _pc.document['gainfield'], _pc.document['interp'], _pc.document['spwmap'], _pc.document['calwt'], _pc.document['parang'], _pc.document['applymode'], _pc.document['flagbackup'] )
280 except Exception as exc:
281 _except_log('applycal', exc)
282 raise
283 finally:
284 task_result = _end_log( _logging_state_, 'applycal', task_result )
285 return task_result
287applycal = _applycal( )