Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/cvel2.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 cvel2.xml ##################### 

2##################### b0b759de57aa7d74a7bbb529a642b212 ############################## 

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_cvel2 import cvel2 as _cvel2_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 _cvel2: 

15 """ 

16 cvel2 ---- Regrid an MS or MMS to a new spectral window, channel structure or frame 

17 

18  

19 The intent of cvel2 is to transform channel labels and the 

20 visibilities to a spectral reference frame which is appropriate for 

21 the science analysis, e.g. from TOPO to LSRK to correct for Doppler 

22 shifts throughout the time of the observation. Naturally, this will 

23 change the shape of the spectral feature to some extent. According to 

24 the Nyquist theorem you should oversample a spectrum with twice the 

25 numbers of channels to retain the shape. Based on some tests, however, 

26 we recommend to observe with at least 3-4 times the number of channels 

27 for each significant spectral feature (like 3-4 times the 

28 linewidth). This will minimize regridding artifacts in cvel2. 

29  

30 If cvel2 has already established the grid that is desired for the 

31 imaging, tclean should be run with exactly the same frequency/velocity 

32 parameters as used in cvel2 in order to avoid additional regridding in 

33 clean. 

34  

35 Hanning smoothing is optionally offered in cvel2, but tests have shown 

36 that already the regridding process itself, if it involved a 

37 transformation from TOPO to a non-terrestrial reference frame, implies 

38 some smoothing (due to channel interpolation) such that Hanning 

39 smoothing may not be necessary. 

40  

41 This version of cvel2 also supports Multi-MS input, in which case it 

42 will create an output Multi-MS too. 

43  

44 NOTE: 

45 The parameter passall is not supported in cvel2. The user may 

46 achieve the same results of passall=True by splitting out the data 

47 that will not be regridded with cvel2 and concatenate regridded 

48 and non-regridded sets at the end. In the case of Multi-MS input, 

49 the user should use virtualconcat to achieve a concatenated MMS. 

50 

51 --------- parameter descriptions --------------------------------------------- 

52 

53 vis Name of input visibility file 

54 Default: none 

55  

56 Example: vis='ngc5921.ms' 

57 outputvis Name of output visibility file or Multi-MS 

58 Default: none 

59  

60 Example: vis='ngc5921_out.ms' 

61 keepmms If the input is a Multi-MS the output will also be a 

62 Multi-MS. 

63 Default: True 

64  

65 By default it will create a Multi-MS when the 

66 input is a Multi-MS. The output Multi-MS will 

67 have the same partition axis of the input 

68 MMS. See 'help partition' for more information on 

69 the MMS format. 

70  

71 NOTE: It is not possible to combine the spws if 

72 the input MMS was partitioned with 

73 separationaxis='spw'. In this case, the task will 

74 abort with an error. 

75 passall HIDDEN parameter. Pass through (write to output MS) non-selected data with no change 

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

77 Default: '' (all fields) 

78  

79 Use 'go listobs' to obtain the list id's or 

80 names. If field string is a non-negative integer, 

81 it is assumed a field index, otherwise, it is 

82 assumed a field name. 

83  

84 Examples: 

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

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

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

88 3C295 

89 field = '3,4C*'; field id 3, all names 

90 starting with 4C 

91 spw Select spectral window/channels 

92 Default: ''=all spectral windows and channels 

93  

94 Examples: 

95 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 

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

97 spw='0:5~61'; spw 0, channels 5 to 61 

98 spw='0,10,3:3~45'; spw 0,10 all channels, spw 

99 3 - chans 3 to 45. 

100 spw='0~2:2~6'; spw 0,1,2 with channels 2 

101 through 6 in each. 

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

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

104  

105 NOTE: mstransform does not support multiple 

106 channel ranges per spectral window. 

107 scan Scan number range 

108 Subparameter of selectdata=True 

109 default: '' = all 

110 antenna Select data based on antenna/baseline 

111 Subparameter of selectdata=True 

112 default: '' (all) 

113  

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

115 is assumed an antenna index, otherwise, it is 

116 assumed as an antenna name 

117  

118 Examples:  

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

120 index 5 and index 6. 

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

122 antenna 5 and 6. 

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

124 indices 5-6 and 7-8 

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

126 5 

127 antenna='05'; all baselines with antenna 

128 number 05 (VLA old name) 

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

130 5,6,10 index numbers 

131 antenna='!ea03,ea12,ea17': all baselines 

132 except those that include EVLA antennas ea03, 

133 ea12, or ea17. 

134 correlation Select data based on correlation 

135 Default: '' (all) 

136  

137 Example: correlation='XX,YY'. 

138 timerange Select data based on time range 

139 Subparameter of selectdata=True 

140 Default = '' (all) 

141  

142 Examples: 

143 timerange = 

144 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 

145 (Note: if YYYY/MM/DD is missing date defaults 

146 to first day in data set.) 

147 timerange='09:14:0~09:54:0' picks 40 min on 

148 first day  

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

150 hr 30min on NEXT day 

151 timerange='09:44:00' pick data within one 

152 integration of time 

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

154 intent Select observing intent 

155 Default: '' (no selection by intent) 

156  

157 Example: intent='*BANDPASS*' (selects data 

158 labelled with BANDPASS intent) 

159 array Select (sub)array(s) by array ID number. 

160 Default = '' (all) 

161 uvrange Select data by baseline length. 

162 observation Select by observation ID(s) 

163 Subparameter of selectdata=True 

164 Default: '' = all 

165  

166 Example: observation='0~2,4' 

167 feed Multi-feed numbers: Not yet implemented. 

168 datacolumn Which data column(s) to process. 

169 mode Regridding mode (channel/velocity/frequency/channel_b). 

170 Default: 'channel' 

171 Options: 'channel', 'velocity', 'frequency', 

172 'channel_b' 

173  

174 * mode = 'channel'; Use with nchan, start, width to 

175 specify output spw. Produces equidistant grid 

176 based on first selected channel. 

177 * mode = 'velocity', means channels are specified 

178 in velocity. 

179 * mode = 'frequency', means channels are specified 

180 in frequency. 

181 * mode = 'channel_b', alternative 'channel' 

182 mode. Does not force an equidistant grid. Faster. 

183  

184 Examples:  

185 spw = '0,1'; mode = 'channel' will produce a 

186 single spw containing all channels in spw 0 

187 and 1 

188 spw='0:5~28^2'; mode = 'channel' will produce 

189 a single spw made with channels 

190 (5,7,9,...,25,27) 

191 spw = '0'; mode = 'channel': nchan=3; start=5; 

192 width=4 will produce an spw with 3 output 

193 channels 

194 - new channel 1 contains data from channels 

195 (5+6+7+8) 

196 - new channel 2 contains data from channels 

197 (9+10+11+12) 

198 - new channel 3 contains data from channels 

199 (13+14+15+16) 

200 spw = '0:0~63^3'; mode='channel'; nchan=21; 

201 start = 0; width = 1 will produce an spw with 

202 21 channels 

203 - new channel 1 contains data from channel 0 

204 - new channel 2 contains data from channel 2 

205 - new channel 21 contains data from channel 61 

206 spw = '0:0~40^2'; mode = 'channel'; nchan = 3; 

207 start = 5; width = 4 will produce an spw with 

208 three output channels 

209 - new channel 1 contains channels (5,7) 

210 - new channel 2 contains channels (13,15) 

211 - new channel 3 contains channels (21,23) 

212 nchan Number of channels in the output spw (-1=all).  

213 Subparameter of 

214 mode='channel|velocity|frequency|channel_b'  

215 Default: -1 = all channels 

216  

217 Used for regridding, together with 'start' and 

218 'width'. 

219  

220 Example: nchan=3 

221 start Start or end input channel (zero-based), depending on the sign of the width parameter  

222 Subparameter of 

223 mode='channel|velocity|frequency|channel_b'  

224  

225 Used for regridding, together with 'width' and 

226 'nchan'. It can be in different units, depending 

227 on the regridding mode:  

228 - first input channel (mode='channel'),  

229 - first velocity (mode='velocity'), or  

230 - first frequency (mode='frequency').  

231  

232 Example values: '5', '0.0km/s', '1.4GHz', for 

233 channel, velocity, and frequency modes, 

234 respectively. 

235 width Channel width of the output visibilities.  

236 Subparameter of 

237 mode='channel|velocity|frequency|channel_b'  

238  

239 Used for regridding, together with 'start', and 

240 'nchan'. It can be in different units, depending 

241 on the regridding mode: number of input channels 

242 (mode='channel'), velocity (mode='velocity'), or 

243 frequency (mode='frequency'.  

244  

245 Example values: '2', '1.0km/s', '1.0kHz', for 

246 channel, velocity, and frequency modes, 

247 respectively. 

248  

249 Note: the sign indicates whether the start 

250 parameter is lower(+) or upper(-) end of the 

251 range. 

252 interpolation Spectral interpolation method 

253 Subparameter of 

254 mode='channel|velocity|frequency|channel_b' 

255 Default = 'linear' 

256 Options: linear, nearest, cubic, spline, fftshift 

257 phasecenter Phase center direction to be used for the spectral 

258 coordinate transformation. 

259 Default: '' (first selected field) 

260 Options: FIELD_ID (int) or center coordinate measure (str). 

261  

262 Phase direction measure or fieldid. To be used 

263 in mosaics to indicate the center direction to be 

264 used in the spectral coordinate transformation. 

265  

266 Examples:  

267 phasecenter=6 

268 phasecenter='J2000 19h30m00 -40d00m00' 

269 restfreq Rest frequency to use for output visibilities. 

270 Default=''  

271  

272 Occasionally it is necessary to set this (for 

273 example some VLA spectral line data). For 

274 example for NH_3 (1,1) put 

275 restfreq='23.694496GHz' 

276 outframe Output reference frame (not case-sensitive). 

277 Default: '' (keep original reference frame) 

278 Options: LSRK, LSRD, BARY, GALACTO, LGROUP, CMB, 

279 GEO, TOPO, or SOURCE  

280  

281 SOURCE is meant for solar system work and 

282 corresponds to GEO + radial velocity correction 

283 for ephemeris objects. 

284  

285 Example: outframe='BARY' 

286 veltype Definition of velocity (in mode) 

287 Default = 'radio' 

288 hanning Hanning smooth data to remove Gibbs ringing. 

289 Default: False 

290 Options: False|True 

291 RETURNS void 

292 

293 --------- examples ----------------------------------------------------------- 

294 

295  

296  

297 For more information, see the task pages of cvel2 in CASA Docs: 

298  

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

300 

301 

302 """ 

