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

716 statements  

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

1# image-based line finding and baseline subtraction. 

2 

3from abc import abstractmethod 

4import contextlib 

5import os 

6import shutil 

7import sys 

8from typing import Any, Dict, List, Tuple, Union 

9import uuid 

10 

11import numpy as np 

12from numpy import array, uint64 

13 

14from casatasks import casalog 

15from casatasks.private.ialib import write_image_history 

16from casatasks.private.sdutil import (sdtask_decorator, table_manager, 

17 tool_manager) 

18from casatasks.private.task_imsmooth import imsmooth 

19from casatasks.private.task_sdbaseline import sdbaseline 

20from casatasks.private.task_sdsmooth import sdsmooth 

21from casatasks.private.update_spw import sets_to_spwchan, spwchan_to_sets 

22from casatools import image, quanta, table 

23 

24DATACOLUMN = 'DATA' 

25OVERWRITE = True 

26 

27IMAGE_STACK_MAX_HEIGHT = 5 

28MS_STACK_MAX_HEIGHT = 3 

29 

30qa = quanta() 

31do_not_erase_temporary_files = False 

32dump_tasks = False 

33 

34 

35class AbstractFolder: 

36 """Abstract class has Image/MeasurementSet file path. 

37 

38 This class and child classes are wrapper of CasaImage/MeasurementSet file. 

39 The wrapped path could be decided to erase by which child classes are implemented. 

40 """ 

41 

42 has_file = False 

43 

44 def __init__(self, file: str = None) -> None: 

45 """Initialize a Folder object.""" 

46 if not os.path.exists(file): 

47 raise ValueError(f'file {file} is not found') 

48 self.path = file 

49 self.has_file = True 

50 

51 @abstractmethod 

52 def erase(self) -> None: 

53 """Erase the file pointed path.""" 

54 raise RuntimeError('Not implemented') 

55 

56 

57class _EraseableFolder(AbstractFolder): 

58 """Image/MeasurementSet file path class. The file path is permitted to erase.""" 

59 

60 def __init__(self, file: str = None) -> None: 

61 super().__init__(file) 

62 _eraseable_folder_register.register(self) 

63 

64 def erase(self, dry_run: bool = True) -> None: 

65 if self.has_file: 

66 if dry_run: 

67 casalog.post(f'[DRY RUN] erase file: {self.path}', 'DEBUG2') 

68 else: 

69 casalog.post(f'erase file: {self.path}', 'DEBUG2') 

70 if os.path.exists(self.path): 

71 shutil.rmtree(self.path) 

72 if not os.path.exists(self.path): 

73 self.has_file = False 

74 else: 

75 casalog.post(f'not found the file to erase: {self.path}', 'WARN') 

76 

77 

78class _UnerasableFolder(AbstractFolder): 

79 """Image/MeasurementSet file path class. The file path is NOT permitted to erase.""" 

80 

81 def erase(self, dry_run: bool = True) -> None: 

82 casalog.post(f'un-erase file: {self.path}', 'DEBUG2') 

83 

84 

85class _EraseableFolderRegister(): 

86 """Class of the register of folders that need to be erased.""" 

87 

88 _register = dict() 

89 

90 def register(self, folder: _EraseableFolder): 

91 if isinstance(folder, _EraseableFolder) and folder.path not in self._register.keys(): 

92 self._register[folder.path] = folder 

93 else: 

94 raise ValueError('Irregal folder would be appended', 'SEVERE') 

95 

96 def clear(self, dry_run: bool = True): 

97 if not dry_run: 

98 for path, folder in self._register.items(): 

99 if not folder.has_file: 

100 raise RuntimeError('Invalid code execution state', 'SEVERE') 

101 elif not os.path.exists(path): 

102 raise RuntimeError(f'File not found: {path}', 'SEVERE') 

103 else: 

104 folder.erase(dry_run) 

105 self._register.clear() 

106 casalog.post('cleaned up _EraseableFolderRegister', 'DEBUG2') 

107 

108 def pop(self, key: str) -> _EraseableFolder: 

109 return self._register.pop(key) 

110 

111 

112_eraseable_folder_register = _EraseableFolderRegister() 

113 

114 

115class AbstractFileStack: 

116 """CasaImage/MeasurementSet file path stack to be processed by tasks in imbaseline. 

117 

118 The paths of CasaImage or MeasurementSet are wrapped by AbstractFolder class. 

119 Implementation classes of AbstractFileStack are _EraseableFolder/Un_EraseableFolder, the 

120 _EraseableFolder class erases the path holden by a property 'path' when execute cleaning 

121 process, and the Un_EraseableFolder class doesn't erase it. 

122 If this class is used to stack a path of CasaImage, the bottom of it must be the input 

123 image(an argument 'imagename'). 

124 """ 

125 

126 def __init__(self, top: AbstractFolder = None, max_height=None) -> None: 

127 """Initialize a FileStack object.""" 

128 self.stack = [] 

129 self.max_height = max_height 

130 if isinstance(top, AbstractFolder): 

131 self.push(top) 

132 

133 def push(self, file: AbstractFolder = None) -> None: 

134 """Push a folder into the stack.""" 

135 if not isinstance(file, AbstractFolder): 

136 raise ValueError(f'cannot append {file.path}') 

137 elif self.height() == self.max_height: 

138 raise RuntimeError('stack is full') 

139 else: 

140 casalog.post(f'push {file.path} into the stack', 'DEBUG2') 

141 self.stack.append(file) 

142 

143 def pop(self) -> AbstractFolder: 

144 """Return and remove the top of the stack. 

145 

146 The stack object should have input CasaImage or converted MeasurementSet at bottom, 

147 so if pop() is called when stack height is zero, then it raises RuntimeError. 

148 """ 

149 if self.height() <= 1: 

150 raise RuntimeError('the stack cannot pop') 

151 return self.stack.pop() 

152 

153 def peak(self) -> AbstractFolder: 

154 """Return a pointer of the top of the stack.""" 

155 if len(self.stack) > 0: 

156 picked = self.stack[-1] 

157 casalog.post(f'pick from the stack: {picked.path}', 'DEBUG2') 

158 return self.stack[len(self.stack) - 1] 

159 else: 

160 raise RuntimeError('the stack is empty') 

161 

162 def subpeak(self) -> AbstractFolder: 

163 """Return a pointer of a next of the top of the stack.""" 

164 if len(self.stack) > 1: 

165 picked = self.stack[len(self.stack) - 2] 

166 casalog.post(f'pick from sub peak of the stack: {picked.path}', 'DEBUG2') 

167 return self.stack[len(self.stack) - 2] 

168 else: 

169 raise RuntimeError('the stack has only one stuff') 

170 

171 def bottom(self) -> AbstractFolder: 

172 """Return a pointer of the bottom of the stack.""" 

173 if len(self.stack) > 0: 

174 picked = self.stack[0] 

175 casalog.post(f'pick from bottom of the stack: {picked.path}', 'DEBUG2') 

176 return self.stack[0] 

177 else: 

178 raise RuntimeError('the stack has not have enough stuff') 

179 

180 def clear(self, dry_run: bool = True) -> None: 

181 """Do erase method of all of the stack and clear the stack.""" 

182 self.stack.clear() 

183 

184 def height(self) -> int: 

185 """Return height of the stack.""" 

186 return len(self.stack) 

187 

188 

189class _CasaImageStack(AbstractFileStack): 

190 """FileStack for CasaImage.""" 

191 

192 def __init__(self, top: AbstractFolder = None) -> None: 

193 super().__init__(top=top, max_height=IMAGE_STACK_MAX_HEIGHT) 

194 

195 

196class _MeasurementSetStack(AbstractFileStack): 

197 """FileStack for MeasurementSet.""" 

198 

199 def __init__(self) -> None: 

200 super().__init__(max_height=MS_STACK_MAX_HEIGHT) 

201 self.spsmoothed = False 

202 self.kwidth = 5 

203 

204 

205@contextlib.contextmanager 

206def _stack_manager(initial_image=None): 

207 image_stack = _CasaImageStack(top=_UnerasableFolder(initial_image)) 

208 ms_stack = _MeasurementSetStack() 

209 try: 

210 yield image_stack, ms_stack 

211 finally: 

212 image_stack.clear() 

213 ms_stack.clear() 

214 

215 

216class AbstractValidatable: 

217 """Abstract class to enforce implementing validation method. 

218 

219 A class that inherits this class is that require parameter validation of it. 

220 """ 

221 

222 @abstractmethod 

223 def validate(self) -> None: 

224 """Validate the object.""" 

225 raise RuntimeError('Not implemented') 

226 

227 

228class _ImageShape(AbstractValidatable): 

229 """Shape parameters of input image. 

230 

231 These parameters are been getting in Image2MS, using in MS2Image. 

232 """ 

233 

234 def __init__(self, im_shape: np.ndarray = None, axis_dir: np.ndarray = None, 

235 axis_sp: int = None, axis_pol: int = None) -> None: 

236 self.im_shape = im_shape 

237 self.axis_dir = axis_dir 

238 self.axis_sp = axis_sp 

239 self.axis_pol = axis_pol 

240 self.dir_shape = self.im_shape[self.axis_dir] 

241 self.im_nrow = np.prod(self.dir_shape) 

242 self.im_nchan = self.im_shape[self.axis_sp] if self.axis_sp > 0 else 1 

243 self.im_npol = self.im_shape[self.axis_pol] if self.axis_pol > 0 else 1 

244 

245 def validate(self) -> None: 

246 if not len(self.axis_dir): 

247 raise ValueError(f'invalid value: axis_dir {self.axis_dir}') 

248 

249 if not (self.axis_sp in [-1, 2, 3] and self.axis_pol in [-1, 2, 3] 

250 and self.axis_sp != self.axis_pol): 

251 raise ValueError(f'invalid value: sp:{self.axis_sp} or pol:{self.axis_pol}') 

252 

253 # if im_nchan is too few, say, <10, sdbaseline should abort 

254 if self.im_nchan < 10: 

255 raise ValueError(f'nchan {self.im_nchan} is too few to perform baseline subtraction') 

256 

257 if len(self.im_shape) < 3: 

258 raise ValueError(f'invalid value: im_shape {self.im_shape}') 

259 

260 if len(self.dir_shape) < 2: 

261 raise ValueError(f'invalid value: dir_shape {self.dir_shape}') 

262 

263 

264def _get_image_shape(imagepath: str) -> _ImageShape: 

265 if not os.path.exists(imagepath): 

266 raise ValueError(f"path '{imagepath}' is not found") 

267 

268 shape = None 

269 with tool_manager(imagepath, image) as ia: 

270 try: 

271 cs = ia.coordsys() 

272 shape = _ImageShape( 

273 ia.shape(), 

274 cs.findcoordinate('direction')['world'], 

275 __get_axis_position(cs.findcoordinate('spectral')['world']), # 3 or 2 or -1 

276 __get_axis_position(cs.findcoordinate('stokes')['world']) # 2 or 3 or -1 

277 ) 

278 finally: 

279 cs.done() 

280 

281 if shape.im_shape.shape[0] < 3: 

282 raise ValueError(f"image '{imagepath}' is invalid") 

283 

284 shape.validate() 

285 casalog.post(f'image shape is {shape.im_shape}, direciton {shape.dir_shape} ' 

286 f'({shape.im_nrow} pixels), npol {shape.im_npol}, nchan {shape.im_nchan}', 

287 'DEBUG2') 

288 

289 return shape 

290 

291 

292def __get_axis_position(val: array = None) -> int: 

293 if val is not None and len(val) > 0: 

294 return val[0].item() 

295 return -1 

296 

297 

298@sdtask_decorator 

299def imbaseline(imagename=None, linefile=None, output_cont=None, bloutput=None, maskmode=None, 

300 chans=None, thresh=None, avg_limit=None, minwidth=None, edge=None, blfunc=None, 

301 order=None, npiece=None, applyfft=None, fftthresh=None, addwn=None, rejwn=None, 

302 blparam=None, clipniter=None, clipthresh=None, dirkernel=None, major=None, 

303 minor=None, pa=None, kimage=None, scale=None, spkernel=None, kwidth=None) -> None: 

304 """Execute imbaseline. 

305 

306 All specifications of arguments are defined in: 

307 https://open-jira.nrao.edu/browse/CAS-13520 

308 

309 The task executes several processes as follows: 

310 (1) do direction plane smoothing of input casa image (execute imsmooth) 

311 (2) convert casa image into MeasurementSet (a pixel of image corresponds to a line of MS) 

312 (3) do spectral smoothing of MS (execute sdsmooth) 

313 (4) do baselining (execute sdbaseline) 

314 (5) convert MS into casa image, and subtract results 

315 """ 

316 _validate_imagename(imagename) 

317 linefile = _prepare_linefile(linefile, imagename) 

318 

319 with _stack_manager(imagename) as (image_stack, ms_stack): 

320 try: 

321 input_image_shape = _get_image_shape(image_stack.peak().path) 

322 

323 # do direction plane smoothing 

324 _ImsmoothMethods.execute(dirkernel, major, minor, pa, kimage, scale, image_stack) 

325 

326 # convert casaimage into MeasurementSet 

327 _Image2MSMethods.execute(DATACOLUMN, input_image_shape, image_stack, ms_stack) 

328 

329 # do spectral smoothing 

330 _SdsmoothMethods.execute(DATACOLUMN, spkernel, kwidth, image_stack, ms_stack, 

331 input_image_shape) 

332 

333 # do baselining 

334 _SdbaselineMethods.execute(DATACOLUMN, bloutput, maskmode, chans, thresh, avg_limit, 

335 minwidth, edge, blfunc, order, npiece, applyfft, fftthresh, 

336 addwn, rejwn, blparam, clipniter, clipthresh, image_stack, 

337 ms_stack, input_image_shape) 

338 

339 # convert MeasurementSet into image and subtract results 

340 _ImageSubtractionMethods.execute(linefile, image_stack) 

341 

342 if output_cont: 

343 _ImageSubtractionMethods.get_continuum_image(image_stack) 

344 finally: 

345 _do_post_processing(linefile) 

346 

347 

348def _validate_imagename(imagename: str = None) -> None: 

349 if not os.path.exists(imagename): 

350 raise ValueError(f'Error: file {imagename} is not found.', 'SEVERE') 

351 

352 

353def _prepare_linefile(linefile: str = None, imagename: str = None) -> str: 

354 if linefile == '' or linefile is None: 

355 linefile = os.path.basename(imagename).rstrip('/') + '_bs' 

356 if not OVERWRITE and os.path.exists(linefile): 

357 raise ValueError(f'Error: file {linefile} already exists, please delete before continuing.', 

358 'SEVERE') 

359 return linefile 

360 

361 

362def _generate_temporary_filename(prefix: str = '', ext: str = '') -> str: 

363 if prefix and prefix[-1] != '-': 

364 prefix = prefix + '-' 

365 if ext != '': 

366 ext = '.' + ext 

