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

2##################### 63f2bd0ee18ea79d81a985116dd0f469 ############################## 

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_importasdm import importasdm as _importasdm_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 _importasdm: 

15 """ 

16 importasdm ---- Convert an ALMA Science Data Model observation into a CASA visibility file (MS) 

17 

18  

19 Convert an ALMA Science Data Model observation into a CASA visibility 

20 file (MS) 

21 

22 --------- parameter descriptions --------------------------------------------- 

23 

24 asdm Name of input ASDM file (directory) 

25 Default: none 

26  

27 Example: asdm='ExecBlock3' 

28 vis Root ms name.  

29 Default: none 

30  

31 Note that a prefix (.ms) is NOT appended to this 

32 name. 

33 createmms Create a Multi-MS partitioned according to the given 

34 separation axis. 

35 Default: False 

36 Options: False|True 

37  

38 For more detailed documentation on partition, 

39 Multi-MS and the MPI use in CASA, please see CASA 

40 Docs (https://casa.nrao.edu/casadocs/). 

41 separationaxis Axis to do parallelization across 

42 Default: 'auto' 

43 Options: 'scan', 'spw', 'baseline', 'auto' 

44  

45 * auto: will partition per scan/spw to obtain 

46 optimal load balancing with the following 

47 criteria:  

48 1 - Maximize the scan/spw/field distribution 

49 across sub-MSs 

50 2 - Generate sub-MSs with similar size 

51 * 'scan' or 'spw': will partition the MS into 

52 scan or spw. The individual sub-MSs may not be 

53 balanced with respect to the number of rows. 

54 * 'baseline': mostly useful for Single-Dish 

55 data. This axis will partition the MS based on 

56 the available baselines. If the user wants only 

57 auto-correlations, use the 

58 ocorr_mode='ao'. Note that if numsubms='auto', 

59 partition will try to create as many subMSs as 

60 the number of available servers in the 

61 cluster. If the user wants to have one subMS 

62 for each baseline, set the numsubms parameter 

63 to a number higher than the number of baselines 

64 to achieve this. 

65 numsubms The number of sub-MSs to create in the Multi-Ms. 

66 Default: 'auto' 

67 Options: any integer number (example: numsubms=4) 

68  

69 The default 'auto' is to partition using the 

70 number of available servers given when launching 

71 CASA. If the task is unable to determine the 

72 number of running servers, or the user did not 

73 start CASA using mpicasa, numsubms will use 8 as 

74 the default. 

75  

76 Example: Launch CASA with 5 engines, where 4 

77 of them will be used to create the MMS (the 

78 first engine is used as the MPIClient): 

79 mpicasa -n 5 casa --nogui --log2term 

80 CASA> importasdm('uid__A1', createmms=True) 

81 corr_mode Correlation mode to be considered on input. 

82 Default: 'all' 

83 Options: ao, co, ac, or all 

84 srt Spectral resolution type. 

85 Default: 'all' 

86 Options: fr, ca, bw, or all 

87 time_sampling Specifies the time sampling (INTEGRATION and/or 

88 SUBINTEGRATION) to be considered on input.  

89 Default: 'all' 

90 Options: i, si, or all 

91  

92 A quoted string containing a sequence of i, si, 

93 or all separated by whitespaces is expected 

94 ocorr_mode Output data for correlation mode AUTO_ONLY (ao) or 

95 CROSS_ONLY (co) or CROSS_AND_AUTO (ca) 

96 Default: 'ca' 

97 Options: ao, co, ca 

98 compression Produce compressed columns in the resulting measurement 

99 set. 

100 Default: False 

101 Options: False|True 

102 lazy Make the MS DATA column read the ASDM Binary data 

103 directly (faster import, smaller MS). 

104 Default: False 

105 Options: False|True 

106  

107 Instead of writing a copy of the visibilities 

108 into a standard DATA column, lazy=True will make 

109 importasdm only write a lookup-table such that 

110 later access to the DATA column will read the 

111 ASDM binary visibility data directly. This 

112 requires that the ASDM not be removed from its 

113 location as long the the DATA column is 

114 needed. Use method ms.asdmref() to query and 

115 manipulate the reference to the ASDM. 

116  

117 lazy=True will save ca. 50% disk space and 

118 accelerate the DATA column access by 

119 ca. 10%. lazy=True will only work when there is 

120 visibility data in the ASDM, not with pure 

121 radiometer data. 

122 asis Creates verbatim copies of the ASDM tables in the output 

123 measurement set. 

124 Default: none 

125  

126 The value given to this option must be a list of 

127 table names separated by space characters; the 

128 wildcard character '*' is allowed in table 

129 names. 

130 wvr_corrected_data Specifies which values are considerd in the ASDM binary 

131 data to fill the DATA column in the MAIN table of the MS. 

132 Default: no 

133 Options: no|yes|both 

134  

135 * no: uncorrected data 

136 * yes: corrected data 

137 * both: for corrected and uncorrected data. Note 

138 if both is selected, two measurement sets are 

139 created, one with uncorrected data and the 

140 other with corrected data (which name is 

141 suffixed by '-wvr-corrected') 

142 scans Processes only the scans specified in the option's value. 

143 Default: none (all scans) 

144  

145 This value is a semicolon separated list of scan 

146 specifications. A scan specification consists in 

147 an exec bock index followed by the character ':' 

148 followed by a comma separated list of scan 

149 indexes or scan index ranges. A scan index is 

150 relative to the exec block it belongs to. Scan 

151 indexes are 1-based while exec blocks's are 

152 0-based.  

153  

154 Examples:  

155 '0:1'  

156 '2:2~6'  

157 '0:1;1:2~6,8;2:,3:24~30' 

158 '1,2'  

159 '3:' alone will be interpreted as 'all the 

160 scans of the exec block#3'. An scan index or a 

161 scan index range not preceded by an exec block 

162 index will be interpreted as 'all the scans 

163 with such indexes in all the exec blocks'. 

164 ignore_time All the rows of the tables Feed, History, Pointing, 

165 Source, SysCal, CalDevice, SysPower, and Weather are processed 

166 independently of the time range of the selected exec block / scan. 

167 Default: False 

168 Options: False|True 

169 process_syspower s processed if and only if this 

170 parameter is set to true. 

171 Default: True 

172 Options: True|False 

173 process_caldevice The CalDevice table is processed if and only if this 

174 parameter is set to true. 

175 Default: True 

176 Options: True|False 

177 process_pointing The Pointing table is processed if and only if this 

178 parameter is set to true.  

179 Default: True 

180 Options: True|False 

181  

182 If set to False, the POINTING table is empty in 

183 the resulting MS 

184 process_flags Create online flags based on the Flag.xml, Antenna.xml 

185 and SpectralWindow.xml files and copy them to the FLAG_CMD sub-table 

186 of the MS. 

187 Default: True 

188 Options: True|False 

189  

190 The flags will NOT be applied unless the 

191 parameter applyflags is set to True. Optionally, 

192 the flags can also be saved to an external ASCII 

193 file if savecmds is set to True. 

194 tbuff Time padding buffer (seconds) 

195 Subparameter of process_flags=True 

196 Default: 0.0 

197  

198 NOTE: this time is in seconds. You should 

199 currently set the value of tbuff to be 1.5x the 

200 correlator integration time if greater than 1 

201 second. For example, if the SDM has integrations 

202 of 3 seconds, set tbuff=4.5. Likewise, set 

203 tbuff=15.0 for 10-sec integrations. 

204 applyflags Apply the online flags to the MS. 

205 Subparameter of process_flags=True 

206 Default: False 

207 Options: False|True 

208 savecmds Save the flag commands to an ASCII file given by the 

209 parameter outfile.  

210 Subparameter of process_flags=True 

211 Default: False 

212 Options: False|True 

213 outfile Filename or list of filenames where to save the online 

214 flag commands. 

215 Subparameter of process_flags=True 

216 Default: '' (it will save on a filename composed 

217 from the MS name(s).) E.g., for vis='uid_A02.ms', 

218 the outfile will be 'uid_A02_cmd.txt'. 

219 flagbackup Back up flag column before applying flags. 

220 Default: True 

221 Options: True|False 

222 verbose Produce log output as asdm2MS is being run 

223 Default: False 

224 Options: False|True 

225 overwrite Over write an existing MS(s) or MS(s), if the option 

226 wvr_corrected_data='both' 

227 Default: False (do not overwrite) 

228 Options: False|True 

229  

230 NOTE: the overwrite parameter affects all the 

231 output of the task. If any of the following 

232 exist, it will not overwrite them. MS(s), 

233 .flagversions, online flag files. When set to 

234 True, it will overwrite the MS, .flagversions and 

235 online flag file. 

236 bdfflags Set the MS FLAG column according to the ASDM _binary_ 

237 flags 

238 Default: False 

239 Options: False|True 

240 with_pointing_correction Add (ASDM::Pointing::encoder - 

241 ASDM::Pointing::pointingDirection) to the value to be written in 

242 MS::Pointing::direction 

243 Default: False 

244 Options: False|True 

245 convert_ephem2geo if True, convert any attached ephemerides to the GEO 

246 reference frame (time-spacing not changed) 

247 Default: True 

248 Options: True|False 

249  

250 ALMA uses ephemerides with observer location 

251 equal to the ALMA site. For later processing of 

252 the radial velocity information in, e.g. cvel, a 

253 geocentric ephemeris is needed. Setting this 

254 option to True will perform the conversion of 

255 positions and velocities on all attached 

256 ephemerides in the imported MS. This will neither 

257 change the time-spacing nor the duration of the 

258 ephemeris. No interpolation in time is done. 

259 polyephem_tabtimestep Timestep (days) for the tabulation of polynomial 

260 ephemerides. A value less than or equal to 0 sets the timestep to 0.001 days.  

261 Default: 0 

262  

263 Presently, VLA data can contain polynomial 

264 ephemerides. ALMA data uses tabulated values. 

265 Polynomial ephemerides in the SDM are always 

266 tabulated using some timestep when the ephemeris 

267 tables attached to the MS are written. If a non-default 

268 value is used and the ASDM contains tabulated values 

269 then importasdm will log a warning messages informing 

270 the user that polyephem_tabtimestep is not used for 

271 tabulated ephemerides. 

272 RETURNS void 

273 

274 --------- examples ----------------------------------------------------------- 

275 

276  

277 FOR MORE INFORMATION, SEE THE TASK PAGES OF IMPORTASDM IN CASA DOCS: 

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

279  

280 

281 

282 """ 

