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

27 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-31 17:39 +0000

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

2##################### c1c8e47ed65e84953105bd45e8a50894 ############################## 

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_gencal import gencal as _gencal_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 _gencal: 

15 """ 

16 gencal ---- Specify Calibration Values of Various Types 

17 

18  

19 The gencal task provides a means of specifying antenna-based 

20 calibration values manually. The values are put in designated tables 

21 and applied to the data using applycal. Several specialized 

22 calibrations are also generated with gencal. 

23  

24 Current antenna-based gencal options (caltype) are: 

25  

26 - 'amp'= amplitude correction 

27 - 'ph' = phase correction 

28 - 'sbd'= single-band delay (phase-frequency slope for each spw) 

29 - 'mbd'= multi-band delay (phase-frequency slope over all spw) 

30 - 'antpos' = ITRF antenna position corrections 

31 - 'antposvla' = VLA-centric antenna position corrections 

32 - 'tsys' = Tsys from the SYSCAL table (ALMA) 

33 - 'swpow' = EVLA switched-power gains (experimental) 

34 - ?swpwts? = EVLA switched-power for weights only, no temperature rescaling 

35 - 'evlagain' (='swpow') (this syntax will deprecate) 

36 - 'rq' = EVLA requantizer gains _only_ 

37 - 'swp/rq' = EVLA switched-power gains divided by requantizer gain 

38 - 'opac' = Tropospheric opacity 

39 - 'gc' = Gain curve (zenith-angle-dependent gain) (VLA only) 

40 - 'eff' = Antenna efficiency (sqrt(K/Jy)) (VLA only) 

41 - 'gceff' = Gain curve and efficiency (VLA only) 

42 - 'tecim' = Time-dep TEC image specified in infile 

43 - 'jyperk'= Jy/K factor via Jy/K DB Web API 

44 - 'eop' = EOP corrections 

45 

46 --------- parameter descriptions --------------------------------------------- 

47 

48 vis Name of input visibility file 

49 Default: none 

50  

51 Example: vis='ngc5921.ms' 

52 caltable Name of input calibration table 

53  

54 Default: none 

55  

56 If a calibration table does not exist, it will be 

57 created. Specifying an existing table will result 

58 in the parameters being applied 

59 cumulatively. Only a single time-stamp for all 

60 calibrations are supported, currently. Do not 

61 use a caltable created by gaincal, bandpass, 

62 etc.  

63  

64 Example: caltable='test.G' 

65 caltype The calibration parameter type being specified 

66 Default: none 

67 Options: 'amp', 'ph', 'sbd', 'mbd', 'antpos', 

68 'antposvla', 'tsys', 'evlagain', 'opac', 'gc', 

69 'gceff', 'eff', 'tecim', 'jyperk', 'eop' 

70  

71 - 'amp' = gain (G) amplitude (1 real parameter 

72 per pol, antenna, spw) 

73 - 'ph' = gain (G) phase (deg) (1 real parameter 

74 per pol, antenna, spw) 

75 - 'sbd' = single-band delays (nsec) (1 real 

76 parameter per pol, antenna, spw) 

77 - 'mbd' = multi-band delay (nsec) (1 real 

78 parameter per pol, antenna, spw) 

79 - 'antpos' = antenna position corrections (m) (3 

80 real ITRF offset parameters per antenna; spw, 

81 pol selection will be ignored) 

82 With antenna='', this triggers an automated 

83 lookup of antenna positions for EVLA. For ALMA 

84 an input file generated with getantposalma task 

85 can be input in paramter infile. 

86 - 'antposvla' = antenna position corrections (m) 

87 specified in the old VLA-centric coordinate 

88 system 

89 - 'tsys' = Tsys from the SYSCAL table (ALMA) 

90 - ?swpwts? = EVLA switched-power weights 

91 - 'evlagain' = EVLA switched-power gains 

92 (experimental) 

93 - 'opac' = Tropospheric opacity (1 real parameter 

94 per antenna, spw) 

95 - 'gc' = Antenna zenith-angle dependent gain 

96 curve (auto-lookup) 

97 - 'gceff' = Gain curve and efficiency 

98 (auto-lookup) 

99 - 'eff' = Antenna efficiency (auto-lookup) 

100 - 'jyperk' = Jy/K factor via Jy/K DB Web API 

101 - 'eop' = EOP corrections 

102  

103 Example: caltype='ph' 

104 infile Input ancilliary file 

105 Subparameter of caltype='antpos|gc|gceff|tecim|jyperk' 

106 Default: none 

107  

108 The format of the file in case of 'antpos' is JSON. 

109 The file contains the information about the antenna 

110 positions as well as some metadata. As a reference, 

111 this code snippet would create the most minimal JSON file 

112 that can be used by **gencal** 

113  

114 :: 

115 import json 

116 ... 

117 with open("outfile.json", "w") as f: 

118 json.dump({"data":{"ANT1" : [500000, 500000, 500000]}, "metadata" : {"product_code": "antposalma"} }, f) 

119 endpoint Input endpoint of the Jy/K DB Web API. 

120 Subparameter of caltype='jyperk' 

121 Default: 'asdm' 

122 Options: 'asdm', 'model-fit', 'interpolation' 

123  

124 The 'interpolation' option may not work for the data after 2019. 

125 timeout Maximum waiting time [sec] for the Web API access. 

126 Subparameter of caltype='jyperk' 

127 Default: 180 

128 retry Number of retry when the Web API access fails. 

129 Subparameter of caltype='jyperk' 

130 Default: 3 

131 retry_wait_time Waiting time [sec] until next query, when the Web API access fails. 

132 Subparameter of caltype='jyperk' 

133 Default: 5 

134 ant_pos_time_limit Maximum number of days beyond the observation for which a 

135 correction should be included in the final offset. This subparameter has only 

136 an effect on VLA data. 

137 Subparameter of caltype='antpos' 

138 Default: 0 

139 spw Select spectral window/channels 

140 Default: '' (all spectral windows and channels) 

141  

142 Examples: spw='0~2,4'; spectral windows 0,1,2,4 (all channels) spw='<2'; spectral windows less than 2 (i.e. 0,1) spw='0:5~61'; spw 0, channels 5 to 61 spw='0,10,3:3~45'; spw 0,10 all channels, spw 

143 3 - chans 3 to 45. spw='0~2:2~6'; spw 0,1,2 with channels 2 

144 through 6 in each. 

145 spw = '\*:3~64' channels 3 through 64 for all sp id's 

146 spw = ' :3~64' will NOT work. 

147 antenna Select data based on antenna/baseline 

148 Subparameter of selectdata=True 

149 Default: '' (all) 

150  

151 If antenna string is a non-negative integer, it 

152 is assumed an antenna index, otherwise, it is 

153 assumed as an antenna name 

154  

155 Examples:  

156 antenna='5&6'; baseline between antenna 

157 index 5 and index 6. 

158 antenna='VA05&VA06'; baseline between VLA 

159 antenna 5 and 6. 

160 antenna='5&6;7&8'; baselines with 

161 indices 5-6 and 7-8 

162 antenna='5'; all baselines with antenna index 

163 5 

164 antenna='05'; all baselines with antenna 

165 number 05 (VLA old name) 

166 antenna='5,6,10'; all baselines with antennas 

167 5,6,10 index numbers 

168 pol Polarization selection for specified parameters 

169 Default: pol='' (specified parameters apply to 

170 all polarizations) 

171  

172 Example: pol='R' (specified parameters to 

173 apply to R only) 

174 parameter The calibration values 

175  

176 The calibration parameters, specified as a list, 

177 to store in the caltable for the spw, antenna, 

178 and pol selection. The required length of the 

179 list is determined by the caltype and the spw, 

180 antenna, pol selection. One "set" of parameters 

181 (e.g., one value for 'amp', 'ph', etc., three 

182 values for 'antpos') specified the same value for 

183 all indicated spw, antenna, and pol. 

184 OR,  

185 When specifying a long list of calibration 

186 parameter values, these should be ordered first 

187 (fastest) by pol (if pol!=''), then by antenna 

188 (if antenna!=''), and finally (sloweset) by spw 

189 (if spw!=''). Unspecified selection axes must 

190 not be enumerated in the parameter list 

191 uniform Assume uniform calibration values across the array 

192 Subparameter of caltype='tsys' 

193 Default: True 

194 Options: True|False 

195 RETURNS void 

196 

197 --------- examples ----------------------------------------------------------- 

198 

199  

200 FOR MORE INFORMATION, SEE THE TASK PAGES OF GENCAL IN CASA DOCS: 

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

202 

203 

204 """ 

