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

50 statements  

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

1import os 

2import shutil 

3import string 

4import copy 

5import math 

6 

7from .mstools import write_history 

8from casatools import table, ms, mstransformer 

9from casatasks import casalog 

10from .parallel.parallel_data_helper import ParallelDataHelper 

11 

12_tb = table() 

13 

14def hanningsmooth(vis=None, 

15 outputvis=None, 

16 keepmms=None, 

17 field=None, 

18 spw=None, 

19 scan=None, 

20 antenna=None, 

21 correlation=None, 

22 timerange=None, 

23 intent=None, 

24 array=None, 

25 uvrange=None, 

26 observation=None, 

27 feed=None, 

28 datacolumn=None, 

29 ): 

30 

31 """Hanning smooth frequency channel data to remove Gibbs ringing 

32 

33 """ 

34 

35 casalog.origin('hanningsmooth') 

36 

37 

38 # Initiate the helper class  

39 pdh = ParallelDataHelper("hanningsmooth", locals()) 

40 

41 # Validate input and output parameters 

42 pdh.setupIO() 

43 

44 # Input vis is an MMS 

45 if pdh.isMMSAndNotServer(vis) and keepmms: 

46 

47 if not pdh.validateInputParams(): 

48 raise Exception('Unable to continue with MMS processing') 

49 

50 pdh.setupCluster('hanningsmooth') 

51 

52 # Execute the jobs 

53 pdh.go() 

54 return 

55 

56 mslocal = ms() 

57 

58 # Actual task code starts here 

59 try: 

60 mtlocal = mstransformer() 

61 

62 # Gather all the parameters in a dictionary.  

63 config = {} 

64 

65 config = pdh.setupParameters(inputms=vis, outputms=outputvis, field=field, 

66 spw=spw, array=array, scan=scan, antenna=antenna, correlation=correlation, 

67 uvrange=uvrange,timerange=timerange, intent=intent, observation=observation, 

68 feed=feed) 

69 

70 

71 # Check if CORRECTED column exists, when requested 

72 datacolumn = datacolumn.upper() 

73 if datacolumn == 'CORRECTED': 

74 _tb.open(vis) 

75 if 'CORRECTED_DATA' not in _tb.colnames(): 

76 casalog.post('Input CORRECTED_DATA does not exist. Will use DATA','WARN') 

77 datacolumn = 'DATA' 

78 _tb.close() 

79 

80 casalog.post('Will use datacolumn = %s'%datacolumn, 'DEBUG') 

81 config['datacolumn'] = datacolumn 

82 

83 # Call MSTransform framework with hanning=True 

84 config['hanning'] = True 

85 

86 # Configure the tool  

87 casalog.post('%s'%config, 'DEBUG1') 

88 mtlocal.config(config) 

89 

90 # Open the MS, select the data and configure the output 

91 mtlocal.open() 

92 

93 # Run the tool 

94 casalog.post('Apply Hanning smoothing on data') 

95 mtlocal.run() 

96 

97 finally: 

98 mtlocal.done() 

99 

100 # Write history to output MS, not the input ms. 

101 try: 

102 param_names = hanningsmooth.__code__.co_varnames[:hanningsmooth.__code__.co_argcount] 

103 local_vars = locals() 

104 param_vals = [local_vars[p] for p in param_names] 

105 

106 casalog.post('Updating the history in the output', 'DEBUG1') 

107 write_history(mslocal, outputvis, 'hanningsmooth', param_names, 

108 param_vals, casalog) 

109 except Exception as instance: 

110 casalog.post("*** Error \'%s\' updating HISTORY" % (instance),'WARN') 

111 

112 mslocal = None 

113 

114