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

27 statements  

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

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

2##################### e8ee8b38fa0a4cd83c694ea0c3a33a00 ############################## 

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_sdatmcor import sdatmcor as _sdatmcor_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 _sdatmcor: 

15 """ 

16 sdatmcor ---- Offline correction of residual atmospheric features 

17 

18  

19  

20 The task sdatmcor provides the capability of offline correction of 

21 residual atmospheric features in the calibrated single-dish spectra 

22 which result from the difference of elevation angle between ON_SOURCE 

23 and OFF_SOURCE measurements. 

24  

25 The correction factor is derived from the atmosphere model based on 

26 the atmospheric properties (temperature, pressure, etc.) measured 

27 during the observation. The model is constructed by the atmosphere 

28 (at) tool. 

29  

30 For spw selection, two selection parameters, spw and outputspw, 

31 are available. The former specifies the data to be 

32 corrected while the latter corresponds to the spw for output. 

33 In practice, intersection of spw and outputspw is corrected. 

34 For example, when spw='19,23' and outputspw='19', spw 23 is not 

35 corrected because data for spw 23 is not written to outfile so 

36 that the correction is not meaningful. 

37 For data selection parameters other than spw, only data selected 

38 by data selection parameters are corrected and written to the outfile. 

39  

40 Note that outfile will have the data column DATA regardless of 

41 what data column exists in infile. 

42 

43 --------- parameter descriptions --------------------------------------------- 

44 

45 infile name of input MS. 

46 datacolumn name of data column to be used ["data", "float_data", or "corrected"] 

47 outfile name of output MS. 

48 overwrite allow to overwrite the output file if already exists. 

49 field Select fields. Use field id(s) or name(s). 

50  

51 If field string is a non-negative integer, it is assumed to 

52 be a field index otherwise, it is assumed to be a field name. 

53  

54 Default: ''= all fields 

55  

56 Example: 

57 field='0~2'; field ids 0,1,2 

58 field='0,4,5~7'; field ids 0,4,5,6,7 

59 field='3C286,3C295'; field named 3C286 and 3C295 

60 field = '3,4C*'; field id 3, all names starting with 4C 

61 spw Select spectral windows 

62  

63 Note that spw specifies the list of spw ids to apply correction. 

64 Spw ids to output should be specified by outputspw. 

65  

66 Note also that channel selection is not available for this task. 

67  

68 Default: ''=all spectral windows 

69 Example: 

70 spw='0~2,4'; spectral windows 0,1,2,4 

71 spw='<2'; spectral windows less than 2 (i.e. 0,1) 

72 spw='0,10'; spw 0,10 

73 scan Scan number range 

74  

75 Default: '' (all) 

76 Example: scan='1~5' 

77 antenna Select data based on antenna/baseline 

78  

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

80 assumed to be an antenna index, otherwise, it is 

81 considered an antenna name. 

82  

83 If specified selection doesn't contain any autocorrelation, 

84 the selection will be tweaked to include autocorrelation data. 

85 For example, 'PM02' will be interpreted as 'PM02&&&'. 

86  

87 Default: '' (all) 

88 Example: 

89 antenna='5&6'; baseline between antenna index 5 and 

90 index 6. 

91 antenna='VA05&VA06'; baseline between VLA antenna 5 

92 and 6. 

93 antenna='5&6;7&8'; baselines 5-6 and 7-8 

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

95 antenna='05'; all baselines with antenna number 05 

96 (VLA old name) 

97 antenna='5,6,9'; all baselines with antennas 5,6,9 

98 index number 

99 correlation Correlation (polarization) types or expression 

100  

101 Default: '' (all correlations) 

102 Example: correlation='XX,YY' 

103 timerange Range of time to select from data 

104  

105 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 

106 Note: if YYYY/MM/DD is missing date defaults to first 

107 day in data set 

108  

109 Default: '' (all) 

110 Example: 

111 timerange='09:14:0~09:54:0' picks 40 min on first day 

112 timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 

113 30min on NEXT day 

114 timerange='09:44:00' pick data within one integration 

115 of time 

116 timerange='> 10:24:00' data after this time 

117 intent Scan Intent(s) 

118  

119 Default: '' (all) 

120 Example: 

121 intent='TARGET_SOURCE' 

122 intent='TARGET_SOURCE1,TARGET_SOURCE2' 

123 intent='TARGET_POINTING*' 

124 observation Observation ID range 

125  

126 Default: '' (all observations) 

127 Example: observation='0~5' 

128 feed feed selection 

129  

130 Default: '' (all feeds) 

131 Example: feed='0,1' 

132 msselect Complicated data selection using TaQL 

133  

134 Complicated data selection that cannot be supported by other 

135 data selection parameters should be specified here using TaQL. 

136 See Casacore Note 199 for detailed syntax of TaQL: 

137  

138 https://casacore.github.io/casacore-notes/199.html 

139  

140 Default: '' (all data) 

141 Example: 

142 msselect='ABS(DATA) < 1 && ANTENNA1 == ANTENNA2 + 1' 

143 msselect='ROWNUMBER() < 100' 

144 outputspw select spws to output, same syntax of spw.("" = all) 

145  

146 Note that outputspw specifies the list of spw ids to output. 

147 Spw ids to be corrected should be specified by spw. 

148  

149 Note also that channel selection is not available for this task. 

150 gainfactor Gain factor to multiply correction term. 

151  

152 In ALMA data reduction, intensity of calibrated spectra, antenna 

153 temperature Ta* in unit of Kelvin, is converted to Jansky (Jy) 

154 by multiplying conversion factor. This parameter is intended to 

155 apply exactly the same multiplicative factor to correction term. 

156 If no conversion is applied to spectral data, gainfactor should 

157 be 1.0, which means that the correction is in unit of Ta*. 

158 The value can be float, dict, or string. Default is 1.0. 

159  

160 Float value is interpreted as fixed factor, which is applied to all spws. 

161  

162 Dict should be the pair of spw id (key) and the factor to be applied (value). 

163 Key should be string rather than int. 

164  

165 If string is given, it should be the name of caltable. For caltable, 

166 inverse square of stored value is applied. 

167  

168 Default: 1.0 

169 Example: 10.0 

170 {'17': 45.0, '19': 43.5, '21': 42.0, '23': 40.0} 

171 'k2jycal.tbl' 

172 dtem_dh temperature gradient [K/km], e.g. -5.6. ("" = Tool default) 

173  

174 The value is directly passed to initialization method for ATM model. 

175 Float and string types are acceptable. Float value is interpreted as 

176 the value in K/km. String value should be the numeric value with unit 

177 such as '-5.6K/km'. 

178  

179 Default: '' (tool default, -5.6K/km, is used) 

180 h0 scale height for water [km], e.g. 2.0. ("" = Tool default) 

181  

182 The value is directly passed to initialization method for ATM model. 

183 Float and string types are acceptable. Float value is interpreted as 

184 the value in kilometer. String value should be the numeric value with 

185 unit compatible with length, such as '2km' or '2000m'. 

186 atmtype Atmospheric type. 

187 The value is directly passed to initialization method for ATM model. 

188 The type should be specified as integer. Available options are, 

189  

190 1: tropical 

191 2: mid latitude summer (default) 

192 3: mid latitude winter 

193 4: subarctic summer 

194 5: subarctic winter 

195 atmdetail Expose parameters for detailed configuration of ATM model if True. 

196  

197 The following parameters are exposed to the user if atmdetail is True: 

198  

199 altitude 

200 temperature 

201 pressure 

202 humidity 

203 pwv 

204 dp 

205 dpm 

206 layerboundaries 

207 layertemperature 

208 altitude Site altitude [m]. 

209  

210 The value is directly passed to initialization method for ATM model. 

211 Float and string types are acceptable. Float value is interpreted as 

212 the value in meter. String value should be the numeric value with 

213 unit compatible with length, such as '5km' or '5000m'. 

214  

215 Default value is taken from the input MS (ANTENNA table). 

216 temperature Ambient temperature [K]. 

217  

218 The value is directly passed to initialization method for ATM model. 

219 Float and string types are acceptable. Float value is interpreted as 

220 the value in Kelvin. String value should be the numeric value with 

221 unit, such as '270K'. 

222  

223 Default value is taken from the input MS (ASDM_CALATMOSPHERE table). 

224 pressure Ambient pressure [mbar]. 

225  

226 The value is directly passed to initialization method for ATM model. 

227 Float and string types are acceptable. Float value is interpreted as 

228 the value in mbar. String value should be the numeric value with 

229 unit compatible with pressure, such as '1000mbar' or '1000hPa'. 

230  

231 Default value is taken from the input MS (ASDM_CALATMOSPHERE table). 

232 humidity Relative humidity [percent]. 

233  

234 If the value is explicitly specified, it should range from 0 to 100. 

235  

236 Default value (-1) indicates that the value is taken from the input MS 

237 (ASDM_CALATMOSPHERE table). 

238 pwv Zenith water vapor [mm]. 

239  

240 The value is directly passed to configuration method for ATM model. 

241 Float and string types are acceptable. Float value is interpreted as 

242 the value in millimeter. String value should be the numeric value with 

243 the unit compatible with length, such as '0.3mm' 

244  

245 Default value is taken from the input MS (ASDM_CALWVR table). 

246 dp Initial pressure step. 

247  

248 The value is directly passed to initialization method for ATM model. 

249 Float and string types are acceptable. Float value is interpreted as 

250 the value in mbar. String value should be the numeric value with 

251 unit compatible with pressure, such as '10mbar' or '10hPa'. 

252  

253 Default value ('') indicates to use tool default (10mbar). 

254 dpm Pressure multiplicative factor for steps. 

255  

256 The value is directly passed to initialization method for ATM model. 

257 Default value (-1) indicates to use tool default (1.2). 

258 layerboundaries Altitude of user-defined temperature profile. 

259  

260 The value is directly passed to initialization method for ATM model. 

261 String, list of strings, and list of float values are acceptable. 

262  

263 For list inputs, float values are interpreted as the value in meter 

264 while the string values should be the numeric value with the unit 

265 compatible with length. 

266  

267 For string input, the value should be comma separated list of 

268 strings consisting of numeric value and the unit compatible with 

269 length. 

270  

271 Number of values should be identical to the number for layertemperature. 

272  

273 Default value ('') indicates to use tool default. 

274  

275 Example: [1000, 2000] 

276 ['1km', '2km'] 

277 '1km,2km' 

278 layertemperature User-defined temperature profile [K]. 

279  

280 The value is directly passed to initialization method for ATM model. 

281 String, list of strings, and list of float values are acceptable. 

282  

283 For list inputs, float values are interpreted as the value in Kelvin 

284 while the string values should be the numeric value with unit. 

285  

286 For string input, the value should be comma separated list of 

287 strings consisting of numeric value and unit. 

288  

289 Number of values should be identical to the number for layerboundaries. 

290  

291 Example: [250, 240] 

292 ['250K', '240K'] 

293 '250K,240K' 

294 

295 --------- examples ----------------------------------------------------------- 

296 

297  

298 

299 

300 """ 