303 

304 _info_group_ = """manipulation""" 

305 _info_desc_ = """Regrid an MS or MMS to a new spectral window, channel structure or frame""" 

306 

307 def __call__( self, vis='', outputvis='', keepmms=True, passall=False, field='', spw='', scan='', antenna='', correlation='', timerange='', intent='', array='', uvrange='', observation='', feed='', datacolumn='all', mode='channel', nchan=int(-1), start=int(0), width=int(1), interpolation='linear', phasecenter='', restfreq='', outframe='', veltype='radio', hanning=False ): 

308 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outputvis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'keepmms': {'type': 'cBool'}, 'passall': {'type': 'cBool'}, 'field': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'spw': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'scan': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'antenna': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'correlation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'timerange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'intent': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'array': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'uvrange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'observation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'feed': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'DATA', 'model', 'corrected', 'LAG_DATA', 'lag_data', 'FLOAT_DATA,DATA', 'FLOAT_DATA', 'CORRECTED', 'lag_data,data', 'float_data', 'float_data,data', 'DATA,MODEL,CORRECTED', 'ALL', 'MODEL', 'all', 'data,model,corrected', 'LAG_DATA,DATA', 'data' ]}, 'mode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'channel', 'velocity', 'frequency', 'channel_b' ]}, 'nchan': {'type': 'cInt'}, 'start': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'width': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'interpolation': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'nearest', 'linear', 'spline', 'fftshift', 'cubic' ]}, 'phasecenter': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'restfreq': {'type': 'cStr', 'coerce': _coerce.to_str}, 'outframe': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'SOURCE', 'LSRK', 'CMB', 'geo', 'source', 'bary', 'GALACTO', 'GEO', 'TOPO', 'LSRD', 'lsrk', 'topo', 'LGROUP', 'BARY', 'lsrd', 'cmb', 'galacto', 'lgroup', '' ]}, 'veltype': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'optical', 'radio', 'OPTICAL', 'RADIO' ]}, 'hanning': {'type': 'cBool'}} 

