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

27 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-01 07:19 +0000

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

2##################### f0f0b427965b14190ecdd5e50a5251e8 ############################## 

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_uvcontsub_old import uvcontsub_old as _uvcontsub_old_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 _uvcontsub_old: 

15 """ 

16 uvcontsub_old ---- Continuum fitting and subtraction in the uv plane 

17 

18 --------- parameter descriptions --------------------------------------------- 

19 

20 vis Name of input MS. Output goes to vis + ".contsub" (will be overwritten if already exists) 

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

22 fitspw Spectral window:channel selection for fitting the continuum 

23 excludechans exclude Spectral window:channel selection in fitspw for fitting 

24 combine Data axes to combine for the continuum estimation (none, or spw and/or scan) 

25 solint Continuum fit timescale (int recommended!) 

26 fitorder Polynomial order for the fits 

27 spw Spectral window selection for output 

28 want_cont Create vis + ".cont" to hold the continuum estimate. 

29 

30 --------- examples ----------------------------------------------------------- 

31 

32  

33  

34 Continuum fitting and subtraction in the uv plane: 

35  

36 This task estimates the continuum emission by fitting polynomials to 

37 the real and imaginary parts of the spectral windows and channels 

38 selected by fitspw. This fit represents a model of the continuum in 

39 all channels. 

40  

41 The fitted continuum spectrum is subtracted from all channels 

42 selected in spw, and the result (presumably only line emission) 

43 is stored in a new MS (vis + ".contsub"). If an MS 

44 with the output name already exists, it will be overwritten. 

45 It will read from the CORRECTED_DATA column of vis if it is present, 

46 or DATA if it is not. Whichever column is read is presumed to have 

47 already been calibrated. 

48  

49 If want_cont is True, the continuum fit is placed in a second new MS 

50 (vis + '.cont', also overwritten if it already exists). 

51 N.B. because the continuum model is necessarily a 

52 smoothed fit, images made with it are liable to have their field of 

53 view reduced in some strange way. Images of the continuum should be 

54 made by simply excluding the line channels (and probably averaging the 

55 remaining ones) in clean. 

56  

57 Keyword arguments: 

58 vis -- Name of input visibility file 

59 default: none; example: vis='ngc5921.ms' 

60 field -- Field selection for continuum estimation and subtraction. 

61 The estimation and subtraction is done for each selected field 

62 in turn. (Run listobs to get lists of the ID and names.) 

63 default: field = '' means select all fields 

64 field = 1 # will get field_id=1 (if you give it an 

65 integer, it will retrieve the source with that index. 

66 field = '1328+307' specifies source '1328+307' 

67 field = '13*' will retrieve '1328+307' and any other fields 

68 beginning with '13' 

69 fitspw -- Selection of spectral windows and channels to use in the 

70 fit for the continuum, using general spw:chan syntax. 

71 The ranges of channels also can be specified by frequencies as in 

72 the MS selection syntax (spw ids are required but '*' can be 

73 used, see the example below). 

74 See the note under combine. 

75 default: '' (all) 

76 example: fitspw='0:5~30;40~55' 

77 --> select the ranges by channels in the spw id 0 

78 fitspw='0:5~30;40~55,1:10~25;45~58,2' 

79 --> select channel ranges 5-30 and 40-55 for the spw id 0, 

80 10-25 and 45-58 for spwid 1, and use all channels for the spw id 2 

81 fitspw='0:113.767~114.528GHz;114.744~115.447GHz' 

82 --> select the ranges by frequencies in the spw id 0 

83 fitspw='0:113.767~114.528GHz;114.744~115.447GHz,1:111.892~112.654GHz;112.868~113.025GHz' 

84 --> select the different ranges by frequencies for the spw ids 0 and 1 

85 fitspw='*:113.767~114.528GHz;114.744~115.447GHz' 

86 --> select the same frequency ranges for all the relevant spws 

87 >>> expandable parameter for fitspw 

88 excludechans - if True, it will exclude the spws:channels specified in fitspw 

89 for the fit 

90 default: False (use fitspw for the fit) 

91 example: fitspw='0:114.528GHz~114.744GHz'; excludechans=True 

92 --> exclude the frequency range, 114.528GHz - 114.744GHz in the spw id 0 

93 combine -- Data axes to combine for the continuum estimate. 

94 It must include 'spw' if spw contains spws that are not in 

95 fitspw! 

96 default: '' --> solutions will break at scan, field, and spw 

97 boundaries according to solint 

98 Options: '', 'spw'', 'scan', or 'spw, scan' 

99 example: combine='spw' --> form spw-merged continuum estimate 

100 solint -- Timescale for per-baseline fit (units optional) 

101 default (recommended): 'int' --> no time averaging, do a 

102 fit for each integration and let the 

103 noisy fits average out in the image. 

104  

105 example: solint='10s' --> average to 10s before fitting 

106 10 or '10' --> '10s' (unitless: assumes seconds) 

107 options: 'int' --> per integration 

108 'inf' --> per scan 

109  

110 If solint is longer than 'int', the continuum estimate can be 

111 corrupted by time smearing! 

112  

113 fitorder -- Polynomial order for the fits of the continuum w.r.t. 

114 frequency. fitorders > 1 are strongly discouraged 

115 because high order polynomials have more flexibility, may 

116 absorb line emission, and tend go wild at the edges of 

117 fitspw, which is not what you want. 

118  

119 default: 0 (constant); example: fitorder=1 

120  

121 spw -- Optional per spectral window selection of channels to include 

122 in the output. See the note under combine. 

123  

124 The spectral windows will be renumbered to start from 0, as in 

125 split. 

126 want_cont -- Create vis + '.cont' to hold the continuum estimate. 

127 default: 'False'; example: want_cont=True 

128 The continuum estimate will be placed in vis + '.cont' 

129 

130 

131 """ 