283 

284 _info_group_ = """import/export""" 

285 _info_desc_ = """Convert an ALMA Science Data Model observation into a CASA visibility file (MS)""" 

286 

287 def __call__( self, asdm='', vis='', createmms=False, separationaxis='auto', numsubms='auto', corr_mode='all', srt='all', time_sampling='all', ocorr_mode='ca', compression=False, lazy=False, asis='', wvr_corrected_data='no', scans='', ignore_time=False, process_syspower=True, process_caldevice=True, process_pointing=True, process_flags=True, tbuff=float(0.0), applyflags=False, savecmds=False, outfile='', flagbackup=True, verbose=False, overwrite=False, bdfflags=False, with_pointing_correction=False, convert_ephem2geo=True, polyephem_tabtimestep=float(0.) ): 

288 schema = {'asdm': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'vis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'createmms': {'type': 'cBool'}, 'separationaxis': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'baseline', 'AUTO', 'SPW', 'SCAN', 'auto', 'spw', 'BASELINE', 'scan' ]}, 'numsubms': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}]}, 'corr_mode': {'type': 'cStr', 'coerce': _coerce.to_str}, 'srt': {'type': 'cStr', 'coerce': _coerce.to_str}, 'time_sampling': {'type': 'cStr', 'coerce': _coerce.to_str}, 'ocorr_mode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'co', 'ao', 'ca' ]}, 'compression': {'type': 'cBool'}, 'lazy': {'type': 'cBool'}, 'asis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'wvr_corrected_data': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'no', 'yes', 'both' ]}, 'scans': {'type': 'cStr', 'coerce': _coerce.to_str}, 'ignore_time': {'type': 'cBool'}, 'process_syspower': {'type': 'cBool'}, 'process_caldevice': {'type': 'cBool'}, 'process_pointing': {'type': 'cBool'}, 'process_flags': {'type': 'cBool'}, 'tbuff': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'applyflags': {'type': 'cBool'}, 'savecmds': {'type': 'cBool'}, 'outfile': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'flagbackup': {'type': 'cBool'}, 'verbose': {'type': 'cBool'}, 'overwrite': {'type': 'cBool'}, 'bdfflags': {'type': 'cBool'}, 'with_pointing_correction': {'type': 'cBool'}, 'convert_ephem2geo': {'type': 'cBool'}, 'polyephem_tabtimestep': {'type': 'cFloat', 'coerce': _coerce.to_float}} 