367 while True: 

368 filename = prefix + str(uuid.uuid4()) + ext 

369 if not os.path.exists(filename): 

370 return filename 

371 

372 

373def _copy_image_file(infile: str = None, outfile: str = None) -> None: 

374 if not os.path.exists(infile): 

375 raise Exception(f'Image files not found, infile: {infile}') 

376 

377 ia = image() 

378 try: 

379 ok = ia.fromimage(infile=infile, outfile=outfile) 

380 if not ok: 

381 raise Exception(f'Some error occured, infile: {infile}, outfile: {outfile}') 

382 finally: 

383 ia.done() 

384 

385 

386def _do_post_processing(outfile) -> None: 

387 """Execute some post-processes of imbaseline.""" 

388 _eraseable_folder_register.clear(dry_run=do_not_erase_temporary_files) 

389 __write_image_history(outfile) 

390 

391 

392def __write_image_history(outfile) -> None: 

393 with tool_manager(outfile, image) as outia: 

394 try: 

395 param_names = imbaseline.__code__.co_varnames[:imbaseline.__code__.co_argcount] 

396 vars = locals() 

397 param_vals = [vars[p] for p in param_names] 

398 write_image_history(outia, sys._getframe().f_code.co_name, param_names, 

399 param_vals, casalog) 

400 except Exception as instance: 

401 casalog.post(f'*** Error "{instance}" updating HISTORY', 'WARN') 

402 

403 

404class _ImageSubtractionMethods(): 

405 

406 @staticmethod 

407 def execute(linefile: str = None, image_stack: AbstractFileStack = None) -> None: 

408 """Execute image subtraction. 

409 

410 The output image is computed as follows: 

411 - in case any smoothing (along direction and/or frequency) is executed 

412 output_image = input_image - (smoothed_image - smoothed_and_subtracted_image) 

413 - in case no smoothing is executed 

414 output_image = subtracted_image 

415 """ 

416 if image_stack.height() <= 2: # any smoothing were not executed 

417 output_image = image_stack.pop().path 

418 _eraseable_folder_register.pop(output_image) 

419 os.rename(output_image, linefile) 

420 image_stack.push(_UnerasableFolder(linefile)) 

421 else: 

422 smoothed_image = image_stack.subpeak().path 

423 subtracted_image = image_stack.peak().path 

424 base_image = image_stack.bottom().path 

425 _copy_image_file(base_image, linefile) 

426 _ImageSubtractionMethods.__subtract_image(smoothed_image, subtracted_image) 

427 _ImageSubtractionMethods.__subtract_image(linefile, smoothed_image) 

428 image_stack.push(_UnerasableFolder(linefile)) 

429 

430 @staticmethod 

431 def get_continuum_image(image_stack: AbstractFileStack = None) -> None: 

432 """Compute 'input_image - output_image'.""" 

433 base_image = image_stack.bottom().path 

434 output_image = os.path.basename(base_image) + '.cont' 

435 _copy_image_file(base_image, output_image) 

436 

437 linefile = image_stack.peak().path 

438 _ImageSubtractionMethods.__subtract_image(output_image, linefile) 

439 

440 @staticmethod 

441 def __subtract_image(operand_a: str = None, operand_b: str = None) -> None: 

442 """Subtract image chunk.""" 

443 image_array = None 

444 with tool_manager(operand_b, image) as ia: 

445 image_array = ia.getchunk() 

446 

447 with tool_manager(operand_a, image) as ia: 

448 ia.putchunk(pixels=ia.getchunk() - image_array, locking=True) 

449 

450 

451class _ImsmoothMethods(): 

452 """Methoods for Imsmooth execution.""" 

453 

454 @staticmethod 

455 def execute(dirkernel: str = None, major: str = None, minor: str = None, pa: str = None, 

456 kimage: str = None, scale: float = None, stack: AbstractFileStack = None) -> None: 

457 """Call casatasks.imsmooth task if dirkernel is specified.""" 

458 if not _ImsmoothMethods.require(dirkernel): 

459 casalog.post('omit image smoothing', 'INFO') 

460 return 

461 

462 casalog.post('execute image smoothing', 'INFO') 

463 infile = stack.peak().path 

464 outfile = _generate_temporary_filename('dirsmooth', 'im') 

465 imsmooth(**_ImsmoothParams(infile, outfile, dirkernel, major, minor, pa, kimage, scale)()) 

466 stack.push(_EraseableFolder(outfile)) 

467 

468 @staticmethod 

469 def require(dirkernel: str = 'none') -> None: 

470 if not dirkernel: 

471 dirkernel = 'none' 

472 if dirkernel == 'none': 

473 return False 

474 elif dirkernel in ['image', 'boxcar', 'gaussian']: 

475 return True 

476 else: 

477 raise ValueError(f'Unsupported direction smoothing kernel, {dirkernel}', 'SEVERE') 

478 

479 

480class _SdsmoothMethods(): 

481 """Methoods for Sdsmooth execution.""" 

482 

483 @staticmethod 

484 def execute(datacolumn: str = None, spkernel: str = None, kwidth: int = None, 

485 image_stack: AbstractFileStack = None, ms_stack: AbstractFileStack = None, 

486 image_shape: _ImageShape = None) -> None: 

487 """Call casatasks.sdsmooth task if spkernel is specified.""" 

488 if not _SdsmoothMethods.require(spkernel): 

489 casalog.post('omit spectral smoothing', 'INFO') 

490 return 

491 

492 casalog.post('execute spectral smoothing', 'INFO') 

493 

494 input_ms = ms_stack.peak().path 

495 output_ms = _generate_temporary_filename('spsmooth', 'ms') 

496 base_image = image_stack.bottom().path 

497 params = _SdsmoothParams(input_ms, output_ms, datacolumn.lower(), spkernel, kwidth) 

498 sdsmooth(**params()) 

499 ms_stack.push(_EraseableFolder(output_ms)) 

500 output_image = _MS2ImageMethods.convert(base_image, output_ms, image_shape, datacolumn) 

501 image_stack.push(_EraseableFolder(output_image)) 

502 ms_stack.spsmoothed = True 

503 ms_stack.kwidth = params.kwidth 

504 

505 @staticmethod 

506 def require(spkernel: str = 'none') -> None: 

507 if not spkernel: 

508 spkernel = 'none' 

509 if spkernel == 'none': 

510 return False 

511 elif spkernel in ['boxcar', 'gaussian']: 

512 return True 

513 else: 

514 raise ValueError(f'Unsupported spectral smoothing kernel, {spkernel}', 'SEVERE') 

515 

516 

517class _SdbaselineMethods(): 

518 """Methoods for Sdbaseline execution.""" 

519 

520 @staticmethod 

521 def execute(datacolumn: str = None, bloutput: str = None, maskmode: str = None, 

522 chans: str = None, thresh: float = None, avg_limit: int = None, 

523 minwidth: int = None, edge: List[int] = None, 

524 blfunc: str = None, order: int = None, npiece: int = None, applyfft: bool = None, 

525 fftthresh: float = None, addwn: List[int] = None, rejwn: List[int] = None, 

526 blparam: str = None, clipniter: int = None, clipthresh: float = None, 

527 image_stack: AbstractFileStack = None, ms_stack: AbstractFileStack = None, 

528 image_shape: _ImageShape = None) -> None: 

529 """Call casatasks.sdbaseline task.""" 

530 casalog.post('execute spectral baselining', 'INFO') 

531 input_ms = ms_stack.peak().path 

532 output_ms = _generate_temporary_filename('baseline', 'ms') 

533 base_image = image_stack.bottom().path 

534 sdbaseline(**_SdbaselineParams(input_ms, output_ms, datacolumn.lower(), bloutput, maskmode, 

535 chans, thresh, avg_limit, minwidth, edge, blfunc, order, 

536 npiece, applyfft, fftthresh, addwn, rejwn, blparam, 

537 clipniter, clipthresh, ms_stack.spsmoothed, image_shape, 

538 ms_stack.kwidth)()) 

539 ms_stack.push(_EraseableFolder(output_ms)) 

540 output_image = _MS2ImageMethods.convert(base_image, output_ms, image_shape, datacolumn) 

541 image_stack.push(_EraseableFolder(output_image)) 

542 blparam_name = input_ms + '_blparam.' + _SdbaselineParams.FIXED_PARAM['blformat'] 

543 if os.path.exists(blparam_name): 

544 _SdbaselineMethods.__rename_blparam_filename(blparam_name, base_image) 

545 

546 @staticmethod 

547 def __rename_blparam_filename(filename: str = None, basename: str = None) -> str: 

548 if not os.path.exists(filename): 

549 return None 

550 newname = os.path.basename(basename) + '.ms_blparam.' + \ 

551 _SdbaselineParams.FIXED_PARAM['blformat'] 

552 if os.path.exists(newname): 

553 return filename 

554 try: 

555 os.rename(filename, newname) 

556 except Exception: 

557 casalog.post(f'rename failure:from {filename} to {newname}', 'SEVERE') 

558 return filename 

559 return newname 

560 

561 

562class _ImsmoothParams(AbstractValidatable): 

563 """Parameter manipulation class for execution of casatasks.imsmooth.""" 

564 

565 FIXED_PARAM = dict( 

566 targetres=False, 

567 mask='', 

568 beam={}, 

569 region='', 

570 box='', 

571 chans='', 

572 stokes='', 

573 stretch=False, 

574 overwrite=True 

575 ) 

576 

577 def __init__(self, infile: str = None, outfile: str = None, dirkernel: str = 'none', 

578 major: str = '', minor: str = '', pa: str = '', kimage: str = '', 

579 scale: int = -1.0) -> None: 

580 self.infile = infile 

581 self.outfile = outfile 

582 

583 # dirkernel options: none(default)/gaussian/boxcar/image 

584 self.kernel = dirkernel if dirkernel is not None else 'none' 

585 

586 # subparameter for dirkernel = gaussian/boxcar 

587 self.major = major if major is not None else '' 

588 self.minor = minor if minor is not None else '' 

589 self.pa = pa if pa is not None else '' 

590 

591 # subparameter for dirkernel = image 

592 self.kimage = kimage if kimage is not None else '' 

593 self.scale = scale if scale is not None else -1.0 

594 

595 self.validate() 

596 

597 def validate(self) -> None: 

598 self.__validate_dirkernel() 

599 

600 def __validate_dirkernel(self) -> None: 

601 if self.kernel == 'image': 

602 self.major = self.minor = self.pa = '' 

603 if self.kimage != '' and not os.path.exists(self.kimage): 

604 raise ValueError(f'Error: file {self.kimage} is not found.', 'SEVERE') 

605 elif self.kernel == 'gaussian' or self.kernel == 'boxcar': 

606 self.kimage = '' 

607 self.scale = -1.0 

608 elif self.kernel != 'none': 

609 raise ValueError(f'Unsupported maskmode, {self.kernel}', 'SEVERE') 

610 

611 def __call__(self) -> Union[List[Any], Dict[str, str]]: 

612 """Convert the class into arguments of imsmooth().""" 

613 retval = dict(self.FIXED_PARAM, imagename=self.infile, kernel=self.kernel, major=self.major, 

614 minor=self.minor, pa=self.pa, kimage=self.kimage, scale=self.scale, 

615 outfile=self.outfile) 

616 if dump_tasks: 

617 print(_dump_tasks('imsmooth', retval)) 

618 return retval 

619 

620 

621class _SdsmoothParams(AbstractValidatable): 

622 """Parameter manipulation class for execution of casatasks.sdsmooth.""" 

623 

624 FIXED_PARAM = dict( 

625 spw='', 

626 field='', 

627 antenna='', 

628 timerange='', 

629 scan='', 

630 pol='', 

631 intent='', 

632 reindex=True, 

633 overwrite=True 

634 ) 

635 

636 def __init__(self, infile: str = None, outfile: str = None, datacolumn: str = None, 

637 spkernel: str = 'none', kwidth: int = 5) -> None: 

638 self.infile = infile 

639 self.outfile = outfile 

640 self.datacolumn = datacolumn 

641 self.kernel = spkernel if spkernel is not None else 'none' # none(default)/gaussian/boxcar 

642 self.kwidth = kwidth if kwidth is not None else 5 # gaussian/boxcar 

643 self.validate() 

644 

645 def validate(self) -> None: 

646 self.__validate_spkernel() 

647 

648 def __validate_spkernel(self) -> None: 

649 if self.kernel == 'none': 

650 self.kwidth = 5 

651 elif not (self.kernel == 'gaussian' or self.kernel == 'boxcar'): 

652 raise ValueError(f'Unsupported maskmode, {self.kernel}', 'SEVERE') 

653 

654 def __call__(self) -> Dict[str, Any]: 

655 """Convert the class into arguments of sdsmooth().""" 

656 retval = dict(self.FIXED_PARAM, infile=self.infile, datacolumn=self.datacolumn, 

657 kernel=self.kernel, kwidth=self.kwidth, outfile=self.outfile) 

658 if dump_tasks: 

659 print(_dump_tasks('sdsmooth', retval)) 

660 return retval 

661 

662 

663class _SdbaselineParams(AbstractValidatable): 

664 """Parameter manipulation class for execution of casatasks.sdbaseline.""" 

665 

666 FIXED_PARAM = dict( 

667 antenna='', 

668 field='', 

669 timerange='', 

670 scan='', 

671 pol='', 

672 intent='', 

673 reindex=True, 

674 blmode='fit', 

675 dosubtract=True, 

676 blformat='csv', 

677 bltable='', 

678 updateweight=False, 

679 sigmavalue='stddev', 

680 showprogress=False, 

681 minnrow=1000, 

682 fftmethod='fft', 

683 verbose=False, 

684 overwrite=True 

685 ) 

686 

687 def __init__(self, infile: str = None, outfile: str = None, datacolumn: str = None, 

688 bloutput: str = '', maskmode: str = 'list', chans: str = '', thresh: float = 5.0, 

689 avg_limit: int = 4, minwidth: int = 4, edge: List[int] = [0, 0], 

690 blfunc: str = 'poly', order: int = 5, npiece: int = 3, applyfft: bool = True, 

691 fftthresh: float = 3.0, addwn: List = [0], 

692 rejwn: List = [], blparam: str = '', clipniter: int = 0, clipthresh: float = 3.0, 

693 spsmoothed: bool = False, image_shape: _ImageShape = None, 

694 kwidth: int = None) -> None: 

695 self.infile = infile 

696 self.outfile = outfile 

697 self.datacolumn = datacolumn 

698 self.bloutput = bloutput if bloutput is not None else '' 

699 

700 # maskmode: list(default)/auto 

701 self.maskmode = maskmode.lower() if maskmode is not None else 'list' 

702 

703 # subparam for maskmode = list 

704 self.spw = self.__chans2spw(chans, self.maskmode) 

705 

706 # subparam for maskmode = auto 

707 self.thresh = thresh if thresh is not None else 5.0 

708 self.avg_limit = avg_limit if avg_limit is not None else 4 