205 

206 _info_group_ = """calibration""" 

207 _info_desc_ = """Specify Calibration Values of Various Types""" 

208 

209 def __call__( self, vis='', caltable='', caltype='', infile='', endpoint='asdm', timeout=int(180), retry=int(3), retry_wait_time=int(5), ant_pos_time_limit=int(0), spw='', antenna='', pol='', parameter=[ ], uniform=True ): 

210 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'caltable': {'type': 'cStr', 'coerce': _coerce.to_str}, 'caltype': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'eff', 'antposvla', 'swpwts', 'mbd', 'opac', 'gc', 'antpos', 'tsys', 'swp/rq', 'swpow', 'amp', 'tecim', 'gceff', 'jyperk', 'eop', 'ph', 'rq', 'evlagain', 'sbd' ]}, 'infile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'endpoint': {'type': 'cStr', 'coerce': _coerce.to_str}, 'timeout': {'type': 'cInt'}, 'retry': {'type': 'cInt'}, 'retry_wait_time': {'type': 'cInt'}, 'ant_pos_time_limit': {'type': 'cInt'}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'pol': {'type': 'cStr', 'coerce': _coerce.to_str}, 'parameter': {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, 'uniform': {'type': 'cBool'}} 

211 doc = {'vis': vis, 'caltable': caltable, 'caltype': caltype, 'infile': infile, 'endpoint': endpoint, 'timeout': timeout, 'retry': retry, 'retry_wait_time': retry_wait_time, 'ant_pos_time_limit': ant_pos_time_limit, 'spw': spw, 'antenna': antenna, 'pol': pol, 'parameter': parameter, 'uniform': uniform} 

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

