Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_cvel2.py: 92%
64 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 07:19 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 07:19 +0000
2import os
3import shutil
5from casatools import mstransformer as mttool
6from casatools import ms as mstool
7from casatools import table as tbtool
8from casatasks import casalog
9from .parallel.parallel_data_helper import ParallelDataHelper
10from .mstools import write_history
12def cvel2(
13 vis,
14 outputvis,
15 keepmms,
16 passall, # hidden parameter for backwards compatibiliy
17 field,
18 spw,
19 scan,
20 antenna,
21 correlation,
22 timerange,
23 intent,
24 array,
25 uvrange,
26 observation,
27 feed,
28 datacolumn,
29 mode,
30 nchan,
31 start,
32 width,
33 interpolation,
34 phasecenter,
35 restfreq,
36 outframe,
37 veltype,
38 hanning,
39 ):
41 """ This task used the MSTransform framework. It needs to use the ParallelDataHelper
42 class, implemented in parallel.parallel_data_helper.py.
43 """
45 assert outputvis != '', "Must provide output data set name in parameter outputvis."
46 assert not os.path.exists(outputvis), "Output MS %s already exists - will not overwrite." % outputvis
47 assert not os.path.exists(outputvis+".flagversions"), \
48 "The flagversions \"%s.flagversions\" for the output MS already exist. Please delete." % outputvis
50 # Initialize the helper class
51 pdh = ParallelDataHelper("cvel2", locals())
53 casalog.origin('cvel2')
55 # Validate input and output parameters
56 pdh.setupIO()
58 # Input vis is an MMS
59 if pdh.isMMSAndNotServer(vis) and keepmms:
61 # Work the heuristics of combinespws=True and the separationaxis of the input
62 retval = pdh.validateInputParams()
63 if not retval['status']:
64 raise RuntimeError('Unable to continue with MMS processing')
66 pdh.setupCluster('cvel2')
68 # Execute the jobs
69 pdh.go()
70 return
73 try:
74 mtlocal = mttool()
75 # Gather all the parameters in a dictionary.
76 config = {}
78 config = pdh.setupParameters(inputms=vis, outputms=outputvis, field=field,
79 spw=spw, array=array, scan=scan, antenna=antenna, correlation=correlation,
80 uvrange=uvrange,timerange=timerange, intent=intent, observation=observation,
81 feed=feed)
83 config['datacolumn'] = datacolumn
84 casalog.post('Will work on datacolumn = %s'%datacolumn.upper())
86 # In cvel the spws are always combined
87 config['combinespws'] = True
89 # Hanning smoothing
90 config['hanning'] = hanning
92 # Set the regridms parameter in mstransform
93 config['regridms'] = True
95 if passall == True:
96 casalog.post('Parameter passall=True is not supported in cvel2','WARN')
98 # Reset the defaults depending on the mode
99 # Only add non-empty string parameters to config dictionary
100 start, width = pdh.defaultRegridParams()
101 config['mode'] = mode
102 config['nchan'] = nchan
103 if start != '':
104 config['start'] = start
105 if width != '':
106 config['width'] = width
108 config['interpolation'] = interpolation
109 if restfreq != '':
110 config['restfreq'] = restfreq
111 if outframe != '':
112 config['outframe'] = outframe
113 if phasecenter != '':
114 config['phasecenter'] = phasecenter
115 config['veltype'] = veltype
116 config['nspw'] = 1
117 config['taql'] = "NOT (FLAG_ROW OR ALL(FLAG))"
119 # Configure the tool and all the parameters
120 casalog.post('%s'%config, 'DEBUG')
121 mtlocal.config(config)
123 # Open the MS, select the data and configure the output
124 mtlocal.open()
126 # Run the tool
127 mtlocal.run()
129 finally:
130 mtlocal.done()
132 # Write history to output MS, not the input ms.
133 try:
134 mslocal = mstool()
135 param_names = cvel2.__code__.co_varnames[:cvel2.__code__.co_argcount]
136 local_vars = locals( )
137 param_vals = [local_vars[p] for p in param_names]
139 write_history(mslocal, outputvis, 'cvel2', param_names,
140 param_vals, casalog)
141 except Exception as instance:
142 casalog.post("*** Error \'%s\' updating HISTORY" % (instance),'WARN')
144 mslocal = None