Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_initweights.py: 16%
44 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, ms
4from casatasks import casalog
6from .mstools import write_history
7from .parallel.parallel_data_helper import ParallelDataHelper
8from .parallel.parallel_task_helper import ParallelTaskHelper
10def initweights(vis=None,wtmode=None,tsystable=None,gainfield=None,interp=None,spwmap=None,dowtsp=None):
12 casalog.origin('initweights')
14 # Do the trivial parallelization
15 if ParallelTaskHelper.isMPIEnabled() and ParallelDataHelper.isMMSAndNotServer(vis):
16 tsystable = ParallelTaskHelper.findAbsPath(tsystable)
17 helper = ParallelTaskHelper('initweights', locals())
18 helper.go()
19 # Write history to MS.
20 try:
21 param_names = initweights.__code__.co_varnames[:initweights.__code__.co_argcount]
22 vars = locals( )
23 param_vals = [vars[p] for p in param_names]
25 casalog.post('Updating the history in the output', 'DEBUG1')
26 write_history(ms, vis, 'initweights', param_names,
27 param_vals, casalog)
28 except Exception as instance:
29 casalog.post("*** Error \'%s\' updating HISTORY" % (instance),
30 'WARN')
32 return
35 #Python script
36 mycb=calibrater()
38 # only if vis exists...
39 if ((type(vis)==str) & (os.path.exists(vis))):
40 if wtmode.upper().find("TSYS") > -1:
41 if not os.path.exists(tsystable):
42 raise Exception('Tsys calibration table %s not found' % tsystable)
43 if len(spwmap)==0:
44 spwmap=[-1]
45 if interp=="":
46 interp="linear"
47 # ... and we are asked to do something...
48 # open without adding anything!
49 mycb.open(vis,compress=False,addcorr=False,addmodel=False)
50 mycb.initweights(wtmode=wtmode,dowtsp=dowtsp,tsystable=tsystable,gainfield=gainfield,interp=interp,spwmap=spwmap)
51 mycb.close()
52 else:
53 raise ValueError('Visibility data set not found - please verify the name')
55 # Write history to MS.
56 # When running in parallel, history will be written in the parallel section above
57 # normal MSs should write the history here
58 if ParallelTaskHelper.isMPIClient():
59 myms=ms()
60 try:
61 param_names = initweights.__code__.co_varnames[:initweights.__code__.co_argcount]
62 vars = locals()
63 param_vals = [vars[p] for p in param_names]
65 casalog.post('Updating the history in the output', 'DEBUG1')
66 write_history(myms, vis, 'initweights', param_names,
67 param_vals, casalog)
68 except Exception as instance:
69 casalog.post("*** Error \'%s\' updating HISTORY" % instance,'WARN')