301 

302 _info_group_ = """single dish""" 

303 _info_desc_ = """Offline correction of residual atmospheric features""" 

304 

305 def __call__( self, infile='', datacolumn='data', outfile='', overwrite=False, field='', spw='', scan='', antenna='', correlation='', timerange='', intent='', observation='', feed='', msselect='', outputspw='', gainfactor=float(1.0), dtem_dh='', h0='', atmtype=int(2), atmdetail=False, altitude='', temperature='', pressure='', humidity=float(-1), pwv='', dp='', dpm=float(-1), layerboundaries='', layertemperature='' ): 

306 schema = {'infile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'data', 'float_data', 'corrected' ]}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'overwrite': {'type': 'cBool'}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'scan': {'type': 'cStr', 'coerce': _coerce.to_str}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'correlation': {'type': 'cStr', 'coerce': _coerce.to_str}, 'timerange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'observation': {'type': 'cStr', 'coerce': _coerce.to_str}, 'feed': {'type': 'cStr', 'coerce': _coerce.to_str}, 'msselect': {'type': 'cStr', 'coerce': _coerce.to_str}, 'outputspw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'gainfactor': {'anyof': [{'type': 'cFloat', 'coerce': _coerce.to_float}, {'type': 'cDict'}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'dtem_dh': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'h0': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'atmtype': {'type': 'cInt'}, 'atmdetail': {'type': 'cBool'}, 'altitude': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'temperature': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'pressure': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'humidity': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'pwv': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'dp': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'dpm': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'layerboundaries': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}]}, 'layertemperature': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}]}} 

307 doc = {'infile': infile, 'datacolumn': datacolumn, 'outfile': outfile, 'overwrite': overwrite, 'field': field, 'spw': spw, 'scan': scan, 'antenna': antenna, 'correlation': correlation, 'timerange': timerange, 'intent': intent, 'observation': observation, 'feed': feed, 'msselect': msselect, 'outputspw': outputspw, 'gainfactor': gainfactor, 'dtem_dh': dtem_dh, 'h0': h0, 'atmtype': atmtype, 'atmdetail': atmdetail, 'altitude': altitude, 'temperature': temperature, 'pressure': pressure, 'humidity': humidity, 'pwv': pwv, 'dp': dp, 'dpm': dpm, 'layerboundaries': layerboundaries, 'layertemperature': layertemperature} 

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

309 _logging_state_ = _start_log( 'sdatmcor', [ 'infile=' + repr(_pc.document['infile']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'outfile=' + repr(_pc.document['outfile']), 'overwrite=' + repr(_pc.document['overwrite']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'scan=' + repr(_pc.document['scan']), 'antenna=' + repr(_pc.document['antenna']), 'correlation=' + repr(_pc.document['correlation']), 'timerange=' + repr(_pc.document['timerange']), 'intent=' + repr(_pc.document['intent']), 'observation=' + repr(_pc.document['observation']), 'feed=' + repr(_pc.document['feed']), 'msselect=' + repr(_pc.document['msselect']), 'outputspw=' + repr(_pc.document['outputspw']), 'gainfactor=' + repr(_pc.document['gainfactor']), 'dtem_dh=' + repr(_pc.document['dtem_dh']), 'h0=' + repr(_pc.document['h0']), 'atmtype=' + repr(_pc.document['atmtype']), 'atmdetail=' + repr(_pc.document['atmdetail']), 'altitude=' + repr(_pc.document['altitude']), 'temperature=' + repr(_pc.document['temperature']), 'pressure=' + repr(_pc.document['pressure']), 'humidity=' + repr(_pc.document['humidity']), 'pwv=' + repr(_pc.document['pwv']), 'dp=' + repr(_pc.document['dp']), 'dpm=' + repr(_pc.document['dpm']), 'layerboundaries=' + repr(_pc.document['layerboundaries']), 'layertemperature=' + repr(_pc.document['layertemperature']) ] ) 

310 task_result = None 

311 try: 

312 task_result = _sdatmcor_t( _pc.document['infile'], _pc.document['datacolumn'], _pc.document['outfile'], _pc.document['overwrite'], _pc.document['field'], _pc.document['spw'], _pc.document['scan'], _pc.document['antenna'], _pc.document['correlation'], _pc.document['timerange'], _pc.document['intent'], _pc.document['observation'], _pc.document['feed'], _pc.document['msselect'], _pc.document['outputspw'], _pc.document['gainfactor'], _pc.document['dtem_dh'], _pc.document['h0'], _pc.document['atmtype'], _pc.document['atmdetail'], _pc.document['altitude'], _pc.document['temperature'], _pc.document['pressure'], _pc.document['humidity'], _pc.document['pwv'], _pc.document['dp'], _pc.document['dpm'], _pc.document['layerboundaries'], _pc.document['layertemperature'] ) 

313 except Exception as exc: 

314 _except_log('sdatmcor', exc) 

315 raise 

316 finally: 

317 task_result = _end_log( _logging_state_, 'sdatmcor', task_result ) 

318 return task_result 

319 

320sdatmcor = _sdatmcor( ) 

321