Coverage for /home/casatest/venv/lib/python3.12/site-packages/casatasks/fringefit.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-21 07:43 +0000

1##################### generated by xml-casa (v2) from fringefit.xml ################# 

2##################### ecd6425606a9aacdde09aa33346a9406 ############################## 

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_fringefit import fringefit as _fringefit_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 

13 

14class _fringefit: 

15 """ 

16 fringefit ---- Fringe fit delay and rates 

17 

18  

19 Phase offsets, groups delays and delay rates are calculated with 

20 respect to a specified referance antenna by a two-dimensional FFT and 

21 subsequent least-squares optimisation. 

22  

23 Previous calibrations should be applied on the fly. 

24 

25 --------- parameter descriptions --------------------------------------------- 

26 

27 vis Name of input visibility file 

28 caltable Name of output gain calibration table 

29 field Select field using field id(s) or field name(s) 

30 spw Select spectral window/channels 

31 intent Select observing intent 

32 selectdata Other data selection parameters 

33 timerange Select data based on time range 

34 uvrange Select data by baseline length. 

35 Default = '' (all) 

36  

37 Examples: 

38 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 

39 uvrange='>4klambda';uvranges greater than 4 kilo-lambda 

40 uvrange='0~1000km'; uvrange in kilometers 

41 antenna Select data based on antenna/baseline 

42 scan Scan number range 

43 observation Select by observation ID(s) 

44 msselect Optional complex data selection (ignore for now) 

45 solint Solution interval: egs. \'inf\', \'60s\' (see help) 

46 combine Data axes which to combine for solve (obs, scan, spw, and/or field) 

47 refant Reference antenna name(s) 

48 minsnr Reject solutions below this signal-to-noise ratio (at the FFT stage) 

49 zerorates Zero delay-rates in solution table 

50  

51 Write a solution table with delay-rates zeroed, for the case of 

52 "manual phase calibration", so that the calibration table can be 

53 applied to the full dataset without the extrapolation of a non-zero delay-rate term 

54 affecting the data 

55 globalsolve Refine estimates of delay and rate with global least-squares solver 

56 niter Maximum number of iterations for least-squares solver 

57 delaywindow Constrain FFT delay search to a window specified as a two-element list with units of nanoseconds 

58 Default: [None, None] 

59 Examples: [-10, 10] 

60 ratewindow Constrain FFT rate search to a window specified as a two-element list with units of seconds per second 

61 Default: [None, None] 

62 Examples: [-1e-13, 1e-13] 

63 append Append solutions to the (existing) table 

64 Default: False (overwrite existing table or make 

65 new table) 

66  

67 Appended solutions must be derived from the same 

68 MS as the existing caltable, and solution spws 

69 must have the same meta-info (according to spw 

70 selection and solint) or be non-overlapping. 

71 corrdepflags Respect correlation-dependent flags: 

72 If False (default), if any correlation is flagged, 

73 treat all correlations in the visibility vector as flagged 

74 when solving (per channel, per baseline). 

75 If True, use unflagged correlations in a visibility vector, 

76 even if one or more other correlations are flagged. 

77  

78 Default: False (treat correlation vectors with one or more 

79 correlations flagged as entirely flagged) 

80  

81 Traditionally, CASA has observed a strict interpretation of  

82 correlation-dependent flags: if one or more correlations  

83 (for any baseline and channel) is flagged, then all available  

84 correlations for the same baseline and channel are  

85 treated as flagged. However, it is desirable in some  

86 circumstances to relax this stricture, e.g., to preserve use 

87 of data from antennas with only one good polarization (e.g., one polarization 

88 is bad or entirely absent). Solutions for the bad or missing polarization  

89 will be rendered as flagged. 

90 corrcomb Combine correlations (use with corrdepflags=True): 

91 If corrcomb="stokes", the parallel-hand correlations (if both 

92 are unflagged) will be combined formally (unweighted) to form Stokes I, 

93 with a net weight properly propagated from the correlatio 

94 weights. 

95 If corrcomb="parallel", the parallel-hand correlations (if 

96 either unflagged) will be combined with a weighted average, 

97 thereby optimizing net sensitivity for unpolarized sources. 

98 If either parallel-hand correlation is flagged, its weight in 

99 this average will be zero. This mode permits combining 

100 correlations without flagging single-pol antennas completely. 

101 If corrcomb="none" (default), correlations will not be combined. 

102 docallib Control means of specifying the caltables 

103 Default: False (Use gaintable, gainfield, interp, 

104 spwmap, calwt) 

105 Options: False|True 

106  

107 If True, specify a file containing cal library in 

108 callib 

109 callib Specify a file containing cal library directives 

110 Subparameter of docallib=True 

111 gaintable Gain calibration table(s) to apply on the fly 

112 Default: '' (none) 

113 Subparameter of docallib=False 

114 Examples:  

115 gaintable='ngc5921.gcal' 

116 gaintable=['ngc5921.ampcal','ngc5921.phcal'] 

117 gainfield Select a subset of calibrators from gaintable(s) 

118 Default: '' (all sources on the sky) 

119  

120 'nearest' ==> nearest (on sky) available field in 

121 table otherwise, same syntax as field 

122  

123 Examples:  

124 gainfield='0~2,5' means use fields 0,1,2,5 

125 from gaintable 

126 gainfield=['0~3','4~6'] means use field 0 

127 through 3 

128 interp Interpolation parameters (in time[,freq]) for each gaintable, as a list of strings. 

129 Default: '' --> 'linear,linear' for all gaintable(s) 

130 Options: Time: 'nearest', 'linear' 

131 Freq: 'nearest', 'linear', 'cubic', 

132 'spline' 

133 Specify a list of strings, aligned with the list of caltable specified 

134 in gaintable, that contain the required interpolation parameters 

135 for each caltable. 

136 * When frequency interpolation is relevant (B, Df, 

137 Xf), separate time-dependent and freq-dependent 

138 interp types with a comma (freq after the 

139 comma).  

140 * Specifications for frequency are ignored when the 

141 calibration table has no channel-dependence.  

142 * Time-dependent interp options ending in 'PD' 

143 enable a "phase delay" correction per spw for 

144 non-channel-dependent calibration types. 

145 * For multi-obsId datasets, 'perobs' can be 

146 appended to the time-dependent interpolation 

147 specification to enforce obsId boundaries when 

148 interpolating in time.  

149 * For multi-scan datasets, 'perscan' can be 

150 appended to the time-dependent interpolation 

151 specification to enforce scan boundaries when 

152 interpolating in time.  

153 * Freq-dependent interp options can have 'flag' appended 

154 to enforce channel-dependent flagging, and/or 'rel'  

155 appended to invoke relative frequency interpolation 

156  

157 Examples:  

158 interp='nearest' (in time, freq-dep will be 

159 linear, if relevant) 

160 interp='linear,cubic' (linear in time, cubic 

161 in freq) 

162 interp='linearperobs,splineflag' (linear in 

163 time per obsId, spline in freq with 

164 channelized flagging) 

165 interp='nearest,linearflagrel' (nearest in 

166 time, linear in freq with with channelized  

167 flagging and relative-frequency interpolation) 

168 interp=',spline' (spline in freq; linear in 

169 time by default) 

170 interp=['nearest,spline','linear'] (for 

171 multiple gaintables) 

172 spwmap Spectral window mappings to form for gaintable(s) 

173 Only used if callib=False 

174 default: [] (apply solutions from each calibration spw to 

175 the same MS spw only) 

176 Any available calibration spw can be mechanically mapped to any  

177 MS spw.  

178 Examples: 

179 spwmap=[0,0,1,1] means apply calibration  

180 from cal spw = 0 to MS spw 0,1 and cal spw 1 to MS spws 2,3. 

181 spwmap=[[0,0,1,1],[0,1,0,1]] (use a list of lists for multiple 

182 gaintables) 

183 paramactive Control which parameters are solved for; a vector of (exactly) three booleans for delay, delay-rate and dispersive delay (in that order) 

184 concatspws For combine='spw', the multi-band FFT solution can be 

185 done in two different ways. For concatspws=True (the default), spws are 

186 combined onto a wider frequency grid. For concatspws=False, each 

187 spw is separated FFT'd, and the results are combined using the 

188 shift theorem; this mode is experimental. 

189 parang Apply parallactic angle correction on the fly. 

190 

191 --------- examples ----------------------------------------------------------- 

192 

193  

194 For more information, see the task pages for fringefit in CASA Docs: 

195  

196 https://casa.nrao.edu/casadocs/ 

197 

198 

199 """ 