709 self.minwidth = minwidth if minwidth is not None else 4 

710 self.edge = edge if edge is not None else [0, 0] 

711 

712 # poly(default)/chebyshev/cspline/sinusoid/variable 

713 self.blfunc = blfunc.lower() if blfunc is not None else 'poly' 

714 

715 # subparam for blfunc = poly/chebyshev 

716 self.order = order if order is not None else 5 

717 

718 # subparam for blfunc = cspline 

719 self.npiece = npiece if npiece is not None else 3 

720 

721 # subparam for blfunc = sinusoid 

722 self.applyfft = applyfft if applyfft is not None else True 

723 self.fftthresh = fftthresh if fftthresh is not None else 3.0 

724 self.addwn = addwn if addwn is not None else [0] 

725 self.rejwn = rejwn if rejwn is not None else [] 

726 

727 # subparam for blfunc = variable 

728 self.blparam = blparam if blparam is not None else '' 

729 self.clipniter = clipniter if clipniter is not None else 0 

730 self.clipthresh = clipthresh if clipthresh is not None else 3.0 

731 

732 if spsmoothed: 

733 spw = '0' 

734 left_edge = kwidth // 2 

735 right_edge = image_shape.im_nchan - kwidth // 2 

736 if self.spw: 

737 coverage = set(list(range(left_edge, right_edge))) 

738 sets = dict() 

739 for i, s in spwchan_to_sets(self.infile, self.spw).items(): 

740 sets[i] = s & coverage 

741 spw = sets_to_spwchan(sets) 

742 else: 

743 spw = f'0:{left_edge}~{right_edge-1}' 

744 self.spw = spw 

745 if not self.spw: 

746 self.spw = '0' 

747 

748 def __chans2spw(self, chans: str, maskmode) -> str: 

749 if not chans or maskmode != 'list': 

750 return '' 

751 return chans 

752 

753 def validate(self) -> None: 

754 self.__validate_maskmode() 

755 self.__validate_blfunc() 

756 

757 def __validate_maskmode(self) -> None: 

758 if not (self.maskmode == 'list' or self.maskmode == 'auto'): 

759 raise ValueError(f'Unsupported maskmode, {self.maskmode}', 'SEVERE') 

760 

761 def __validate_blfunc(self) -> None: 

762 def is_valid_blfunc(self) -> None: 

763 return self.blfunc == 'poly' or self.blfunc == 'chebyshev' or self.blfunc == 'cspline' \ 

764 or self.blfunc == 'sinusoid' or self.blfunc == 'variable' 

765 

766 if not is_valid_blfunc(self): 

767 raise ValueError(f'Unsupported blfunc, {self.blfunc}', 'SEVERE') 

768 

769 if self.blfunc == 'variable' and not os.path.exists(self.blparam): 

770 raise ValueError(f'input file {self.blparam} does not exists', 'SEVERE') 

771 

772 def __call__(self) -> Dict[str, Any]: 

773 """Convert the class into arguments of sdbaseline().""" 

774 retval = dict(self.FIXED_PARAM, infile=self.infile, datacolumn=self.datacolumn, 

775 maskmode=self.maskmode, thresh=self.thresh, avg_limit=self.avg_limit, 

776 minwidth=self.minwidth, edge=self.edge, bloutput=self.bloutput, 

777 blfunc=self.blfunc, order=self.order, npiece=self.npiece, 

778 applyfft=self.applyfft, fftthresh=self.fftthresh, addwn=self.addwn, 

779 rejwn=self.rejwn, clipthresh=self.clipthresh, clipniter=self.clipniter, 

780 blparam=self.blparam, outfile=self.outfile, spw=self.spw) 

781 if dump_tasks: 

782 print(_dump_tasks('sdbaseline', retval)) 

783 

784 return retval 

785 

786 

787class _Image2MSParams(AbstractValidatable): 

788 """Parameter manipulation class for executing image2ms().""" 

789 

790 def __init__(self, infile: str = None, outfile: str = None, datacolumn: str = 'DATA', 

791 input_image_shape: _ImageShape = None) -> None: 

792 self.infile = infile 

793 self.outfile = outfile 

794 self.datacolumn = datacolumn 

795 self.im_shape = input_image_shape.im_shape 

796 self.axis_dir = input_image_shape.axis_dir 

797 self.axis_sp = input_image_shape.axis_sp 

798 self.axis_pol = input_image_shape.axis_pol 

799 self.dir_shape = input_image_shape.dir_shape 

800 self.im_nrow = input_image_shape.im_nrow 

801 self.im_nchan = input_image_shape.im_nchan 

802 self.im_npol = input_image_shape.im_npol 

803 self.validate() 

804 

805 def validate(self) -> None: 

806 self.__validate_outfile() 

807 

808 def __validate_outfile(self) -> None: 

809 if os.path.exists(self.outfile): 

810 raise ValueError(f'Folder exists: {self.outfile}') 

811 

812 

813class _Image2MSMethods(): 

814 """Methods for converting image to MeasurementSet.""" 

815 

816 @staticmethod 

817 def execute(datacolumn: str = None, input_image_shape: _ImageShape = None, 

818 image_stack: AbstractFileStack = None, 

819 ms_stack: AbstractFileStack = None) -> None: 

820 """Convert a casaimage to a MeasurementSet.""" 

821 casalog.post('convert casaimage to MeasurementSet', 'INFO') 

822 infile = image_stack.peak().path 

823 outfile = _generate_temporary_filename('img2ms', 'ms') 

824 _Image2MSMethods.__image2ms(_Image2MSParams(infile, outfile, datacolumn, input_image_shape)) 

825 ms_stack.push(_EraseableFolder(outfile)) 

826 

827 @staticmethod 

828 def __image2ms(params: _Image2MSParams = None) -> None: 

829 """Convert CasaImage into MeasurementSet.""" 

830 _Image2MSMethods.__create_empty_ms(params) 

831 _Image2MSMethods.__put_parametes_from_image_to_ms(params) 

832 

833 @staticmethod 

834 def __create_empty_ms(params: _Image2MSParams = None) -> None: 

835 _Image2MSMethods.__cleanup_ms_path(params) 

836 _Image2MSMethods.__create_maintable(params) 

837 _Image2MSMethods.__create_antenna_table(params) 

838 _Image2MSMethods.__create_data_description_table(params) 

839 _Image2MSMethods.__create_feed_table(params) 

840 _Image2MSMethods.__create_field_table(params) 

841 _Image2MSMethods.__create_flag_cmd_table(params) 

842 _Image2MSMethods.__create_history_table(params) 

843 _Image2MSMethods.__create_observation_table(params) 

844 _Image2MSMethods.__create_pointing_table(params) 

845 _Image2MSMethods.__create_polarization_table(params) 

846 _Image2MSMethods.__create_processor_table(params) 

847 _Image2MSMethods.__create_source_table(params) 

848 _Image2MSMethods.__create_special_window_table(params) 

849 _Image2MSMethods.__create_state_table(params) 

850 

851 @staticmethod 

852 def __generate_time_list(nrow_req: int) -> np.ndarray: 

853 mjd_sec = qa.convert(qa.quantity('1995-04-13T09:19:00'), 's')['value'] # dummy timestamp 

854 interval = 30.0 

855 return mjd_sec + np.arange(nrow_req) * interval 

856 

857 @staticmethod 

858 def __create_maintable(params: _Image2MSParams = None) -> None: 

859 tb = table() 

860 try: 

861 tb.create(params.outfile, _EmptyMSBaseInformation.ms_desc, 

862 dminfo=_EmptyMSBaseInformation.ms_dminfo) 

863 tb.putkeyword(keyword='MS_VERSION', value=2) 

864 nrow = tb.nrows() 

865 nrow_req = params.im_nrow * params.im_npol 

866 nrow = tb.nrows() 

867 if nrow != nrow_req: 

868 tb.addrows(nrow_req) 

869 ddid = tb.getcol('DATA_DESC_ID') 

870 ddid[:] = 0 

871 tb.putcol('DATA_DESC_ID', ddid) 

872 dummy = np.zeros(nrow_req, dtype=int) 

873 tb.putcol('ANTENNA1', dummy) 

874 tb.putcol('ANTENNA2', dummy) 

875 tb.putcol('STATE_ID', dummy) 

876 time_list = _Image2MSMethods.__generate_time_list(nrow_req) 

877 tb.putcol('TIME', time_list) 

878 casalog.post(f'number of rows {nrow}, number of image pixels {params.im_nrow}, ' 

879 f'number of pols {params.im_npol}, ' 

880 f'required rows {nrow_req}', 'DEBUG2') 

881 finally: 

882 tb.close() 

883 

884 @staticmethod 

885 def __create_antenna_table(params: _Image2MSParams = None) -> None: 

886 _Image2MSMethods.__create_subtable(params.outfile, 

887 'ANTENNA', 

888 _EmptyMSBaseInformation.antenna_desc, 

889 _EmptyMSBaseInformation.antenna_dminfo) 

890 with table_manager(os.path.join(params.outfile, 'ANTENNA'), nomodify=False) as tb: 

891 tb.addrows(1) 

892 

893 @staticmethod 

894 def __create_data_description_table(params: _Image2MSParams = None) -> None: 

895 _Image2MSMethods.__create_subtable(params.outfile, 

896 'DATA_DESCRIPTION', 

897 _EmptyMSBaseInformation.data_description_desc, 

898 _EmptyMSBaseInformation.data_description_dminfo) 

899 with table_manager(os.path.join(params.outfile, 'DATA_DESCRIPTION'), nomodify=False) as tb: 

900 tb.addrows(1) 

901 tb.putcell('SPECTRAL_WINDOW_ID', 0, 0) 

902 tb.putcell('POLARIZATION_ID', 0, 0) 

903 

904 @staticmethod 

905 def __create_feed_table(params: _Image2MSParams = None) -> None: 

906 _Image2MSMethods.__create_subtable(params.outfile, 

907 'FEED', 

908 _EmptyMSBaseInformation.feed_desc, 

909 _EmptyMSBaseInformation.feed_dminfo) 

910 with table_manager(os.path.join(params.outfile, 'FEED'), nomodify=False) as tb: 

911 tb.addrows(1) 

912 

913 @staticmethod 

914 def __create_field_table(params: _Image2MSParams = None) -> None: 

915 _Image2MSMethods.__create_subtable(params.outfile, 

916 'FIELD', 

917 _EmptyMSBaseInformation.field_desc, 

918 _EmptyMSBaseInformation.field_dminfo) 

919 with table_manager(os.path.join(params.outfile, 'FIELD'), nomodify=False) as tb: 

920 tb.addrows(1) 

921 tb.putcell('DELAY_DIR', 0, np.zeros((2, 1))) 

922 tb.putcell('PHASE_DIR', 0, np.zeros((2, 1))) 

923 tb.putcell('REFERENCE_DIR', 0, np.zeros((2, 1))) 

924 

925 @staticmethod 

926 def __create_flag_cmd_table(params: _Image2MSParams = None) -> None: 

927 _Image2MSMethods.__create_subtable(params.outfile, 

928 'FLAG_CMD', 

929 _EmptyMSBaseInformation.flag_cmd_desc, 

930 _EmptyMSBaseInformation.flag_cmd_dminfo) 

931 

932 @staticmethod 

933 def __create_history_table(params: _Image2MSParams = None) -> None: 

934 _Image2MSMethods.__create_subtable(params.outfile, 

935 'HISTORY', 

936 _EmptyMSBaseInformation.history_desc, 

937 _EmptyMSBaseInformation.history_dminfo) 

938 

939 @staticmethod 

940 def __create_observation_table(params: _Image2MSParams = None) -> None: 

941 _Image2MSMethods.__create_subtable(params.outfile, 

942 'OBSERVATION', 

943 _EmptyMSBaseInformation.observation_desc, 

944 _EmptyMSBaseInformation.observation_dminfo) 

945 with table_manager(os.path.join(params.outfile, 'OBSERVATION'), nomodify=False) as tb: 

946 tb.addrows(1) 

947 

948 @staticmethod 

949 def __create_pointing_table(params: _Image2MSParams = None) -> None: 

950 _Image2MSMethods.__create_subtable(params.outfile, 

951 'POINTING', 

952 _EmptyMSBaseInformation.pointing_desc, 

953 _EmptyMSBaseInformation.pointing_dminfo) 

954 

955 @staticmethod 

956 def __create_polarization_table(params: _Image2MSParams = None) -> None: 

957 _Image2MSMethods.__create_subtable(params.outfile, 

958 'POLARIZATION', 

959 _EmptyMSBaseInformation.polarization_desc, 

960 _EmptyMSBaseInformation.polarization_dminfo) 

961 with table_manager(os.path.join(params.outfile, 'POLARIZATION'), nomodify=False) as tb: 

962 corr_type = np.ones(1, dtype=int) 

963 corr_product = np.ones(2, dtype=int).reshape((2, 1)) 

964 if tb.nrows() == 0: 

965 tb.addrows(1) 

966 tb.putcell('NUM_CORR', 0, 1) 

967 tb.putcell('CORR_TYPE', 0, corr_type) 

968 tb.putcell('CORR_PRODUCT', 0, corr_product) 

969 

970 @staticmethod 

971 def __create_processor_table(params: _Image2MSParams = None) -> None: 

972 _Image2MSMethods.__create_subtable(params.outfile, 

973 'PROCESSOR', 

974 _EmptyMSBaseInformation.processor_desc, 

975 _EmptyMSBaseInformation.processor_dminfo) 

976 

977 @staticmethod 

978 def __create_source_table(params: _Image2MSParams = None) -> None: 

979 _Image2MSMethods.__create_subtable(params.outfile, 

980 'SOURCE', 

981 _EmptyMSBaseInformation.source_desc, 

982 _EmptyMSBaseInformation.source_dminfo) 

983 

984 @staticmethod 

985 def __create_special_window_table(params: _Image2MSParams = None) -> None: 

986 _Image2MSMethods.__create_subtable(params.outfile, 

987 'SPECTRAL_WINDOW', 

988 _EmptyMSBaseInformation.special_window_desc, 

989 _EmptyMSBaseInformation.special_window_dminfo) 

990 with table_manager(os.path.join(params.outfile, 'SPECTRAL_WINDOW'), nomodify=False) as tb: 

991 cw = np.ones(params.im_nchan, dtype=float) * 1e6 

992 cf = 1e9 + np.arange(params.im_nchan, dtype=float) * 1e6 

993 

994 if tb.nrows() == 0: 

995 tb.addrows(1) 

996 tb.putcell('NUM_CHAN', 0, params.im_nchan) 

997 tb.putcell('CHAN_FREQ', 0, cf) 

998 tb.putcell('CHAN_WIDTH', 0, cw) 

999 tb.putcell('RESOLUTION', 0, cw) 

1000 tb.putcell('EFFECTIVE_BW', 0, cw) 

