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 19:53 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
1import os
2import shutil
3import string
4import copy
5import math
7from .mstools import write_history
8from casatools import table, ms, mstransformer
9from casatasks import casalog
10from .parallel.parallel_data_helper import ParallelDataHelper
12_tb = table()
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 ):
31 """Hanning smooth frequency channel data to remove Gibbs ringing
33 """
35 casalog.origin('hanningsmooth')
38 # Initiate the helper class
39 pdh = ParallelDataHelper("hanningsmooth", locals())
41 # Validate input and output parameters
42 pdh.setupIO()
44 # Input vis is an MMS
45 if pdh.isMMSAndNotServer(vis) and keepmms:
47 if not pdh.validateInputParams():
48 raise Exception('Unable to continue with MMS processing')
50 pdh.setupCluster('hanningsmooth')
52 # Execute the jobs
53 pdh.go()
54 return
56 mslocal = ms()
58 # Actual task code starts here
59 try:
60 mtlocal = mstransformer()
62 # Gather all the parameters in a dictionary.
63 config = {}
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)
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()
80 casalog.post('Will use datacolumn = %s'%datacolumn, 'DEBUG')
81 config['datacolumn'] = datacolumn
83 # Call MSTransform framework with hanning=True
84 config['hanning'] = True
86 # Configure the tool
87 casalog.post('%s'%config, 'DEBUG1')
88 mtlocal.config(config)
90 # Open the MS, select the data and configure the output
91 mtlocal.open()
93 # Run the tool
94 casalog.post('Apply Hanning smoothing on data')
95 mtlocal.run()
97 finally:
98 mtlocal.done()
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]
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')
112 mslocal = None