Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_clearcal.py: 21%
34 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 18:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 18:48 +0000
1import os
3from casatools import calibrater, table, ms
4from casatasks import casalog
5from .mstools import write_history
6from .parallel.parallel_data_helper import ParallelDataHelper
7from .parallel.parallel_task_helper import ParallelTaskHelper
9def clearcal(
10 vis=None,
11 field=None,
12 spw=None,
13 intent=None,
14 addmodel=None,
15 ):
17 casalog.origin('clearcal')
19 # Do the trivial parallelization
20 if ParallelDataHelper.isMMSAndNotServer(vis):
21 helper = ParallelTaskHelper('clearcal', locals())
22 helper.go()
23 return
25 # Local versions of the tools
26 tblocal = table()
27 cblocal = calibrater()
28 mslocal = ms()
30 # we will initialize scr cols only if we don't create them
31 doinit = False
33 if (type(vis) == str) & os.path.exists(vis):
34 tblocal.open(vis)
35 doinit = tblocal.colnames().count('CORRECTED_DATA') > 0
36 tblocal.close()
38 # We ignore selection if creating the scratch columns
39 if not doinit:
40 casalog.post('Need to create scratch columns; ignoring selection.')
42 cblocal.setvi(old=True,quiet=False); # Old VI for now
43 cblocal.open(vis, addmodel=addmodel)
44 else:
45 raise Exception('Visibility data set not found - please verify the name')
47 # If necessary (scr col not just created), initialize scr cols
48 if doinit:
49 cblocal.selectvis(field=field, spw=spw, intent=intent)
50 cblocal.initcalset(1)
51 cblocal.close()
53 # Write history to the MS
54 local_vars = locals( )
55 param_names = clearcal.__code__.co_varnames[:clearcal.__code__.co_argcount]
56 param_vals = [local_vars[p] for p in param_names]
58 casalog.post('Updating the history in the output', 'DEBUG1')
59 write_history(mslocal, vis, 'clearcal', param_names,
60 param_vals, casalog)