200 

201 _info_group_ = """calibration""" 

202 _info_desc_ = """Fringe fit delay and rates""" 

203 

204 def __call__( self, vis='', caltable='', field='', spw='', intent='', selectdata=True, timerange='', uvrange='', antenna='', scan='', observation='', msselect='', solint='inf', combine='', refant='', minsnr=float(3.0), zerorates=False, globalsolve=True, niter=int(100), delaywindow=[ ], ratewindow=[ ], append=False, corrdepflags=False, corrcomb='none', docallib=False, callib='', gaintable=[ ], gainfield=[ ], interp=[ ], spwmap=[ ], paramactive=[ ], concatspws=True, parang=False ): 

205 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}, 'minsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'zerorates': {'type': 'cBool'}, 'globalsolve': {'type': 'cBool'}, 'niter': {'type': 'cInt'}, 'delaywindow': {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, 'ratewindow': {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, 'append': {'type': 'cBool'}, 'corrdepflags': {'type': 'cBool'}, 'corrcomb': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'none', 'stokes', 'parallel' ]}, '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]}, 'paramactive': {'type': 'cBoolVec', 'coerce': [_coerce.to_list,_coerce.to_boolvec]}, 'concatspws': {'type': 'cBool'}, 'parang': {'type': 'cBool'}} 

