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

27 statements  

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

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

2##################### 654512321d5d13c05a750e2f99cd3d0c ############################## 

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_hanningsmooth import hanningsmooth as _hanningsmooth_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 _hanningsmooth: 

15 """ 

16 hanningsmooth ---- Hanning smooth frequency channel data to remove Gibbs ringing 

17 

18  

19 The hanningsmooth task uses the MSTransform framework underneath but 

20 keeps roughly the same interface as the old hanningsmooth task. 

21  

22 This function Hanning smooths the frequency channels with a weighted 

23 running average. The weights are 0.5 for the central channel and 0.25 

24 for each of the two adjacent channels. The first and last channels are 

25 flagged. Inclusion of a flagged value in an average causes that data 

26 value to be flagged. 

27  

28 If the 'CORRECTED' data column is requested for an MS that does not 

29 contain this column, it will use 'DATA' to calculate the smoothing and 

30 save it to 'DATA' in the output MS. 

31  

32 WARNING: by default, all visibility columns will be smoothed. 

33 

34 --------- parameter descriptions --------------------------------------------- 

35 

36 vis Name of input visibility file 

37 Default: none 

38  

39 Example: vis='ngc5921.ms' 

40 outputvis Name of output visibility file 

41 Default: '' (same as vis) 

42  

43 Example: outputvis='ngc5921_out.ms' 

44 keepmms Create a Multi-MS as the output if the input is a 

45 Multi-MS. 

46  

47 Default: True 

48 Options: True|False 

49  

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

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

52 have the same partition axis of the input 

53 MMS. See CASA Docs for more information on 

54 the MMS format. 

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

56 Default: '' (all fields) 

57  

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

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

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

61 assumed a field name. 

62  

63 Examples: 

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

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

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

67 3C295 

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

69 starting with 4C 

70 spw Select spectral window/channels 

71 Default: ''=all spectral windows and channels 

72  

73 Examples: 

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

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

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

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

78 3 - chans 3 to 45. 

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

80 through 6 in each. 

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

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

83  

84 NOTE: mstransform does not support multiple 

85 channel ranges per spectral window (';'). 

86 scan Scan number range 

87 Subparameter of selectdata=True 

88 Default: '' = all 

89 antenna Select data based on antenna/baseline 

90 Subparameter of selectdata=True 

91 Default: '' (all) 

92  

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

94 is assumed an antenna index, otherwise, it is 

95 assumed as an antenna name 

96  

97 Examples:  

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

99 index 5 and index 6. 

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

101 antenna 5 and 6. 

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

103 indices 5-6 and 7-8 

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

105 5 

106 antenna='05'; all baselines with antenna 

107 number 05 (VLA old name) 

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

109 5,6,10 index numbers 

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

111 except those that include EVLA antennas 

112 ea03, ea12, or ea17. 

113 correlation Select data based on correlation 

114 Default: '' ==> all 

115  

116 Example: correlation="XX,YY". 

117 timerange Select data based on time range 

118 Subparameter of selectdata=True 

119 Default = '' (all) 

120  

121 Examples: 

122 timerange = 

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

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

125 to first day in data set.) 

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

127 first day  

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

129 hr 30min on NEXT day 

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

131 integration of time 

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

133 intent Select observing intent 

134 Default: '' (no selection by intent) 

135  

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

137 labelled with BANDPASS intent) 

138 array (Sub)array number range 

139 Default: '' (all) 

140 uvrange Select data by baseline length. 

141 Default = '' (all) 

142  

143 Examples: 

144 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 

145 uvrange='>4klambda';uvranges greater than 4 kilo-lambda 

146 uvrange='0~1000km'; uvrange in kilometers 

147 observation Select by observation ID(s) 

148 Subparameter of selectdata=True 

149 Default: '' = all 

150  

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

152 feed Selection based on the feed  

153 NOT IMPLEMENTED YET! 

154 Default: '' = all 

155 datacolumn Which data column(s) to use for processing 

156 (case-insensitive). 

157 Default: 'all' (= whichever of the options that 

158 are present) 

159 Options: 'data', 'model', 'corrected', 

160 'all','float_data', 'lag_data', 

161 'float_data,data', 'lag_data,data' 

162  

163 Example: datacolumn='data' 

164 

165 --------- examples ----------------------------------------------------------- 

166 

167  

168 FOR MORE INFORMATION, SEE THE TASK PAGES OF HANNINGSMOOTH IN CASA DOCS: 

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

170  

171 

172 

173 """ 

174 

175 _info_group_ = """manipulation""" 

176 _info_desc_ = """Hanning smooth frequency channel data to remove Gibbs ringing""" 

177 

178 def __call__( self, vis='', outputvis='', keepmms=True, field='', spw='', scan='', antenna='', correlation='', timerange='', intent='', array='', uvrange='', observation='', feed='', datacolumn='all' ): 

179 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outputvis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'keepmms': {'type': 'cBool'}, 'field': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'spw': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'scan': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'antenna': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'correlation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'timerange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'intent': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'array': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'uvrange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'observation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'feed': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'DATA', 'model', 'corrected', 'LAG_DATA', 'lag_data', 'FLOAT_DATA,DATA', 'FLOAT_DATA', 'CORRECTED', 'lag_data,data', 'float_data', 'float_data,data', 'DATA,MODEL,CORRECTED', 'ALL', 'MODEL', 'all', 'data,model,corrected', 'LAG_DATA,DATA', 'data' ]}} 

180 doc = {'vis': vis, 'outputvis': outputvis, 'keepmms': keepmms, 'field': field, 'spw': spw, 'scan': scan, 'antenna': antenna, 'correlation': correlation, 'timerange': timerange, 'intent': intent, 'array': array, 'uvrange': uvrange, 'observation': observation, 'feed': feed, 'datacolumn': datacolumn} 

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

182 _logging_state_ = _start_log( 'hanningsmooth', [ 'vis=' + repr(_pc.document['vis']), 'outputvis=' + repr(_pc.document['outputvis']), 'keepmms=' + repr(_pc.document['keepmms']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'scan=' + repr(_pc.document['scan']), 'antenna=' + repr(_pc.document['antenna']), 'correlation=' + repr(_pc.document['correlation']), 'timerange=' + repr(_pc.document['timerange']), 'intent=' + repr(_pc.document['intent']), 'array=' + repr(_pc.document['array']), 'uvrange=' + repr(_pc.document['uvrange']), 'observation=' + repr(_pc.document['observation']), 'feed=' + repr(_pc.document['feed']), 'datacolumn=' + repr(_pc.document['datacolumn']) ] ) 

183 task_result = None 

184 try: 

185 task_result = _hanningsmooth_t( _pc.document['vis'], _pc.document['outputvis'], _pc.document['keepmms'], _pc.document['field'], _pc.document['spw'], _pc.document['scan'], _pc.document['antenna'], _pc.document['correlation'], _pc.document['timerange'], _pc.document['intent'], _pc.document['array'], _pc.document['uvrange'], _pc.document['observation'], _pc.document['feed'], _pc.document['datacolumn'] ) 

186 except Exception as exc: 

187 _except_log('hanningsmooth', exc) 

188 raise 

189 finally: 

190 task_result = _end_log( _logging_state_, 'hanningsmooth', task_result ) 

191 return task_result 

192 

193hanningsmooth = _hanningsmooth( ) 

194