289 doc = {'asdm': asdm, 'vis': vis, 'createmms': createmms, 'separationaxis': separationaxis, 'numsubms': numsubms, 'corr_mode': corr_mode, 'srt': srt, 'time_sampling': time_sampling, 'ocorr_mode': ocorr_mode, 'compression': compression, 'lazy': lazy, 'asis': asis, 'wvr_corrected_data': wvr_corrected_data, 'scans': scans, 'ignore_time': ignore_time, 'process_syspower': process_syspower, 'process_caldevice': process_caldevice, 'process_pointing': process_pointing, 'process_flags': process_flags, 'tbuff': tbuff, 'applyflags': applyflags, 'savecmds': savecmds, 'outfile': outfile, 'flagbackup': flagbackup, 'verbose': verbose, 'overwrite': overwrite, 'bdfflags': bdfflags, 'with_pointing_correction': with_pointing_correction, 'convert_ephem2geo': convert_ephem2geo, 'polyephem_tabtimestep': polyephem_tabtimestep} 

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

291 _logging_state_ = _start_log( 'importasdm', [ 'asdm=' + repr(_pc.document['asdm']), 'vis=' + repr(_pc.document['vis']), 'createmms=' + repr(_pc.document['createmms']), 'separationaxis=' + repr(_pc.document['separationaxis']), 'numsubms=' + repr(_pc.document['numsubms']), 'corr_mode=' + repr(_pc.document['corr_mode']), 'srt=' + repr(_pc.document['srt']), 'time_sampling=' + repr(_pc.document['time_sampling']), 'ocorr_mode=' + repr(_pc.document['ocorr_mode']), 'compression=' + repr(_pc.document['compression']), 'lazy=' + repr(_pc.document['lazy']), 'asis=' + repr(_pc.document['asis']), 'wvr_corrected_data=' + repr(_pc.document['wvr_corrected_data']), 'scans=' + repr(_pc.document['scans']), 'ignore_time=' + repr(_pc.document['ignore_time']), 'process_syspower=' + repr(_pc.document['process_syspower']), 'process_caldevice=' + repr(_pc.document['process_caldevice']), 'process_pointing=' + repr(_pc.document['process_pointing']), 'process_flags=' + repr(_pc.document['process_flags']), 'tbuff=' + repr(_pc.document['tbuff']), 'applyflags=' + repr(_pc.document['applyflags']), 'savecmds=' + repr(_pc.document['savecmds']), 'outfile=' + repr(_pc.document['outfile']), 'flagbackup=' + repr(_pc.document['flagbackup']), 'verbose=' + repr(_pc.document['verbose']), 'overwrite=' + repr(_pc.document['overwrite']), 'bdfflags=' + repr(_pc.document['bdfflags']), 'with_pointing_correction=' + repr(_pc.document['with_pointing_correction']), 'convert_ephem2geo=' + repr(_pc.document['convert_ephem2geo']), 'polyephem_tabtimestep=' + repr(_pc.document['polyephem_tabtimestep']) ] ) 

