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

27 statements  

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

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

2##################### 273b7c2d4e7f951c40d641253327d54b ############################## 

3from __future__ import absolute_import 

4import numpy 

5from casatools.typecheck import CasaValidator as _val_ctor 

6_pc = _val_ctor( ) 

7from casatools.coercetype import coerce as _coerce 

8from casatools.errors import create_error_string 

9from .private.task_imbaseline import imbaseline as _imbaseline_t 

10from casatasks.private.task_logging import start_log as _start_log 

11from casatasks.private.task_logging import end_log as _end_log 

12from casatasks.private.task_logging import except_log as _except_log 

13 

14class _imbaseline: 

15 """ 

16 imbaseline ---- Image-based baseline subtraction for single-dish data 

17 

18 Image-based baseline subtraction for single-dish data 

19 

20 --------- parameter descriptions --------------------------------------------- 

21 

22 imagename Name of the input spectral line image 

23 linefile output continuum subtracted image file name. If it is not specified, it will be imagename + "_bs". 

24 output_cont output continuum image. Name will be imagename + ".cont" 

25 bloutput name of file in which best-fit parameters are written. No output if "" (default). 

26 maskmode mode of setting additional channel masks. "list" and "auto" are available now. 

27 chans Channels to be included in the fitting 

28 thresh S/N threshold for linefinder 

29 avg_limit channel averaging for broad lines 

30 minwidth the minimum channel width to detect as a line 

31 edge channels to drop at beginning and end of spectrum 

32 blfunc baseline model function ["poly", "chebyshev", "cspline", "sinusoid", or "variable"(expert mode)] 

33 order order of baseline model function 

34 npiece number of element polynomials for cubic spline curve 

35 applyfft automatically set wave numbers of sinusoids 

36 fftthresh threshold to select wave numbers of sinusoids 

37 addwn additional wave numbers to use 

38 rejwn wave numbers NOT to use 

39 blparam text file that stores per spectrum fit parameters 

40 clipniter maximum iteration number for iterative fitting 

41 clipthresh clipping threshold for iterative fitting 

42 dirkernel Type of kernel to use to direction plane smoothing. Acceptable values are "none" to omit image smoothing(default), "boxcar" for a boxcar kernel, "gaussian" for a gaussian kernel, "image" to use an image as the kernel. 

43 major Major axis for the kernels. Standard quantity representation. Must be specified for dirkernel="boxcar" or "gaussian". 

44 minor Minor axis. Standard quantity representation. Must be specified for dirkernel="boxcar" or "gaussian". 

45 pa Position angle used only for gaussian kernel. Standard quantity representation. 

46 kimage Kernel image name. Only used if dirkernel="image". 

47 scale Scale factor. -1.0 means auto-scale. Only used if dirkernel="image". 

48 spkernel Type of spectral smoothing kernel. Acceptable values are "none" to omit smoothing(default), "gaussian" for a gaussian kernel, "boxcar" for a boxcar kernel. 

49 kwidth smoothing kernel width in channel. Only used if spkernel="gaussian" or "boxcar". 

50 RETURNS any 

51 

52 --------- examples ----------------------------------------------------------- 

53 

54  

55 

56 

57 """ 

58 

59 _info_group_ = """analysis""" 

60 _info_desc_ = """Image-based baseline subtraction for single-dish data""" 

61 

62 def __call__( self, imagename='', linefile='', output_cont=False, bloutput='', maskmode='list', chans='', thresh=float(5.0), avg_limit=int(4), minwidth=int(4), edge=[ int(0),int(0) ], blfunc='poly', order=int(5), npiece=int(3), applyfft=True, fftthresh=float(3.0), addwn=[ int(0) ], rejwn=[ ], blparam='', clipniter=int(0), clipthresh=float(3.0), dirkernel='none', major='', minor='', pa='', kimage='', scale=float(-1.0), spkernel='none', kwidth=int(5) ): 