1001 tb.putcell('TOTAL_BANDWIDTH', 0, cw.sum()) 

1002 

1003 @staticmethod 

1004 def __create_state_table(params: _Image2MSParams = None) -> None: 

1005 _Image2MSMethods.__create_subtable(params.outfile, 

1006 'STATE', 

1007 _EmptyMSBaseInformation.state_desc, 

1008 _EmptyMSBaseInformation.state_dminfo) 

1009 with table_manager(os.path.join(params.outfile, 'STATE'), nomodify=False) as tb: 

1010 if tb.nrows() == 0: 

1011 tb.addrows(1) 

1012 tb.putcell('OBS_MODE', 0, 'OBSERVE_TARGET#ON_SOURCE_IMAGE_DOMAIN') 

1013 

1014 @staticmethod 

1015 def __cleanup_ms_path(params, overwrite: bool = True) -> None: 

1016 exists = os.path.exists(params.outfile) 

1017 if overwrite and exists: 

1018 shutil.rmtree(params.outfile) 

1019 return exists 

1020 

1021 @staticmethod 

1022 def __create_subtable(outfile: str = None, subtable: str = None, 

1023 desc: str = None, dminfo: str = None) -> None: 

1024 tb = table() 

1025 try: 

1026 tb.create(f'{outfile}/{subtable}', desc, dminfo=dminfo) 

1027 finally: 

1028 tb.close() 

1029 with table_manager(outfile, nomodify=False) as tb: 

1030 tb.putkeyword(subtable, f'Table: {outfile}/{subtable}') 

1031 

1032 @staticmethod 

1033 def __put_parametes_from_image_to_ms(params: _Image2MSParams = None) -> None: 

1034 _Image2MSMethods.__put_image_parameters_into_ms( 

1035 params, *_Image2MSMethods.__get_image_parameters(params)) 

1036 

1037 @staticmethod 

1038 def __get_image_parameters(params: _Image2MSParams = None) -> Tuple[np.array, int]: 

1039 # get image array and mask from the image 

1040 with tool_manager(params.infile, image) as ia: 

1041 arr = ia.getchunk() 

1042 msk = ia.getchunk(getmask=True) 

1043 

1044 # put image array slices to MS DATA column 

1045 # axis indices for spatial, spectral and polarization axes 

1046 xax, yax = params.axis_dir 

1047 spax = params.axis_sp 

1048 if params.axis_pol > 0: 

1049 polax = params.axis_pol 

1050 else: 

1051 arr = np.expand_dims(arr, axis=3) 

1052 msk = np.expand_dims(msk, axis=3) 

1053 polax = 3 

1054 casalog.post(f'axis index: {xax} {yax} {polax} {spax}', 'DEBUG2') 

1055 return arr, msk, xax, yax, spax, polax 

1056 

1057 @staticmethod 

1058 def __put_image_parameters_into_ms(params: _Image2MSParams, image_array: np.array, 

1059 mask_array: np.array, axis_x: int, 

1060 axis_y: int, axis_sp: int, axis_pol: int) -> None: 

1061 # which data column to use 

1062 with table_manager(params.outfile, nomodify=False) as tb: 

1063 # also set FLAG, SIGMA, WEIGHT, and UVW 

1064 index_list = [0, 0, 0, 0] 

1065 index_list[axis_sp] = np.arange(params.im_nchan) 

1066 nx, ny = params.dir_shape 

1067 irow = 0 

1068 wgt = np.ones(1, dtype=float) 

1069 uvw = np.zeros(3, dtype=float) 

1070 for ix in range(nx): 

1071 index_list[axis_x] = ix 

1072 for iy in range(ny): 

1073 index_list[axis_y] = iy 

1074 for ip in range(params.im_npol): 

1075 index_list[axis_pol] = ip 

1076 slice = tuple(index_list) 

1077 cell = image_array[slice] 

1078 mask = np.logical_not(mask_array[slice]) 

1079 casalog.post(f'slice={slice}, cell={cell}', 'DEBUG2') 

1080 tb.putcell(params.datacolumn, irow, np.expand_dims(cell, axis=0)) 

1081 tb.putcell('FLAG', irow, np.expand_dims(mask, axis=0)) 

1082 tb.putcell('SIGMA', irow, wgt) 

1083 tb.putcell('WEIGHT', irow, wgt) 

1084 tb.putcell('UVW', irow, uvw) 

1085 irow += 1 

1086 

1087 

1088class _MS2ImageMethods(): 

1089 

1090 @staticmethod 

1091 def convert(base_image: str = None, input_ms: str = None, input_image_shape: _ImageShape = None, 

1092 datacolumn: str = None) -> None: 

1093 output_image = _MS2ImageMethods.__change_file_extension(input_ms, 'im') 

1094 _copy_image_file(base_image, output_image) # mask data is also copied in this method 

1095 

1096 image_array = _MS2ImageMethods.__make_image_array(input_image_shape, input_ms, datacolumn) 

1097 _MS2ImageMethods.__output_image(output_image, image_array) 

1098 

1099 return output_image 

1100 

1101 @staticmethod 

1102 def __change_file_extension(path: str = None, ext: str = None) -> str: 

1103 if not os.path.exists(path): 

1104 RuntimeError(f'cannot find path: {path}') 

1105 base, oldext = os.path.splitext(path) 

1106 new_path = base_path = f'{base}.{ext}' 

1107 i = 0 

1108 while True: 

1109 if not os.path.exists(new_path): 

1110 break 

1111 new_path = base_path + f'.{i}' 

1112 i += 1 

1113 if i > 10: 

1114 raise RuntimeError('some file system error occured') 

1115 return new_path 

1116 

1117 @staticmethod 

1118 def __make_image_array(input_image_shape: _ImageShape = None, infile: str = None, 

1119 datacolumn: str = None) -> np.array: 

1120 nx, ny = input_image_shape.dir_shape 

1121 image_array = np.empty((nx, ny, input_image_shape.im_nchan)) 

1122 pos = 0 

1123 with table_manager(infile) as tb: 

1124 for i in range(nx): 

1125 for j in range(ny): 

1126 image_array[i][j] = tb.getcell(datacolumn, pos)[0].real 

1127 pos += 1 

1128 if input_image_shape.axis_pol > 0: 

1129 image_array = np.expand_dims(image_array, input_image_shape.axis_pol) 

1130 return image_array 

1131 

1132 @staticmethod 

1133 def __output_image(outfile: str = None, image_array: np.array = None) -> None: 

1134 with tool_manager(outfile, image) as ia: 

1135 ia.putchunk(pixels=image_array, locking=True) 

1136 

1137 

1138def _dump_tasks(taskname: str, vals: dict): 

1139 cmd = f'{taskname}(' 

1140 arr = [f'{key}={repr(val)}' for key, val in vals.items()] 

1141 cmd += ', '.join(arr) 

1142 cmd += ')' 

1143 return cmd 

1144 

1145 

1146class _EmptyMSBaseInformation: 

1147 """The Parameters class for creating an empty MeasurementSet. 

1148 

1149 This class contains dictionaries to create an empty MS using table.create(), 

1150 and it has no method. Dictionaries have two types; desc(desctiption) and 

1151 dminfo(data management infomation), these are used as arguments of table.create(), 

1152 and for a table creating, it needs a desc dict and a dminfo dict. 

1153 so there are dicts of twice of table amount in a MeasurementSet. 

1154 """ 

1155 

1156 ms_desc = { 

1157 'ANTENNA1': {'comment': 'ID of first antenna in interferometer', 

1158 'dataManagerGroup': 'SSM', 

1159 'dataManagerType': 'StandardStMan', 

1160 'keywords': {}, 

1161 'maxlen': 0, 

1162 'option': 0, 

1163 'valueType': 'int'}, 

1164 'ANTENNA2': {'comment': 'ID of second antenna in interferometer', 

1165 'dataManagerGroup': 'SSM', 

1166 'dataManagerType': 'StandardStMan', 

1167 'keywords': {}, 

1168 'maxlen': 0, 

1169 'option': 0, 

1170 'valueType': 'int'}, 

1171 'ARRAY_ID': {'comment': 'ID of array or subarray', 

1172 'dataManagerGroup': 'ISMData', 

1173 'dataManagerType': 'IncrementalStMan', 

1174 'keywords': {}, 

1175 'maxlen': 0, 

1176 'option': 0, 

1177 'valueType': 'int'}, 

1178 'DATA': {'comment': 'The data column', 

1179 'dataManagerGroup': 'TiledData', 

1180 'dataManagerType': 'TiledShapeStMan', 

1181 'keywords': {}, 

1182 'maxlen': 0, 

1183 'ndim': 2, 

1184 'option': 0, 

1185 'valueType': 'complex'}, 

1186 'DATA_DESC_ID': {'comment': 'The data description table index', 

1187 'dataManagerGroup': 'SSM', 

1188 'dataManagerType': 'StandardStMan', 

1189 'keywords': {}, 

1190 'maxlen': 0, 

1191 'option': 0, 

1192 'valueType': 'int'}, 

1193 'EXPOSURE': {'comment': 'The effective integration time', 

1194 'dataManagerGroup': 'ISMData', 

1195 'dataManagerType': 'IncrementalStMan', 

1196 'keywords': {'QuantumUnits': np.array(['s'], dtype='<U16')}, 

1197 'maxlen': 0, 

1198 'option': 0, 

1199 'valueType': 'double'}, 

1200 'FEED1': {'comment': 'The feed index for ANTENNA1', 

1201 'dataManagerGroup': 'ISMData', 

1202 'dataManagerType': 'IncrementalStMan', 

1203 'keywords': {}, 

1204 'maxlen': 0, 

1205 'option': 0, 

1206 'valueType': 'int'}, 

1207 'FEED2': {'comment': 'The feed index for ANTENNA2', 

1208 'dataManagerGroup': 'ISMData', 

1209 'dataManagerType': 'IncrementalStMan', 

1210 'keywords': {}, 

1211 'maxlen': 0, 

1212 'option': 0, 

1213 'valueType': 'int'}, 

1214 'FIELD_ID': {'comment': 'Unique id for this pointing', 

1215 'dataManagerGroup': 'ISMData', 

1216 'dataManagerType': 'IncrementalStMan', 

1217 'keywords': {}, 

1218 'maxlen': 0, 

1219 'option': 0, 

1220 'valueType': 'int'}, 

1221 'FLAG': {'comment': 'The data flags, array of bools with same shape as data', 

1222 'dataManagerGroup': 'TiledFlag', 

1223 'dataManagerType': 'TiledShapeStMan', 

1224 'keywords': {}, 

1225 'maxlen': 0, 

1226 'ndim': 2, 

1227 'option': 0, 

1228 'valueType': 'boolean'}, 

1229 'FLAG_CATEGORY': {'comment': 'The flag category, NUM_CAT flags for each datum', 

1230 'dataManagerGroup': 'TiledFlagCategory', 

1231 'dataManagerType': 'TiledShapeStMan', 

1232 'keywords': {'CATEGORY': 

1233 np.array(['FLAG_CMD', 'ORIGINAL', 'USER'], dtype='<U16')}, 

1234 'maxlen': 0, 

1235 'ndim': 3, 

1236 'option': 0, 

1237 'valueType': 'boolean'}, 

1238 'FLAG_ROW': {'comment': 'Row flag - flag all data in this row if True', 

1239 'dataManagerGroup': 'ISMData', 

1240 'dataManagerType': 'IncrementalStMan', 

1241 'keywords': {}, 

1242 'maxlen': 0, 

1243 'option': 0, 

1244 'valueType': 'boolean'}, 

1245 'INTERVAL': {'comment': 'The sampling interval', 

1246 'dataManagerGroup': 'ISMData', 

1247 'dataManagerType': 'IncrementalStMan', 

1248 'keywords': {'QuantumUnits': np.array(['s'], dtype='<U16')}, 

1249 'maxlen': 0, 

1250 'option': 0, 

1251 'valueType': 'double'}, 

1252 'OBSERVATION_ID': {'comment': 'ID for this observation, index in OBSERVATION table', 

1253 'dataManagerGroup': 'ISMData', 

1254 'dataManagerType': 'IncrementalStMan', 

1255 'keywords': {}, 

1256 'maxlen': 0, 

1257 'option': 0, 

1258 'valueType': 'int'}, 

1259 'PROCESSOR_ID': {'comment': 'Id for backend processor, index in PROCESSOR table', 

1260 'dataManagerGroup': 'ISMData', 

1261 'dataManagerType': 'IncrementalStMan', 

1262 'keywords': {}, 

1263 'maxlen': 0, 

1264 'option': 0, 

1265 'valueType': 'int'}, 

1266 'SCAN_NUMBER': {'comment': 'Sequential scan number from on-line system', 

1267 'dataManagerGroup': 'ISMData', 

1268 'dataManagerType': 'IncrementalStMan', 

1269 'keywords': {}, 

1270 'maxlen': 0, 

1271 'option': 0, 

1272 'valueType': 'int'}, 

1273 'SIGMA': {'comment': 'Estimated rms noise for channel with unity bandpass response', 

1274 'dataManagerGroup': 'TiledSigma', 

1275 'dataManagerType': 'TiledShapeStMan', 

1276 'keywords': {}, 

1277 'maxlen': 0, 

1278 'ndim': 1, 

1279 'option': 0, 

1280 'valueType': 'float'}, 

1281 'STATE_ID': {'comment': 'ID for this observing state', 

1282 'dataManagerGroup': 'ISMData', 

1283 'dataManagerType': 'IncrementalStMan', 

1284 'keywords': {}, 

1285 'maxlen': 0, 

1286 'option': 0, 

1287 'valueType': 'int'}, 

1288 'TIME': {'comment': 'Modified Julian Day', 

1289 'dataManagerGroup': 'ISMData', 

1290 'dataManagerType': 'IncrementalStMan', 

1291 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1292 'QuantumUnits': np.array(['s'], dtype='<U16')}, 

1293 'maxlen': 0, 

1294 'option': 0, 

1295 'valueType': 'double'}, 

1296 'TIME_CENTROID': {'comment': 'Modified Julian Day', 

1297 'dataManagerGroup': 'ISMData', 

1298 'dataManagerType': 'IncrementalStMan', 

1299 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1300 'QuantumUnits': np.array(['s'], dtype='<U16')}, 

1301 'maxlen': 0, 

1302 'option': 0, 

1303 'valueType': 'double'}, 

1304 'UVW': {'comment': 'Vector with uvw coordinates (in meters)', 

1305 'dataManagerGroup': 'TiledUVW', 

1306 'dataManagerType': 'TiledColumnStMan', 

1307 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'uvw'}, 

1308 'QuantumUnits': np.array(['m', 'm', 'm'], dtype='<U16')}, 

1309 'maxlen': 0, 

1310 'ndim': 1, 

1311 'option': 5, 

1312 'shape': np.array([3]), 

1313 'valueType': 'double'}, 