292 task_result = None 

293 try: 

294 task_result = _importasdm_t( _pc.document['asdm'], _pc.document['vis'], _pc.document['createmms'], _pc.document['separationaxis'], _pc.document['numsubms'], _pc.document['corr_mode'], _pc.document['srt'], _pc.document['time_sampling'], _pc.document['ocorr_mode'], _pc.document['compression'], _pc.document['lazy'], _pc.document['asis'], _pc.document['wvr_corrected_data'], _pc.document['scans'], _pc.document['ignore_time'], _pc.document['process_syspower'], _pc.document['process_caldevice'], _pc.document['process_pointing'], _pc.document['process_flags'], _pc.document['tbuff'], _pc.document['applyflags'], _pc.document['savecmds'], _pc.document['outfile'], _pc.document['flagbackup'], _pc.document['verbose'], _pc.document['overwrite'], _pc.document['bdfflags'], _pc.document['with_pointing_correction'], _pc.document['convert_ephem2geo'], _pc.document['polyephem_tabtimestep'] ) 

295 except Exception as exc: 

296 _except_log('importasdm', exc) 

297 raise 

298 finally: 

299 task_result = _end_log( _logging_state_, 'importasdm', task_result ) 

300 return task_result 

301 

302importasdm = _importasdm( ) 

303