63 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'linefile': {'type': 'cPath', 'coerce': _coerce.expand_path}, 'output_cont': {'type': 'cBool'}, 'bloutput': {'type': 'cPath', 'coerce': _coerce.expand_path}, 'maskmode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'auto', 'list', 'AUTO', 'LIST' ]}, 'chans': {'type': 'cStr', 'coerce': _coerce.to_str}, 'thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'avg_limit': {'type': 'cInt'}, 'minwidth': {'type': 'cInt'}, 'edge': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'blfunc': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'variable', 'cspline', 'SINUSOID', 'CSPLINE', 'sinusoid', 'VARIABLE', 'POLY', 'poly', 'chebyshev', 'CHEBYSHEV' ]}, 'order': {'type': 'cInt'}, 'npiece': {'type': 'cInt'}, 'applyfft': {'type': 'cBool'}, 'fftthresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'addwn': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'rejwn': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'blparam': {'type': 'cStr', 'coerce': _coerce.to_str}, 'clipniter': {'type': 'cInt'}, 'clipthresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'dirkernel': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'none', 'gaussian', 'boxcar', 'image' ]}, 'major': {'type': 'cStr', 'coerce': _coerce.to_str}, 'minor': {'type': 'cStr', 'coerce': _coerce.to_str}, 'pa': {'type': 'cStr', 'coerce': _coerce.to_str}, 'kimage': {'type': 'cPath', 'coerce': _coerce.expand_path}, 'scale': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'spkernel': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'none', 'gaussian', 'boxcar' ]}, 'kwidth': {'type': 'cInt'}} 

64 doc = {'imagename': imagename, 'linefile': linefile, 'output_cont': output_cont, 'bloutput': bloutput, 'maskmode': maskmode, 'chans': chans, 'thresh': thresh, 'avg_limit': avg_limit, 'minwidth': minwidth, 'edge': edge, 'blfunc': blfunc, 'order': order, 'npiece': npiece, 'applyfft': applyfft, 'fftthresh': fftthresh, 'addwn': addwn, 'rejwn': rejwn, 'blparam': blparam, 'clipniter': clipniter, 'clipthresh': clipthresh, 'dirkernel': dirkernel, 'major': major, 'minor': minor, 'pa': pa, 'kimage': kimage, 'scale': scale, 'spkernel': spkernel, 'kwidth': kwidth} 

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

66 _logging_state_ = _start_log( 'imbaseline', [ 'imagename=' + repr(_pc.document['imagename']), 'linefile=' + repr(_pc.document['linefile']), 'output_cont=' + repr(_pc.document['output_cont']), 'bloutput=' + repr(_pc.document['bloutput']), 'maskmode=' + repr(_pc.document['maskmode']), 'chans=' + repr(_pc.document['chans']), 'thresh=' + repr(_pc.document['thresh']), 'avg_limit=' + repr(_pc.document['avg_limit']), 'minwidth=' + repr(_pc.document['minwidth']), 'edge=' + repr(_pc.document['edge']), 'blfunc=' + repr(_pc.document['blfunc']), 'order=' + repr(_pc.document['order']), 'npiece=' + repr(_pc.document['npiece']), 'applyfft=' + repr(_pc.document['applyfft']), 'fftthresh=' + repr(_pc.document['fftthresh']), 'addwn=' + repr(_pc.document['addwn']), 'rejwn=' + repr(_pc.document['rejwn']), 'blparam=' + repr(_pc.document['blparam']), 'clipniter=' + repr(_pc.document['clipniter']), 'clipthresh=' + repr(_pc.document['clipthresh']), 'dirkernel=' + repr(_pc.document['dirkernel']), 'major=' + repr(_pc.document['major']), 'minor=' + repr(_pc.document['minor']), 'pa=' + repr(_pc.document['pa']), 'kimage=' + repr(_pc.document['kimage']), 'scale=' + repr(_pc.document['scale']), 'spkernel=' + repr(_pc.document['spkernel']), 'kwidth=' + repr(_pc.document['kwidth']) ] ) 

67 task_result = None 

68 try: 

69 task_result = _imbaseline_t( _pc.document['imagename'], _pc.document['linefile'], _pc.document['output_cont'], _pc.document['bloutput'], _pc.document['maskmode'], _pc.document['chans'], _pc.document['thresh'], _pc.document['avg_limit'], _pc.document['minwidth'], _pc.document['edge'], _pc.document['blfunc'], _pc.document['order'], _pc.document['npiece'], _pc.document['applyfft'], _pc.document['fftthresh'], _pc.document['addwn'], _pc.document['rejwn'], _pc.document['blparam'], _pc.document['clipniter'], _pc.document['clipthresh'], _pc.document['dirkernel'], _pc.document['major'], _pc.document['minor'], _pc.document['pa'], _pc.document['kimage'], _pc.document['scale'], _pc.document['spkernel'], _pc.document['kwidth'] ) 

70 except Exception as exc: 

71 _except_log('imbaseline', exc) 

72 raise 

73 finally: 

74 task_result = _end_log( _logging_state_, 'imbaseline', task_result ) 

75 return task_result 

76 

77imbaseline = _imbaseline( ) 

78