1314 'WEIGHT': {'comment': 'Weight for each polarization spectrum', 

1315 'dataManagerGroup': 'TiledWgt', 

1316 'dataManagerType': 'TiledShapeStMan', 

1317 'keywords': {}, 

1318 'maxlen': 0, 

1319 'ndim': 1, 

1320 'option': 0, 

1321 'valueType': 'float'}, 

1322 'WEIGHT_SPECTRUM': {'comment': 'Weight for each data point', 

1323 'dataManagerGroup': 'TiledWgtSpectrum', 

1324 'dataManagerType': 'TiledShapeStMan', 

1325 'keywords': {}, 

1326 'maxlen': 0, 

1327 'ndim': 2, 

1328 'option': 0, 

1329 'valueType': 'float'}, 

1330 } 

1331 

1332 ms_dminfo = { 

1333 '*1': {'COLUMNS': array(['ARRAY_ID', 'EXPOSURE', 'FEED1', 'FEED2', 'FIELD_ID', 'FLAG_ROW', 

1334 'INTERVAL', 'OBSERVATION_ID', 'PROCESSOR_ID', 'SCAN_NUMBER', 

1335 'STATE_ID', 'TIME', 'TIME_CENTROID'], dtype='<U16'), 

1336 'NAME': 'ISMData', 

1337 'SEQNR': 0, 

1338 'SPEC': {'BUCKETSIZE': 62456, 'MaxCacheSize': 1, 'PERSCACHESIZE': 1}, 

1339 'TYPE': 'IncrementalStMan'}, 

1340 '*2': {'COLUMNS': array(['ANTENNA1', 'ANTENNA2', 'DATA_DESC_ID'], dtype='<U16'), 

1341 'NAME': 'SSM', 

1342 'SEQNR': 1, 

1343 'SPEC': {'BUCKETSIZE': 32768, 

1344 'IndexLength': 198, 

1345 'MaxCacheSize': 2, 

1346 'PERSCACHESIZE': 2}, 

1347 'TYPE': 'StandardStMan'}, 

1348 '*3': {'COLUMNS': array(['DATA'], dtype='<U16'), 

1349 'NAME': 'TiledData', 

1350 'SEQNR': 2, 

1351 'SPEC': {'DEFAULTTILESHAPE': array([2, 63, 1040]), 

1352 'HYPERCUBES': {'*1': {'BucketSize': 1048320, 

1353 'CellShape': array([2, 63]), 

1354 'CubeShape': array([2, 63, 22653]), 

1355 'ID': {}, 

1356 'TileShape': array([2, 63, 1040])}}, 

1357 'IndexSize': 1, 

1358 'MAXIMUMCACHESIZE': 0, 

1359 'MaxCacheSize': 0, 

1360 'SEQNR': 2}, 

1361 'TYPE': 'TiledShapeStMan'}, 

1362 '*4': {'COLUMNS': array(['FLAG'], dtype='<U16'), 

1363 'NAME': 'TiledFlag', 

1364 'SEQNR': 3, 

1365 'SPEC': {'DEFAULTTILESHAPE': array([2, 63, 1040]), 

1366 'HYPERCUBES': {'*1': {'BucketSize': 16380, 

1367 'CellShape': array([2, 63]), 

1368 'CubeShape': array([2, 63, 22653]), 

1369 'ID': {}, 

1370 'TileShape': array([2, 63, 1040])}}, 

1371 'IndexSize': 1, 

1372 'MAXIMUMCACHESIZE': 0, 

1373 'MaxCacheSize': 0, 

1374 'SEQNR': 3}, 

1375 'TYPE': 'TiledShapeStMan'}, 

1376 '*5': {'COLUMNS': array(['FLAG_CATEGORY'], dtype='<U16'), 

1377 'NAME': 'TiledFlagCategory', 

1378 'SEQNR': 4, 

1379 'SPEC': {'DEFAULTTILESHAPE': array([2, 63, 1, 1040]), 

1380 'HYPERCUBES': {}, 

1381 'IndexSize': 0, 

1382 'MAXIMUMCACHESIZE': 0, 

1383 'MaxCacheSize': 0, 

1384 'SEQNR': 4}, 

1385 'TYPE': 'TiledShapeStMan'}, 

1386 '*6': {'COLUMNS': array(['WEIGHT_SPECTRUM'], dtype='<U16'), 

1387 'NAME': 'TiledWgtSpectrum', 

1388 'SEQNR': 5, 

1389 'SPEC': {'DEFAULTTILESHAPE': array([2, 63, 1040]), 

1390 'HYPERCUBES': {'*1': {'BucketSize': 524160, 

1391 'CellShape': array([2, 63]), 

1392 'CubeShape': array([2, 63, 22653]), 

1393 'ID': {}, 

1394 'TileShape': array([2, 63, 1040])}}, 

1395 'IndexSize': 1, 

1396 'MAXIMUMCACHESIZE': 0, 

1397 'MaxCacheSize': 0, 

1398 'SEQNR': 5}, 

1399 'TYPE': 'TiledShapeStMan'}, 

1400 '*7': {'COLUMNS': array(['UVW'], dtype='<U16'), 

1401 'NAME': 'TiledUVW', 

1402 'SEQNR': 6, 

1403 'SPEC': {'DEFAULTTILESHAPE': array([3, 1024]), 

1404 'HYPERCUBES': {'*1': {'BucketSize': 24576, 

1405 'CellShape': array([3]), 

1406 'CubeShape': array([3, 22653]), 

1407 'ID': {}, 

1408 'TileShape': array([3, 1024])}}, 

1409 'MAXIMUMCACHESIZE': 0, 

1410 'MaxCacheSize': 0, 

1411 'SEQNR': 6}, 

1412 'TYPE': 'TiledColumnStMan'}, 

1413 '*8': {'COLUMNS': array(['WEIGHT'], dtype='<U16'), 

1414 'NAME': 'TiledWgt', 

1415 'SEQNR': 7, 

1416 'SPEC': {'DEFAULTTILESHAPE': array([2, 1040]), 

1417 'HYPERCUBES': {'*1': {'BucketSize': 8320, 

1418 'CellShape': array([2]), 

1419 'CubeShape': array([2, 22653]), 

1420 'ID': {}, 

1421 'TileShape': array([2, 1040])}}, 

1422 'IndexSize': 1, 

1423 'MAXIMUMCACHESIZE': 0, 

1424 'MaxCacheSize': 0, 

1425 'SEQNR': 7}, 

1426 'TYPE': 'TiledShapeStMan'}, 

1427 '*9': {'COLUMNS': array(['SIGMA'], dtype='<U16'), 

1428 'NAME': 'TiledSigma', 

1429 'SEQNR': 8, 

1430 'SPEC': {'DEFAULTTILESHAPE': array([2, 1040]), 

1431 'HYPERCUBES': {'*1': {'BucketSize': 8320, 

1432 'CellShape': array([2]), 

1433 'CubeShape': array([2, 22653]), 

1434 'ID': {}, 

1435 'TileShape': array([2, 1040])}}, 

1436 'IndexSize': 1, 

1437 'MAXIMUMCACHESIZE': 0, 

1438 'MaxCacheSize': 0, 

1439 'SEQNR': 8}, 

1440 'TYPE': 'TiledShapeStMan'} 

1441 } 

1442 

1443 antenna_desc = { 

1444 'DISH_DIAMETER': {'comment': 'Physical diameter of dish', 

1445 'dataManagerGroup': 'StandardStMan', 

1446 'dataManagerType': 'StandardStMan', 

1447 'keywords': {'QuantumUnits': array(['m'], dtype='<U16')}, 

1448 'maxlen': 0, 

1449 'option': 0, 

1450 'valueType': 'double'}, 

1451 'FLAG_ROW': {'comment': 'Flag for this row', 

1452 'dataManagerGroup': 'StandardStMan', 

1453 'dataManagerType': 'StandardStMan', 

1454 'keywords': {}, 

1455 'maxlen': 0, 

1456 'option': 0, 

1457 'valueType': 'boolean'}, 

1458 'MOUNT': {'comment': 'Mount type e.g. alt-az, equatorial, etc.', 

1459 'dataManagerGroup': 'StandardStMan', 

1460 'dataManagerType': 'StandardStMan', 

1461 'keywords': {}, 

1462 'maxlen': 0, 

1463 'option': 0, 

1464 'valueType': 'string'}, 

1465 'NAME': {'comment': 'Antenna name, e.g. VLA22, CA03', 

1466 'dataManagerGroup': 'StandardStMan', 

1467 'dataManagerType': 'StandardStMan', 

1468 'keywords': {'ARRAY_NAME': 'VLA'}, 

1469 'maxlen': 0, 

1470 'option': 0, 

1471 'valueType': 'string'}, 

1472 'OFFSET': {'comment': 'Axes offset of mount to FEED REFERENCE point', 

1473 'dataManagerGroup': 'StandardStMan', 

1474 'dataManagerType': 'StandardStMan', 

1475 'keywords': {'MEASINFO': {'Ref': 'ITRF', 'type': 'position'}, 

1476 'QuantumUnits': array(['m', 'm', 'm'], dtype='<U16')}, 

1477 'maxlen': 0, 

1478 'ndim': 1, 

1479 'option': 5, 

1480 'shape': array([3]), 

1481 'valueType': 'double'}, 

1482 'POSITION': {'comment': 'Antenna X,Y,Z phase reference position', 

1483 'dataManagerGroup': 'StandardStMan', 

1484 'dataManagerType': 'StandardStMan', 

1485 'keywords': {'ARRAY_POSITION': array([0., 0., 0.]), 

1486 'MEASINFO': {'Ref': 'ITRF', 'type': 'position'}, 

1487 'QuantumUnits': array(['m', 'm', 'm'], dtype='<U16')}, 

1488 'maxlen': 0, 

1489 'ndim': 1, 

1490 'option': 5, 

1491 'shape': array([3]), 

1492 'valueType': 'double'}, 

1493 'STATION': {'comment': 'Station (antenna pad) name', 

1494 'dataManagerGroup': 'StandardStMan', 

1495 'dataManagerType': 'StandardStMan', 

1496 'keywords': {}, 

1497 'maxlen': 0, 

1498 'option': 0, 

1499 'valueType': 'string'}, 

1500 'TYPE': {'comment': 'Antenna type (e.g. SPACE-BASED)', 

1501 'dataManagerGroup': 'StandardStMan', 

1502 'dataManagerType': 'StandardStMan', 

1503 'keywords': {}, 

1504 'maxlen': 0, 

1505 'option': 0, 

1506 'valueType': 'string'}, 

1507 '_define_hypercolumn_': {}, 

1508 '_keywords_': {'DEGPDY': 360.9856341442, 

1509 'GSTIA0': 3.5030897164680597, 

1510 'RDATE': 4304481539.999771, 

1511 'TIMSYS': 'TAI'}, 

1512 '_private_keywords_': {} 

1513 } 

1514 

1515 antenna_dminfo = { 

1516 '*1': {'COLUMNS': array(['DISH_DIAMETER', 'FLAG_ROW', 'MOUNT', 'NAME', 'OFFSET', 'POSITION', 

1517 'STATION', 'TYPE'], dtype='<U16'), 

1518 'NAME': 'StandardStMan', 

1519 'SEQNR': 0, 

1520 'SPEC': {'BUCKETSIZE': 3332, 

1521 'IndexLength': 126, 

1522 'MaxCacheSize': 2, 

1523 'PERSCACHESIZE': 2}, 

1524 'TYPE': 'StandardStMan' 

1525 } 

1526 } 

1527 

1528 data_description_desc = { 

1529 'FLAG_ROW': {'comment': 'Flag this row', 

1530 'dataManagerGroup': 'StandardStMan', 

1531 'dataManagerType': 'StandardStMan', 

1532 'keywords': {}, 

1533 'maxlen': 0, 

1534 'option': 0, 

1535 'valueType': 'boolean'}, 

1536 'POLARIZATION_ID': {'comment': 'Pointer to polarization table', 

1537 'dataManagerGroup': 'StandardStMan', 

1538 'dataManagerType': 'StandardStMan', 

1539 'keywords': {}, 

1540 'maxlen': 0, 

1541 'option': 0, 

1542 'valueType': 'int'}, 

1543 'SPECTRAL_WINDOW_ID': {'comment': 'Pointer to spectralwindow table', 

1544 'dataManagerGroup': 'StandardStMan', 

1545 'dataManagerType': 'StandardStMan', 

1546 'keywords': {}, 

1547 'maxlen': 0, 

1548 'option': 0, 

1549 'valueType': 'int'}, 

1550 '_define_hypercolumn_': {}, 

1551 '_keywords_': {}, 

1552 '_private_keywords_': {} 

1553 } 

1554 

1555 data_description_dminfo = { 

1556 '*1': 

1557 {'COLUMNS': array(['FLAG_ROW', 'POLARIZATION_ID', 'SPECTRAL_WINDOW_ID'], dtype='<U19'), 

1558 'NAME': 'StandardStMan', 

1559 'SEQNR': 0, 

1560 'SPEC': {'BUCKETSIZE': 260, 

1561 'IndexLength': 126, 

1562 'MaxCacheSize': 2, 

1563 'PERSCACHESIZE': 2}, 

1564 'TYPE': 'StandardStMan' 

1565 } 

1566 } 

1567 