213 _logging_state_ = _start_log( 'gencal', [ 'vis=' + repr(_pc.document['vis']), 'caltable=' + repr(_pc.document['caltable']), 'caltype=' + repr(_pc.document['caltype']), 'infile=' + repr(_pc.document['infile']), 'endpoint=' + repr(_pc.document['endpoint']), 'timeout=' + repr(_pc.document['timeout']), 'retry=' + repr(_pc.document['retry']), 'retry_wait_time=' + repr(_pc.document['retry_wait_time']), 'ant_pos_time_limit=' + repr(_pc.document['ant_pos_time_limit']), 'spw=' + repr(_pc.document['spw']), 'antenna=' + repr(_pc.document['antenna']), 'pol=' + repr(_pc.document['pol']), 'parameter=' + repr(_pc.document['parameter']), 'uniform=' + repr(_pc.document['uniform']) ] ) 

214 task_result = None 

215 try: 

216 task_result = _gencal_t( _pc.document['vis'], _pc.document['caltable'], _pc.document['caltype'], _pc.document['infile'], _pc.document['endpoint'], _pc.document['timeout'], _pc.document['retry'], _pc.document['retry_wait_time'], _pc.document['ant_pos_time_limit'], _pc.document['spw'], _pc.document['antenna'], _pc.document['pol'], _pc.document['parameter'], _pc.document['uniform'] ) 

217 except Exception as exc: 

218 _except_log('gencal', exc) 

219 raise 

220 finally: 

221 task_result = _end_log( _logging_state_, 'gencal', task_result ) 

222 return task_result 

223 

224gencal = _gencal( ) 

225