309 doc = {'vis': vis, 'outputvis': outputvis, 'keepmms': keepmms, 'passall': passall, 'field': field, 'spw': spw, 'scan': scan, 'antenna': antenna, 'correlation': correlation, 'timerange': timerange, 'intent': intent, 'array': array, 'uvrange': uvrange, 'observation': observation, 'feed': feed, 'datacolumn': datacolumn, 'mode': mode, 'nchan': nchan, 'start': start, 'width': width, 'interpolation': interpolation, 'phasecenter': phasecenter, 'restfreq': restfreq, 'outframe': outframe, 'veltype': veltype, 'hanning': hanning} 

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

311 _logging_state_ = _start_log( 'cvel2', [ 'vis=' + repr(_pc.document['vis']), 'outputvis=' + repr(_pc.document['outputvis']), 'keepmms=' + repr(_pc.document['keepmms']), 'passall=' + repr(_pc.document['passall']), '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']), 'array=' + repr(_pc.document['array']), 'uvrange=' + repr(_pc.document['uvrange']), 'observation=' + repr(_pc.document['observation']), 'feed=' + repr(_pc.document['feed']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'mode=' + repr(_pc.document['mode']), 'nchan=' + repr(_pc.document['nchan']), 'start=' + repr(_pc.document['start']), 'width=' + repr(_pc.document['width']), 'interpolation=' + repr(_pc.document['interpolation']), 'phasecenter=' + repr(_pc.document['phasecenter']), 'restfreq=' + repr(_pc.document['restfreq']), 'outframe=' + repr(_pc.document['outframe']), 'veltype=' + repr(_pc.document['veltype']), 'hanning=' + repr(_pc.document['hanning']) ] ) 

312 task_result = None 

313 try: 

314 task_result = _cvel2_t( _pc.document['vis'], _pc.document['outputvis'], _pc.document['keepmms'], _pc.document['passall'], _pc.document['field'], _pc.document['spw'], _pc.document['scan'], _pc.document['antenna'], _pc.document['correlation'], _pc.document['timerange'], _pc.document['intent'], _pc.document['array'], _pc.document['uvrange'], _pc.document['observation'], _pc.document['feed'], _pc.document['datacolumn'], _pc.document['mode'], _pc.document['nchan'], _pc.document['start'], _pc.document['width'], _pc.document['interpolation'], _pc.document['phasecenter'], _pc.document['restfreq'], _pc.document['outframe'], _pc.document['veltype'], _pc.document['hanning'] ) 

315 except Exception as exc: 

316 _except_log('cvel2', exc) 

317 raise 

318 finally: 

319 task_result = _end_log( _logging_state_, 'cvel2', task_result ) 

320 return task_result 

321 

322cvel2 = _cvel2( ) 

323