1568 feed_desc = { 

1569 'ANTENNA_ID': {'comment': 'ID of antenna in this array', 

1570 'dataManagerGroup': 'StandardStMan', 

1571 'dataManagerType': 'StandardStMan', 

1572 'keywords': {}, 

1573 'maxlen': 0, 

1574 'option': 0, 

1575 'valueType': 'int'}, 

1576 'BEAM_ID': {'comment': 'Id for BEAM model', 

1577 'dataManagerGroup': 'StandardStMan', 

1578 'dataManagerType': 'StandardStMan', 

1579 'keywords': {}, 

1580 'maxlen': 0, 

1581 'option': 0, 

1582 'valueType': 'int'}, 

1583 'BEAM_OFFSET': {'comment': 'Beam position offset (on sky but in antennareference frame)', 

1584 'dataManagerGroup': 'StandardStMan', 

1585 'dataManagerType': 'StandardStMan', 

1586 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

1587 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

1588 'maxlen': 0, 

1589 'ndim': 2, 

1590 'option': 0, 

1591 'valueType': 'double'}, 

1592 'FEED_ID': {'comment': 'Feed id', 

1593 'dataManagerGroup': 'StandardStMan', 

1594 'dataManagerType': 'StandardStMan', 

1595 'keywords': {}, 

1596 'maxlen': 0, 

1597 'option': 0, 

1598 'valueType': 'int'}, 

1599 'INTERVAL': {'comment': 'Interval for which this set of parameters is accurate', 

1600 'dataManagerGroup': 'StandardStMan', 

1601 'dataManagerType': 'StandardStMan', 

1602 'keywords': {'QuantumUnits': array(['s'], dtype='<U16')}, 

1603 'maxlen': 0, 

1604 'option': 0, 

1605 'valueType': 'double'}, 

1606 'NUM_RECEPTORS': {'comment': 'Number of receptors on this feed (probably 1 or 2)', 

1607 'dataManagerGroup': 'StandardStMan', 

1608 'dataManagerType': 'StandardStMan', 

1609 'keywords': {}, 

1610 'maxlen': 0, 

1611 'option': 0, 

1612 'valueType': 'int'}, 

1613 'POLARIZATION_TYPE': {'comment': 'Type of polarization to which a given RECEPTOR responds', 

1614 'dataManagerGroup': 'StandardStMan', 

1615 'dataManagerType': 'StandardStMan', 

1616 'keywords': {}, 

1617 'maxlen': 0, 

1618 'ndim': 1, 

1619 'option': 0, 

1620 'valueType': 'string'}, 

1621 'POL_RESPONSE': {'comment': 'D-matrix i.e. leakage between two receptors', 

1622 'dataManagerGroup': 'StandardStMan', 

1623 'dataManagerType': 'StandardStMan', 

1624 'keywords': {}, 

1625 'maxlen': 0, 

1626 'ndim': 2, 

1627 'option': 0, 

1628 'valueType': 'complex'}, 

1629 'POSITION': {'comment': 'Position of feed relative to feed reference position', 

1630 'dataManagerGroup': 'StandardStMan', 

1631 'dataManagerType': 'StandardStMan', 

1632 'keywords': {'MEASINFO': {'Ref': 'ITRF', 'type': 'position'}, 

1633 'QuantumUnits': array(['m', 'm', 'm'], dtype='<U16')}, 

1634 'maxlen': 0, 

1635 'ndim': 1, 

1636 'option': 5, 

1637 'shape': array([3]), 

1638 'valueType': 'double'}, 

1639 'RECEPTOR_ANGLE': {'comment': 'The reference angle for polarization', 

1640 'dataManagerGroup': 'StandardStMan', 

1641 'dataManagerType': 'StandardStMan', 

1642 'keywords': {'QuantumUnits': array(['rad'], dtype='<U16')}, 

1643 'maxlen': 0, 

1644 'ndim': 1, 

1645 'option': 0, 

1646 'valueType': 'double'}, 

1647 'SPECTRAL_WINDOW_ID': {'comment': 'ID for this spectral window setup', 

1648 'dataManagerGroup': 'StandardStMan', 

1649 'dataManagerType': 'StandardStMan', 

1650 'keywords': {}, 

1651 'maxlen': 0, 

1652 'option': 0, 

1653 'valueType': 'int'}, 

1654 'TIME': {'comment': 'Midpoint of time for which this set of parameters is accurate', 

1655 'dataManagerGroup': 'StandardStMan', 

1656 'dataManagerType': 'StandardStMan', 

1657 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1658 'QuantumUnits': array(['s'], dtype='<U16')}, 

1659 'maxlen': 0, 

1660 'option': 0, 

1661 'valueType': 'double'}, 

1662 '_define_hypercolumn_': {}, 

1663 '_keywords_': {}, 

1664 '_private_keywords_': {}} 

1665 

1666 feed_dminfo = { 

1667 '*1': {'COLUMNS': array(['ANTENNA_ID', 'BEAM_ID', 'BEAM_OFFSET', 'FEED_ID', 'INTERVAL', 

1668 'NUM_RECEPTORS', 'POLARIZATION_TYPE', 'POL_RESPONSE', 'POSITION', 

1669 'RECEPTOR_ANGLE', 'SPECTRAL_WINDOW_ID', 'TIME'], dtype='<U19'), 

1670 'NAME': 'StandardStMan', 

1671 'SEQNR': 0, 

1672 'SPEC': {'BUCKETSIZE': 3072, 

1673 'IndexLength': 126, 

1674 'MaxCacheSize': 2, 

1675 'PERSCACHESIZE': 2}, 

1676 'TYPE': 'StandardStMan'}} 

1677 

1678 field_desc = { 

1679 'CODE': {'comment': 'Special characteristics of field, e.g. Bandpass calibrator', 

1680 'dataManagerGroup': 'StandardStMan', 

1681 'dataManagerType': 'StandardStMan', 

1682 'keywords': {}, 

1683 'maxlen': 0, 

1684 'option': 0, 

1685 'valueType': 'string'}, 

1686 'DELAY_DIR': {'comment': 'Direction of delay center (e.g. RA, DEC)as polynomial in time.', 

1687 'dataManagerGroup': 'StandardStMan', 

1688 'dataManagerType': 'StandardStMan', 

1689 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

1690 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

1691 'maxlen': 0, 

1692 'ndim': 2, 

1693 'option': 0, 

1694 'valueType': 'double'}, 

1695 'FLAG_ROW': {'comment': 'Row Flag', 

1696 'dataManagerGroup': 'StandardStMan', 

1697 'dataManagerType': 'StandardStMan', 

1698 'keywords': {}, 

1699 'maxlen': 0, 

1700 'option': 0, 

1701 'valueType': 'boolean'}, 

1702 'NAME': {'comment': 'Name of this field', 

1703 'dataManagerGroup': 'StandardStMan', 

1704 'dataManagerType': 'StandardStMan', 

1705 'keywords': {}, 

1706 'maxlen': 0, 

1707 'option': 0, 

1708 'valueType': 'string'}, 

1709 'NUM_POLY': {'comment': 'Polynomial order of _DIR columns', 

1710 'dataManagerGroup': 'StandardStMan', 

1711 'dataManagerType': 'StandardStMan', 

1712 'keywords': {}, 

1713 'maxlen': 0, 

1714 'option': 0, 

1715 'valueType': 'int'}, 

1716 'PHASE_DIR': {'comment': 'Direction of phase center (e.g. RA, DEC).', 

1717 'dataManagerGroup': 'StandardStMan', 

1718 'dataManagerType': 'StandardStMan', 

1719 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

1720 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

1721 'maxlen': 0, 

1722 'ndim': 2, 

1723 'option': 0, 

1724 'valueType': 'double'}, 

1725 'REFERENCE_DIR': { 

1726 'comment': 'Direction of REFERENCE center (e.g. RA, DEC).as polynomial in time.', 

1727 'dataManagerGroup': 'StandardStMan', 

1728 'dataManagerType': 'StandardStMan', 

1729 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

1730 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

1731 'maxlen': 0, 

1732 'ndim': 2, 

1733 'option': 0, 

1734 'valueType': 'double'}, 

1735 'SOURCE_ID': {'comment': 'Source id', 

1736 'dataManagerGroup': 'StandardStMan', 

1737 'dataManagerType': 'StandardStMan', 

1738 'keywords': {}, 

1739 'maxlen': 0, 

1740 'option': 0, 

1741 'valueType': 'int'}, 

1742 'TIME': {'comment': 'Time origin for direction and rate', 

1743 'dataManagerGroup': 'StandardStMan', 

1744 'dataManagerType': 'StandardStMan', 

1745 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1746 'QuantumUnits': array(['s'], dtype='<U16')}, 

1747 'maxlen': 0, 

1748 'option': 0, 

1749 'valueType': 'double'}, 

1750 '_define_hypercolumn_': {}, 

1751 '_keywords_': {}, 

1752 '_private_keywords_': {}} 

1753 

1754 field_dminfo = { 

1755 '*1': {'COLUMNS': array(['CODE', 'DELAY_DIR', 'FLAG_ROW', 'NAME', 'NUM_POLY', 'PHASE_DIR', 

1756 'REFERENCE_DIR', 'SOURCE_ID', 'TIME'], dtype='<U16'), 

1757 'NAME': 'StandardStMan', 

1758 'SEQNR': 0, 

1759 'SPEC': {'BUCKETSIZE': 2052, 

1760 'IndexLength': 126, 

1761 'MaxCacheSize': 2, 

1762 'PERSCACHESIZE': 2}, 

1763 'TYPE': 'StandardStMan'}} 

1764 

1765 flag_cmd_desc = { 

1766 'APPLIED': {'comment': 'True if flag has been applied to main table', 

1767 'dataManagerGroup': 'StandardStMan', 

1768 'dataManagerType': 'StandardStMan', 

1769 'keywords': {}, 

1770 'maxlen': 0, 

1771 'option': 0, 

1772 'valueType': 'boolean'}, 

1773 'COMMAND': {'comment': 'Flagging command', 

1774 'dataManagerGroup': 'StandardStMan', 

1775 'dataManagerType': 'StandardStMan', 

1776 'keywords': {}, 

1777 'maxlen': 0, 

1778 'option': 0, 

1779 'valueType': 'string'}, 

1780 'INTERVAL': {'comment': 'Time interval for which this flag is valid', 

1781 'dataManagerGroup': 'StandardStMan', 

1782 'dataManagerType': 'StandardStMan', 

1783 'keywords': {'QuantumUnits': array(['s'], dtype='<U16')}, 

1784 'maxlen': 0, 

1785 'option': 0, 

1786 'valueType': 'double'}, 

1787 'LEVEL': {'comment': 'Flag level - revision level ', 

1788 'dataManagerGroup': 'StandardStMan', 

1789 'dataManagerType': 'StandardStMan', 

1790 'keywords': {}, 

1791 'maxlen': 0, 

1792 'option': 0, 

1793 'valueType': 'int'}, 

1794 'REASON': {'comment': 'Flag reason', 

1795 'dataManagerGroup': 'StandardStMan', 

1796 'dataManagerType': 'StandardStMan', 

1797 'keywords': {}, 

1798 'maxlen': 0, 

1799 'option': 0, 

1800 'valueType': 'string'}, 

1801 'SEVERITY': {'comment': 'Severity code (0-10) ', 

1802 'dataManagerGroup': 'StandardStMan', 

1803 'dataManagerType': 'StandardStMan', 

1804 'keywords': {}, 

1805 'maxlen': 0, 

1806 'option': 0, 

1807 'valueType': 'int'}, 

1808 'TIME': {'comment': 'Midpoint of interval for which this flag is valid', 

1809 'dataManagerGroup': 'StandardStMan', 

1810 'dataManagerType': 'StandardStMan', 

1811 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1812 'QuantumUnits': array(['s'], dtype='<U16')}, 

1813 'maxlen': 0, 

1814 'option': 0, 

1815 'valueType': 'double'}, 

1816 'TYPE': {'comment': 'Type of flag (FLAG or UNFLAG)', 

1817 'dataManagerGroup': 'StandardStMan', 

1818 'dataManagerType': 'StandardStMan', 

1819 'keywords': {}, 

1820 'maxlen': 0, 

1821 'option': 0, 

1822 'valueType': 'string'}, 

1823 '_define_hypercolumn_': {}, 

1824 '_keywords_': {}, 

1825 '_private_keywords_': {}} 

1826 

1827 flag_cmd_dminfo = { 

1828 '*1': {'COLUMNS': array(['APPLIED', 'COMMAND', 'INTERVAL', 'LEVEL', 'REASON', 'SEVERITY', 

1829 'TIME', 'TYPE'], dtype='<U16'), 

1830 'NAME': 'StandardStMan', 

1831 'SEQNR': 0, 

1832 'SPEC': {'BUCKETSIZE': 1924, 

1833 'IndexLength': 118, 

1834 'MaxCacheSize': 2, 

1835 'PERSCACHESIZE': 2}, 

1836 'TYPE': 'StandardStMan'}} 

1837 

1838 history_desc = { 

1839 'APPLICATION': {'comment': 'Application name', 

1840 'dataManagerGroup': 'StandardStMan', 

1841 'dataManagerType': 'StandardStMan', 

1842 'keywords': {}, 

1843 'maxlen': 0, 

1844 'option': 0, 

1845 'valueType': 'string'}, 

1846 'APP_PARAMS': {'comment': 'Application parameters', 

1847 'dataManagerGroup': 'StandardStMan', 

1848 'dataManagerType': 'StandardStMan', 

1849 'keywords': {}, 

1850 'maxlen': 0, 

1851 'ndim': 1, 

1852 'option': 0, 

1853 'valueType': 'string'}, 

1854 'CLI_COMMAND': {'comment': 'CLI command sequence', 

1855 'dataManagerGroup': 'StandardStMan', 

1856 'dataManagerType': 'StandardStMan', 

1857 'keywords': {}, 

1858 'maxlen': 0, 

1859 'ndim': 1, 

1860 'option': 0, 

1861 'valueType': 'string'}, 

1862 'MESSAGE': {'comment': 'Log message', 

1863 'dataManagerGroup': 'StandardStMan', 

1864 'dataManagerType': 'StandardStMan', 

1865 'keywords': {}, 

1866 'maxlen': 0, 

1867 'option': 0, 

1868 'valueType': 'string'}, 

1869 'OBJECT_ID': {'comment': 'Originating ObjectID', 

1870 'dataManagerGroup': 'StandardStMan', 

1871 'dataManagerType': 'StandardStMan', 

1872 'keywords': {}, 

1873 'maxlen': 0, 

1874 'option': 0, 

1875 'valueType': 'int'}, 

1876 'OBSERVATION_ID': {'comment': 'Observation id (index in OBSERVATION table)', 

1877 'dataManagerGroup': 'StandardStMan', 

1878 'dataManagerType': 'StandardStMan', 

1879 'keywords': {}, 

1880 'maxlen': 0, 

1881 'option': 0, 

1882 'valueType': 'int'}, 

1883 'ORIGIN': {'comment': '(Source code) origin from which message originated', 

1884 'dataManagerGroup': 'StandardStMan', 

1885 'dataManagerType': 'StandardStMan', 

1886 'keywords': {}, 

1887 'maxlen': 0, 

1888 'option': 0, 

1889 'valueType': 'string'}, 

1890 'PRIORITY': {'comment': 'Message priority', 

1891 'dataManagerGroup': 'StandardStMan', 

1892 'dataManagerType': 'StandardStMan', 

1893 'keywords': {}, 

1894 'maxlen': 0, 

1895 'option': 0, 

1896 'valueType': 'string'}, 

1897 'TIME': {'comment': 'Timestamp of message', 

1898 'dataManagerGroup': 'StandardStMan', 

1899 'dataManagerType': 'StandardStMan', 

1900 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1901 'QuantumUnits': array(['s'], dtype='<U16')}, 

1902 'maxlen': 0, 

1903 'option': 0, 

1904 'valueType': 'double'}, 

1905 '_define_hypercolumn_': {}, 

1906 '_keywords_': {}, 

1907 '_private_keywords_': {}} 

1908 

1909 history_dminfo = { 

1910 '*1': {'COLUMNS': array(['APPLICATION', 'APP_PARAMS', 'CLI_COMMAND', 'MESSAGE', 'OBJECT_ID', 

1911 'OBSERVATION_ID', 'ORIGIN', 'PRIORITY', 'TIME'], dtype='<U16'), 

1912 'NAME': 'StandardStMan', 

1913 'SEQNR': 0, 

1914 'SPEC': {'BUCKETSIZE': 2816, 

1915 'IndexLength': 126, 

1916 'MaxCacheSize': 2, 

1917 'PERSCACHESIZE': 2}, 

1918 'TYPE': 'StandardStMan'}} 

