Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/fringefit.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-01 07:19 +0000

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

2##################### e6409c0f21fccc6ce2bdcdf5b41b3d7d ############################## 

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 f False (default), if any correlation is flagged, treat all correlations in 

72 the visibility vector as flagged when solving (per channel, per baseline). 

73 If True, use unflagged correlations in a visibility vector, even if one or more 

74 other correlations are flagged. 

75  

76 Default: False (treat correlation vectors with one or more correlations flagged as entirely flagged) 

77  

78 Traditionally, CASA has observed a strict interpretation of  

79 correlation-dependent flags: if one or more correlations  

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

81 correlations for the same baseline and channel are  

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

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

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

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

86 will be rendered as flagged. 

87 corrcomb Combine correlations: "all" and "none" are currently 

88 supported values 

89 docallib Control means of specifying the caltables 

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

91 spwmap, calwt) 

92 Options: False|True 

93  

94 If True, specify a file containing cal library in 

95 callib 

96 callib Specify a file containing cal library directives 

97 Subparameter of docallib=True 

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

99 Default: '' (none) 

100 Subparameter of docallib=False 

101 Examples:  

102 gaintable='ngc5921.gcal' 

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

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

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

106  

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

108 table otherwise, same syntax as field 

109  

110 Examples:  

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

112 from gaintable 

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

114 through 3 

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

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

117 Options: Time: 'nearest', 'linear' 

118 Freq: 'nearest', 'linear', 'cubic', 

119 'spline' 

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

121 in gaintable, that contain the required interpolation parameters 

122 for each caltable. 

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

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

125 interp types with a comma (freq after the 

126 comma).  

127 * Specifications for frequency are ignored when the 

128 calibration table has no channel-dependence.  

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

130 enable a "phase delay" correction per spw for 

131 non-channel-dependent calibration types. 

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

133 appended to the time-dependent interpolation 

134 specification to enforce obsId boundaries when 

135 interpolating in time.  

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

137 appended to the time-dependent interpolation 

138 specification to enforce scan boundaries when 

139 interpolating in time.  

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

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

142 appended to invoke relative frequency interpolation 

143  

144 Examples:  

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

146 linear, if relevant) 

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

148 in freq) 

149 interp='linearperobs,splineflag' (linear in 

150 time per obsId, spline in freq with 

151 channelized flagging) 

152 interp='nearest,linearflagrel' (nearest in 

153 time, linear in freq with with channelized  

154 flagging and relative-frequency interpolation) 

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

156 time by default) 

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

158 multiple gaintables) 

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

160 Only used if callib=False 

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

162 the same MS spw only) 

163 Any available calibration spw can be mechanically mapped to any  

164 MS spw.  

165 Examples: 

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

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

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

169 gaintables) 

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

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

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

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

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

175 shift theorem; this mode is experimental. 

176 parang Apply parallactic angle correction on the fly. 

177 

178 --------- examples ----------------------------------------------------------- 

179 

180  

181 For more information, see the task pages of gaincal in CASA Docs: 

182  

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

184 minsnr -- Reject solutions below this SNR 

185 default: 3.0 

186 

187 

188 """ 

189 

190 _info_group_ = """calibration""" 

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

192 

193 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 ): 

194 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}, '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'}} 

195 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} 

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

197 _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']) ] ) 

198 task_result = None 

199 try: 

200 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'] ) 

201 except Exception as exc: 

202 _except_log('fringefit', exc) 

203 raise 

204 finally: 

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

206 return task_result 

207 

208fringefit = _fringefit( ) 

209