132 

133 _info_group_ = """manipulation""" 

134 _info_desc_ = """Continuum fitting and subtraction in the uv plane""" 

135 

136 def __call__( self, vis='', field='', fitspw='', excludechans=False, combine='', solint='int', fitorder=int(0), spw='', want_cont=False ): 

137 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'field': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'fitspw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'excludechans': {'type': 'cBool'}, 'combine': {'type': 'cStr', 'coerce': _coerce.to_str}, 'solint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'fitorder': {'type': 'cInt'}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'want_cont': {'type': 'cBool'}} 

138 doc = {'vis': vis, 'field': field, 'fitspw': fitspw, 'excludechans': excludechans, 'combine': combine, 'solint': solint, 'fitorder': fitorder, 'spw': spw, 'want_cont': want_cont} 

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

140 _logging_state_ = _start_log( 'uvcontsub_old', [ 'vis=' + repr(_pc.document['vis']), 'field=' + repr(_pc.document['field']), 'fitspw=' + repr(_pc.document['fitspw']), 'excludechans=' + repr(_pc.document['excludechans']), 'combine=' + repr(_pc.document['combine']), 'solint=' + repr(_pc.document['solint']), 'fitorder=' + repr(_pc.document['fitorder']), 'spw=' + repr(_pc.document['spw']), 'want_cont=' + repr(_pc.document['want_cont']) ] ) 

141 task_result = None 

142 try: 

143 task_result = _uvcontsub_old_t( _pc.document['vis'], _pc.document['field'], _pc.document['fitspw'], _pc.document['excludechans'], _pc.document['combine'], _pc.document['solint'], _pc.document['fitorder'], _pc.document['spw'], _pc.document['want_cont'] ) 

144 except Exception as exc: 

145 _except_log('uvcontsub_old', exc) 

146 raise 

147 finally: 

148 task_result = _end_log( _logging_state_, 'uvcontsub_old', task_result ) 

149 return task_result 

150 

151uvcontsub_old = _uvcontsub_old( ) 

152