1919 

1920 observation_desc = { 

1921 'FLAG_ROW': {'comment': 'Row flag', 

1922 'dataManagerGroup': 'StandardStMan', 

1923 'dataManagerType': 'StandardStMan', 

1924 'keywords': {}, 

1925 'maxlen': 0, 

1926 'option': 0, 

1927 'valueType': 'boolean'}, 

1928 'LOG': {'comment': 'Observing log', 

1929 'dataManagerGroup': 'StandardStMan', 

1930 'dataManagerType': 'StandardStMan', 

1931 'keywords': {}, 

1932 'maxlen': 0, 

1933 'ndim': 1, 

1934 'option': 0, 

1935 'valueType': 'string'}, 

1936 'OBSERVER': {'comment': 'Name of observer(s)', 

1937 'dataManagerGroup': 'StandardStMan', 

1938 'dataManagerType': 'StandardStMan', 

1939 'keywords': {}, 

1940 'maxlen': 0, 

1941 'option': 0, 

1942 'valueType': 'string'}, 

1943 'PROJECT': {'comment': 'Project identification string', 

1944 'dataManagerGroup': 'StandardStMan', 

1945 'dataManagerType': 'StandardStMan', 

1946 'keywords': {}, 

1947 'maxlen': 0, 

1948 'option': 0, 

1949 'valueType': 'string'}, 

1950 'RELEASE_DATE': {'comment': 'Release date when data becomes public', 

1951 'dataManagerGroup': 'StandardStMan', 

1952 'dataManagerType': 'StandardStMan', 

1953 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1954 'QuantumUnits': array(['s'], dtype='<U16')}, 

1955 'maxlen': 0, 

1956 'option': 0, 

1957 'valueType': 'double'}, 

1958 'SCHEDULE': {'comment': 'Observing schedule', 

1959 'dataManagerGroup': 'StandardStMan', 

1960 'dataManagerType': 'StandardStMan', 

1961 'keywords': {}, 

1962 'maxlen': 0, 

1963 'ndim': 1, 

1964 'option': 0, 

1965 'valueType': 'string'}, 

1966 'SCHEDULE_TYPE': {'comment': 'Observing schedule type', 

1967 'dataManagerGroup': 'StandardStMan', 

1968 'dataManagerType': 'StandardStMan', 

1969 'keywords': {}, 

1970 'maxlen': 0, 

1971 'option': 0, 

1972 'valueType': 'string'}, 

1973 'TELESCOPE_NAME': {'comment': 'Telescope Name (e.g. WSRT, VLBA)', 

1974 'dataManagerGroup': 'StandardStMan', 

1975 'dataManagerType': 'StandardStMan', 

1976 'keywords': {}, 

1977 'maxlen': 0, 

1978 'option': 0, 

1979 'valueType': 'string'}, 

1980 'TIME_RANGE': {'comment': 'Start and end of observation', 

1981 'dataManagerGroup': 'StandardStMan', 

1982 'dataManagerType': 'StandardStMan', 

1983 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

1984 'QuantumUnits': array(['s'], dtype='<U16')}, 

1985 'maxlen': 0, 

1986 'ndim': 1, 

1987 'option': 5, 

1988 'shape': array([2]), 

1989 'valueType': 'double'}, 

1990 '_define_hypercolumn_': {}, 

1991 '_keywords_': {}, 

1992 '_private_keywords_': {}} 

1993 

1994 observation_dminfo = { 

1995 '*1': {'COLUMNS': array(['FLAG_ROW', 'LOG', 'OBSERVER', 'PROJECT', 'RELEASE_DATE', 

1996 'SCHEDULE', 'SCHEDULE_TYPE', 'TELESCOPE_NAME', 'TIME_RANGE'], 

1997 dtype='<U16'), 

1998 'NAME': 'StandardStMan', 

1999 'SEQNR': 0, 

2000 'SPEC': {'BUCKETSIZE': 3076, 

2001 'IndexLength': 126, 

2002 'MaxCacheSize': 2, 

2003 'PERSCACHESIZE': 2}, 

2004 'TYPE': 'StandardStMan'}} 

2005 

2006 pointing_desc = { 

2007 'ANTENNA_ID': {'comment': 'Antenna Id', 

2008 'dataManagerGroup': 'SSMPointing', 

2009 'dataManagerType': 'StandardStMan', 

2010 'keywords': {}, 

2011 'maxlen': 0, 

2012 'option': 0, 

2013 'valueType': 'int'}, 

2014 'DIRECTION': {'comment': 'Antenna pointing direction as polynomial in time', 

2015 'dataManagerGroup': 'ISMPointing', 

2016 'dataManagerType': 'IncrementalStMan', 

2017 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

2018 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

2019 'maxlen': 0, 

2020 'ndim': 2, 

2021 'option': 0, 

2022 'valueType': 'double'}, 

2023 'INTERVAL': {'comment': 'Time interval', 

2024 'dataManagerGroup': 'ISMPointing', 

2025 'dataManagerType': 'IncrementalStMan', 

2026 'keywords': {'QuantumUnits': array(['s'], dtype='<U16')}, 

2027 'maxlen': 0, 

2028 'option': 0, 

2029 'valueType': 'double'}, 

2030 'NAME': {'comment': 'Pointing position name', 

2031 'dataManagerGroup': 'ISMPointing', 

2032 'dataManagerType': 'IncrementalStMan', 

2033 'keywords': {}, 

2034 'maxlen': 0, 

2035 'option': 0, 

2036 'valueType': 'string'}, 

2037 'NUM_POLY': {'comment': 'Series order', 

2038 'dataManagerGroup': 'ISMPointing', 

2039 'dataManagerType': 'IncrementalStMan', 

2040 'keywords': {}, 

2041 'maxlen': 0, 

2042 'option': 0, 

2043 'valueType': 'int'}, 

2044 'TARGET': {'comment': 'target direction as polynomial in time', 

2045 'dataManagerGroup': 'ISMPointing', 

2046 'dataManagerType': 'IncrementalStMan', 

2047 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

2048 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

2049 'maxlen': 0, 

2050 'ndim': -1, 

2051 'option': 0, 

2052 'valueType': 'double'}, 

2053 'TIME': {'comment': 'Time interval midpoint', 

2054 'dataManagerGroup': 'ISMPointing', 

2055 'dataManagerType': 'IncrementalStMan', 

2056 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

2057 'QuantumUnits': array(['s'], dtype='<U16')}, 

2058 'maxlen': 0, 

2059 'option': 0, 

2060 'valueType': 'double'}, 

2061 'TIME_ORIGIN': {'comment': 'Time origin for direction', 

2062 'dataManagerGroup': 'ISMPointing', 

2063 'dataManagerType': 'IncrementalStMan', 

2064 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

2065 'QuantumUnits': array(['s'], dtype='<U16')}, 

2066 'maxlen': 0, 

2067 'option': 0, 

2068 'valueType': 'double'}, 

2069 'TRACKING': {'comment': 'Tracking flag - True if on position', 

2070 'dataManagerGroup': 'ISMPointing', 

2071 'dataManagerType': 'IncrementalStMan', 

2072 'keywords': {}, 

2073 'maxlen': 0, 

2074 'option': 0, 

2075 'valueType': 'boolean'}, 

2076 '_define_hypercolumn_': {}, 

2077 '_keywords_': {}, 

2078 '_private_keywords_': {}} 

2079 

2080 pointing_dminfo = { 

2081 '*1': {'COLUMNS': array(['DIRECTION', 'INTERVAL', 'NAME', 'NUM_POLY', 'TARGET', 'TIME', 

2082 'TIME_ORIGIN', 'TRACKING'], dtype='<U16'), 

2083 'NAME': 'ISMPointing', 

2084 'SEQNR': 0, 

2085 'SPEC': {'BUCKETSIZE': 38436, 'MaxCacheSize': 1, 'PERSCACHESIZE': 1}, 

2086 'TYPE': 'IncrementalStMan'}, 

2087 '*2': {'COLUMNS': array(['ANTENNA_ID'], dtype='<U16'), 

2088 'NAME': 'SSMPointing', 

2089 'SEQNR': 1, 

2090 'SPEC': {'BUCKETSIZE': 32768, 

2091 'IndexLength': 118, 

2092 'MaxCacheSize': 2, 

2093 'PERSCACHESIZE': 2}, 

2094 'TYPE': 'StandardStMan'}} 

2095 

2096 polarization_desc = { 

2097 'CORR_PRODUCT': {'comment': 'Indices describing receptors of feed going into correlation', 

2098 'dataManagerGroup': 'StandardStMan', 

2099 'dataManagerType': 'StandardStMan', 

2100 'keywords': {}, 

2101 'maxlen': 0, 

2102 'ndim': 2, 

2103 'option': 0, 

2104 'valueType': 'int'}, 

2105 'CORR_TYPE': {'comment': 

2106 'The polarization type for each correlation product, as a Stokes enum.', 

2107 'dataManagerGroup': 'StandardStMan', 

2108 'dataManagerType': 'StandardStMan', 

2109 'keywords': {}, 

2110 'maxlen': 0, 

2111 'ndim': 1, 

2112 'option': 0, 

2113 'valueType': 'int'}, 

2114 'FLAG_ROW': {'comment': 'Row flag', 

2115 'dataManagerGroup': 'StandardStMan', 

2116 'dataManagerType': 'StandardStMan', 

2117 'keywords': {}, 

2118 'maxlen': 0, 

2119 'option': 0, 

2120 'valueType': 'boolean'}, 

2121 'NUM_CORR': {'comment': 'Number of correlation products', 

2122 'dataManagerGroup': 'StandardStMan', 

2123 'dataManagerType': 'StandardStMan', 

2124 'keywords': {}, 

2125 'maxlen': 0, 

2126 'option': 0, 

2127 'valueType': 'int'}, 

2128 '_define_hypercolumn_': {}, 

2129 '_keywords_': {}, 

2130 '_private_keywords_': {}} 

2131 

2132 polarization_dminfo = { 

2133 '*1': {'COLUMNS': array(['CORR_PRODUCT', 'CORR_TYPE', 

2134 'FLAG_ROW', 'NUM_CORR'], dtype='<U16'), 

2135 'NAME': 'StandardStMan', 

2136 'SEQNR': 0, 

2137 'SPEC': {'BUCKETSIZE': 644, 

2138 'IndexLength': 126, 

2139 'MaxCacheSize': 2, 

2140 'PERSCACHESIZE': 2}, 

2141 'TYPE': 'StandardStMan'}} 

2142 

2143 processor_desc = { 

2144 'FLAG_ROW': {'comment': 'Row flag', 

2145 'dataManagerGroup': 'StandardStMan', 

2146 'dataManagerType': 'StandardStMan', 

2147 'keywords': {}, 

2148 'maxlen': 0, 

2149 'option': 0, 

2150 'valueType': 'boolean'}, 

2151 'MODE_ID': {'comment': 'Processor mode id', 

2152 'dataManagerGroup': 'StandardStMan', 

2153 'dataManagerType': 'StandardStMan', 

2154 'keywords': {}, 

2155 'maxlen': 0, 

2156 'option': 0, 

2157 'valueType': 'int'}, 

2158 'SUB_TYPE': {'comment': 'Processor sub type', 

2159 'dataManagerGroup': 'StandardStMan', 

2160 'dataManagerType': 'StandardStMan', 

2161 'keywords': {}, 

2162 'maxlen': 0, 

2163 'option': 0, 

2164 'valueType': 'string'}, 

2165 'TYPE': {'comment': 'Processor type', 

2166 'dataManagerGroup': 'StandardStMan', 

2167 'dataManagerType': 'StandardStMan', 

2168 'keywords': {}, 

2169 'maxlen': 0, 

2170 'option': 0, 

2171 'valueType': 'string'}, 

2172 'TYPE_ID': {'comment': 'Processor type id', 

2173 'dataManagerGroup': 'StandardStMan', 

2174 'dataManagerType': 'StandardStMan', 

2175 'keywords': {}, 

2176 'maxlen': 0, 

2177 'option': 0, 

2178 'valueType': 'int'}, 

2179 '_define_hypercolumn_': {}, 

2180 '_keywords_': {}, 

2181 '_private_keywords_': {}} 

2182 

2183 processor_dminfo = { 

2184 '*1': {'COLUMNS': array(['FLAG_ROW', 'MODE_ID', 

2185 'SUB_TYPE', 'TYPE', 'TYPE_ID'], dtype='<U16'), 

2186 'NAME': 'StandardStMan', 

2187 'SEQNR': 0, 

2188 'SPEC': {'BUCKETSIZE': 1028, 

2189 'IndexLength': 118, 

2190 'MaxCacheSize': 2, 

2191 'PERSCACHESIZE': 2}, 

2192 'TYPE': 'StandardStMan'}} 

2193 