206 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, 'minsnr': minsnr, 'zerorates': zerorates, 'globalsolve': globalsolve, 'niter': niter, 'delaywindow': delaywindow, 'ratewindow': ratewindow, 'append': append, 'corrdepflags': corrdepflags, 'corrcomb': corrcomb, 'docallib': docallib, 'callib': callib, 'gaintable': gaintable, 'gainfield': gainfield, 'interp': interp, 'spwmap': spwmap, 'paramactive': paramactive, 'concatspws': concatspws, 'parang': parang} 

207 assert _pc.validate(doc,schema), create_error_string(_pc.errors) 

208 _logging_state_ = _start_log( 'fringefit', [ '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']), 'minsnr=' + repr(_pc.document['minsnr']), 'zerorates=' + repr(_pc.document['zerorates']), 'globalsolve=' + repr(_pc.document['globalsolve']), 'niter=' + repr(_pc.document['niter']), 'delaywindow=' + repr(_pc.document['delaywindow']), 'ratewindow=' + repr(_pc.document['ratewindow']), 'append=' + repr(_pc.document['append']), 'corrdepflags=' + repr(_pc.document['corrdepflags']), 'corrcomb=' + repr(_pc.document['corrcomb']), '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']), 'paramactive=' + repr(_pc.document['paramactive']), 'concatspws=' + repr(_pc.document['concatspws']), 'parang=' + repr(_pc.document['parang']) ] ) 

209 task_result = None 

210 try: 

211 task_result = _fringefit_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['minsnr'], _pc.document['zerorates'], _pc.document['globalsolve'], _pc.document['niter'], _pc.document['delaywindow'], _pc.document['ratewindow'], _pc.document['append'], _pc.document['corrdepflags'], _pc.document['corrcomb'], _pc.document['docallib'], _pc.document['callib'], _pc.document['gaintable'], _pc.document['gainfield'], _pc.document['interp'], _pc.document['spwmap'], _pc.document['paramactive'], _pc.document['concatspws'], _pc.document['parang'] ) 

212 except Exception as exc: 

213 _except_log('fringefit', exc) 

214 raise 

215 finally: 

216 task_result = _end_log( _logging_state_, 'fringefit', task_result ) 

217 return task_result 

218 

219fringefit = _fringefit( ) 

220