2194 source_desc = { 

2195 'CALIBRATION_GROUP': {'comment': 'Number of grouping for calibration purpose.', 

2196 'dataManagerGroup': 'StandardStMan', 

2197 'dataManagerType': 'StandardStMan', 

2198 'keywords': {}, 

2199 'maxlen': 0, 

2200 'option': 0, 

2201 'valueType': 'int'}, 

2202 'CODE': {'comment': 'Special characteristics of source, e.g. Bandpass calibrator', 

2203 'dataManagerGroup': 'StandardStMan', 

2204 'dataManagerType': 'StandardStMan', 

2205 'keywords': {}, 

2206 'maxlen': 0, 

2207 'option': 0, 

2208 'valueType': 'string'}, 

2209 'DIRECTION': {'comment': 'Direction (e.g. RA, DEC).', 

2210 'dataManagerGroup': 'StandardStMan', 

2211 'dataManagerType': 'StandardStMan', 

2212 'keywords': {'MEASINFO': {'Ref': 'J2000', 'type': 'direction'}, 

2213 'QuantumUnits': array(['rad', 'rad'], dtype='<U16')}, 

2214 'maxlen': 0, 

2215 'ndim': 1, 

2216 'option': 5, 

2217 'shape': array([2]), 

2218 'valueType': 'double'}, 

2219 'INTERVAL': {'comment': 'Interval of time for which this set of parameters is accurate', 

2220 'dataManagerGroup': 'StandardStMan', 

2221 'dataManagerType': 'StandardStMan', 

2222 'keywords': {'QuantumUnits': array(['s'], dtype='<U16')}, 

2223 'maxlen': 0, 

2224 'option': 0, 

2225 'valueType': 'double'}, 

2226 'NAME': {'comment': 'Name of source as given during observations', 

2227 'dataManagerGroup': 'StandardStMan', 

2228 'dataManagerType': 'StandardStMan', 

2229 'keywords': {}, 

2230 'maxlen': 0, 

2231 'option': 0, 

2232 'valueType': 'string'}, 

2233 'NUM_LINES': {'comment': 'Number of spectral lines', 

2234 'dataManagerGroup': 'StandardStMan', 

2235 'dataManagerType': 'StandardStMan', 

2236 'keywords': {}, 

2237 'maxlen': 0, 

2238 'option': 0, 

2239 'valueType': 'int'}, 

2240 'POSITION': {'comment': 'Position (e.g. for solar system objects', 

2241 'dataManagerGroup': 'StandardStMan', 

2242 'dataManagerType': 'StandardStMan', 

2243 'keywords': {'MEASINFO': {'Ref': 'ITRF', 'type': 'position'}, 

2244 'QuantumUnits': array(['m', 'm', 'm'], dtype='<U16')}, 

2245 'maxlen': 0, 

2246 'ndim': -1, 

2247 'option': 0, 

2248 'valueType': 'double'}, 

2249 'PROPER_MOTION': {'comment': 'Proper motion', 

2250 'dataManagerGroup': 'StandardStMan', 

2251 'dataManagerType': 'StandardStMan', 

2252 'keywords': {'QuantumUnits': array(['rad/s'], dtype='<U16')}, 

2253 'maxlen': 0, 

2254 'ndim': 1, 

2255 'option': 5, 

2256 'shape': array([2]), 

2257 'valueType': 'double'}, 

2258 'REST_FREQUENCY': {'comment': 'Line rest frequency', 

2259 'dataManagerGroup': 'StandardStMan', 

2260 'dataManagerType': 'StandardStMan', 

2261 'keywords': {'MEASINFO': {'Ref': 'LSRK', 'type': 'frequency'}, 

2262 'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2263 'maxlen': 0, 

2264 'ndim': -1, 

2265 'option': 0, 

2266 'valueType': 'double'}, 

2267 'SOURCE_ID': {'comment': 'Source id', 

2268 'dataManagerGroup': 'StandardStMan', 

2269 'dataManagerType': 'StandardStMan', 

2270 'keywords': {}, 

2271 'maxlen': 0, 

2272 'option': 0, 

2273 'valueType': 'int'}, 

2274 'SOURCE_MODEL': {'comment': 'Component Source Model', 

2275 'dataManagerGroup': 'StandardStMan', 

2276 'dataManagerType': 'StandardStMan', 

2277 'keywords': {}, 

2278 'maxlen': 0, 

2279 'option': 0, 

2280 'valueType': 'record'}, 

2281 'SPECTRAL_WINDOW_ID': {'comment': 'ID for this spectral window setup', 

2282 'dataManagerGroup': 'StandardStMan', 

2283 'dataManagerType': 'StandardStMan', 

2284 'keywords': {}, 

2285 'maxlen': 0, 

2286 'option': 0, 

2287 'valueType': 'int'}, 

2288 'SYSVEL': {'comment': 'Systemic velocity at reference', 

2289 'dataManagerGroup': 'StandardStMan', 

2290 'dataManagerType': 'StandardStMan', 

2291 'keywords': {'MEASINFO': {'Ref': 'LSRK', 'type': 'radialvelocity'}, 

2292 'QuantumUnits': array(['m/s'], dtype='<U16')}, 

2293 'maxlen': 0, 

2294 'ndim': -1, 

2295 'option': 0, 

2296 'valueType': 'double'}, 

2297 'TIME': {'comment': 'Midpoint of time for which this set of parameters is accurate.', 

2298 'dataManagerGroup': 'StandardStMan', 

2299 'dataManagerType': 'StandardStMan', 

2300 'keywords': {'MEASINFO': {'Ref': 'TAI', 'type': 'epoch'}, 

2301 'QuantumUnits': array(['s'], dtype='<U16')}, 

2302 'maxlen': 0, 

2303 'option': 0, 

2304 'valueType': 'double'}, 

2305 'TRANSITION': {'comment': 'Line Transition name', 

2306 'dataManagerGroup': 'StandardStMan', 

2307 'dataManagerType': 'StandardStMan', 

2308 'keywords': {}, 

2309 'maxlen': 0, 

2310 'ndim': -1, 

2311 'option': 0, 

2312 'valueType': 'string'}, 

2313 '_define_hypercolumn_': {}, 

2314 '_keywords_': {}, 

2315 '_private_keywords_': {}} 

2316 

2317 source_dminfo = { 

2318 '*1': {'COLUMNS': array(['CALIBRATION_GROUP', 'CODE', 'DIRECTION', 'INTERVAL', 'NAME', 

2319 'NUM_LINES', 'POSITION', 'PROPER_MOTION', 'REST_FREQUENCY', 

2320 'SOURCE_ID', 'SOURCE_MODEL', 'SPECTRAL_WINDOW_ID', 'SYSVEL', 

2321 'TIME', 'TRANSITION'], dtype='<U19'), 

2322 'NAME': 'StandardStMan', 

2323 'SEQNR': 0, 

2324 'SPEC': {'BUCKETSIZE': 4224, 

2325 'IndexLength': 126, 

2326 'MaxCacheSize': 2, 

2327 'PERSCACHESIZE': 2}, 

2328 'TYPE': 'StandardStMan'}} 

2329 

2330 special_window_desc = { 

2331 'CHAN_FREQ': {'comment': 'Center frequencies for each channel in the data matrix', 

2332 'dataManagerGroup': 'StandardStMan', 

2333 'dataManagerType': 'StandardStMan', 

2334 'keywords': 

2335 {'MEASINFO': 

2336 {'TabRefCodes': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 64], dtype=uint64), 

2337 'TabRefTypes': array(['REST', 'LSRK', 'LSRD', 'BARY', 

2338 'GEO', 'TOPO', 'GALACTO', 

2339 'LGROUP', 'CMB', 'Undefined'], dtype='<U16'), 

2340 'VarRefCol': 'MEAS_FREQ_REF', 

2341 'type': 'frequency'}, 

2342 'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2343 'maxlen': 0, 

2344 'ndim': 1, 

2345 'option': 0, 

2346 'valueType': 'double'}, 

2347 'CHAN_WIDTH': {'comment': 'Channel width for each channel', 

2348 'dataManagerGroup': 'StandardStMan', 

2349 'dataManagerType': 'StandardStMan', 

2350 'keywords': {'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2351 'maxlen': 0, 

2352 'ndim': 1, 

2353 'option': 0, 

2354 'valueType': 'double'}, 

2355 'EFFECTIVE_BW': {'comment': 'Effective noise bandwidth of each channel', 

2356 'dataManagerGroup': 'StandardStMan', 

2357 'dataManagerType': 'StandardStMan', 

2358 'keywords': {'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2359 'maxlen': 0, 

2360 'ndim': 1, 

2361 'option': 0, 

2362 'valueType': 'double'}, 

2363 'FLAG_ROW': {'comment': 'Row flag', 

2364 'dataManagerGroup': 'StandardStMan', 

2365 'dataManagerType': 'StandardStMan', 

2366 'keywords': {}, 

2367 'maxlen': 0, 

2368 'option': 0, 

2369 'valueType': 'boolean'}, 

2370 'FREQ_GROUP': {'comment': 'Frequency group', 

2371 'dataManagerGroup': 'StandardStMan', 

2372 'dataManagerType': 'StandardStMan', 

2373 'keywords': {}, 

2374 'maxlen': 0, 

2375 'option': 0, 

2376 'valueType': 'int'}, 

2377 'FREQ_GROUP_NAME': {'comment': 'Frequency group name', 

2378 'dataManagerGroup': 'StandardStMan', 

2379 'dataManagerType': 'StandardStMan', 

2380 'keywords': {}, 

2381 'maxlen': 0, 

2382 'option': 0, 

2383 'valueType': 'string'}, 

2384 'IF_CONV_CHAIN': {'comment': 'The IF conversion chain number', 

2385 'dataManagerGroup': 'StandardStMan', 

2386 'dataManagerType': 'StandardStMan', 

2387 'keywords': {}, 

2388 'maxlen': 0, 

2389 'option': 0, 

2390 'valueType': 'int'}, 

2391 'MEAS_FREQ_REF': {'comment': 'Frequency Measure reference', 

2392 'dataManagerGroup': 'StandardStMan', 

2393 'dataManagerType': 'StandardStMan', 

2394 'keywords': {}, 

2395 'maxlen': 0, 

2396 'option': 0, 

2397 'valueType': 'int'}, 

2398 'NAME': {'comment': 'Spectral window name', 

2399 'dataManagerGroup': 'StandardStMan', 

2400 'dataManagerType': 'StandardStMan', 

2401 'keywords': {}, 

2402 'maxlen': 0, 

2403 'option': 0, 

2404 'valueType': 'string'}, 

2405 'NET_SIDEBAND': {'comment': 'Net sideband', 

2406 'dataManagerGroup': 'StandardStMan', 

2407 'dataManagerType': 'StandardStMan', 

2408 'keywords': {}, 

2409 'maxlen': 0, 

2410 'option': 0, 

2411 'valueType': 'int'}, 

2412 'NUM_CHAN': {'comment': 'Number of spectral channels', 

2413 'dataManagerGroup': 'StandardStMan', 

2414 'dataManagerType': 'StandardStMan', 

2415 'keywords': {}, 

2416 'maxlen': 0, 

2417 'option': 0, 

2418 'valueType': 'int'}, 

2419 'REF_FREQUENCY': { 

2420 'comment': 'The reference frequency', 

2421 'dataManagerGroup': 'StandardStMan', 

2422 'dataManagerType': 'StandardStMan', 

2423 'keywords': 

2424 {'MEASINFO': 

2425 {'TabRefCodes': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 64], dtype=uint64), 

2426 'TabRefTypes': array(['REST', 'LSRK', 'LSRD', 'BARY', 'GEO', 'TOPO', 'GALACTO', 

2427 'LGROUP', 'CMB', 'Undefined'], dtype='<U16'), 

2428 'VarRefCol': 'MEAS_FREQ_REF', 

2429 'type': 'frequency'}, 

2430 'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2431 'maxlen': 0, 

2432 'option': 0, 

2433 'valueType': 'double'}, 

2434 'RESOLUTION': {'comment': 'The effective noise bandwidth for each channel', 

2435 'dataManagerGroup': 'StandardStMan', 

2436 'dataManagerType': 'StandardStMan', 

2437 'keywords': {'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2438 'maxlen': 0, 

2439 'ndim': 1, 

2440 'option': 0, 

2441 'valueType': 'double'}, 

2442 'TOTAL_BANDWIDTH': { 

2443 'comment': 'The total bandwidth for this window', 

2444 'dataManagerGroup': 'StandardStMan', 

2445 'dataManagerType': 'StandardStMan', 

2446 'keywords': {'QuantumUnits': array(['Hz'], dtype='<U16')}, 

2447 'maxlen': 0, 

2448 'option': 0, 

2449 'valueType': 'double'}, 

2450 '_define_hypercolumn_': {}, 

2451 '_keywords_': {}, 

2452 '_private_keywords_': {}} 

2453 

2454 special_window_dminfo = { 

2455 '*1': {'COLUMNS': array(['CHAN_FREQ', 'CHAN_WIDTH', 'EFFECTIVE_BW', 'FLAG_ROW', 

2456 'FREQ_GROUP', 'FREQ_GROUP_NAME', 'IF_CONV_CHAIN', 'MEAS_FREQ_REF', 

2457 'NAME', 'NET_SIDEBAND', 'NUM_CHAN', 'REF_FREQUENCY', 'RESOLUTION', 

2458 'TOTAL_BANDWIDTH'], dtype='<U16'), 

2459 'NAME': 'StandardStMan', 

2460 'SEQNR': 0, 

2461 'SPEC': {'BUCKETSIZE': 2948, 

2462 'IndexLength': 126, 

2463 'MaxCacheSize': 2, 

2464 'PERSCACHESIZE': 2}, 

2465 'TYPE': 'StandardStMan'}} 

2466 

2467 state_desc = { 

2468 'CAL': {'comment': 'Noise calibration temperature', 

2469 'dataManagerGroup': 'StandardStMan', 

2470 'dataManagerType': 'StandardStMan', 

2471 'keywords': {'QuantumUnits': array(['K'], dtype='<U16')}, 

2472 'maxlen': 0, 

2473 'option': 0, 

2474 'valueType': 'double'}, 

2475 'FLAG_ROW': {'comment': 'Row flag', 

2476 'dataManagerGroup': 'StandardStMan', 

2477 'dataManagerType': 'StandardStMan', 

2478 'keywords': {}, 

2479 'maxlen': 0, 

2480 'option': 0, 

2481 'valueType': 'boolean'}, 

2482 'LOAD': {'comment': 'Load temperature', 

2483 'dataManagerGroup': 'StandardStMan', 

2484 'dataManagerType': 'StandardStMan', 

2485 'keywords': {'QuantumUnits': array(['K'], dtype='<U16')}, 

2486 'maxlen': 0, 

2487 'option': 0, 

2488 'valueType': 'double'}, 

2489 'OBS_MODE': {'comment': 'Observing mode, e.g., OFF_SPECTRUM', 

2490 'dataManagerGroup': 'StandardStMan', 

2491 'dataManagerType': 'StandardStMan', 

2492 'keywords': {}, 

2493 'maxlen': 0, 

2494 'option': 0, 

2495 'valueType': 'string'}, 

2496 'REF': {'comment': 'True for a reference observation', 

2497 'dataManagerGroup': 'StandardStMan', 

2498 'dataManagerType': 'StandardStMan', 

2499 'keywords': {}, 

2500 'maxlen': 0, 

2501 'option': 0, 

2502 'valueType': 'boolean'}, 

2503 'SIG': {'comment': 'True for a source observation', 

2504 'dataManagerGroup': 'StandardStMan', 

2505 'dataManagerType': 'StandardStMan', 

2506 'keywords': {}, 

2507 'maxlen': 0, 

2508 'option': 0, 

2509 'valueType': 'boolean'}, 

2510 'SUB_SCAN': {'comment': 'Sub scan number, relative to scan number', 

2511 'dataManagerGroup': 'StandardStMan', 

2512 'dataManagerType': 'StandardStMan', 

2513 'keywords': {}, 

2514 'maxlen': 0, 

2515 'option': 0, 

2516 'valueType': 'int'}, 

2517 '_define_hypercolumn_': {}, 

2518 '_keywords_': {}, 

2519 '_private_keywords_': {}} 

2520 

2521 state_dminfo = { 

2522 '*1': {'COLUMNS': array(['CAL', 'FLAG_ROW', 'LOAD', 'OBS_MODE', 'REF', 'SIG', 'SUB_SCAN'], 

2523 dtype='<U16'), 

2524 'NAME': 'StandardStMan', 

2525 'SEQNR': 0, 

2526 'SPEC': {'BUCKETSIZE': 1036, 

2527 'IndexLength': 118, 

2528 'MaxCacheSize': 2, 

2529 'PERSCACHESIZE': 2}, 

2530 'TYPE': 'StandardStMan'}}