Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_statwt.py: 77%
43 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
3from casatools import ms
4from casatasks import casalog
5from . import flaghelper
6from .mstools import write_history
8def statwt(
9 vis, selectdata, field, spw, intent, array, observation, scan,
10 combine, timebin, slidetimebin, chanbin, minsamp, statalg,
11 fence, center, lside, zscore, maxiter, fitspw, excludechans,
12 wtrange, flagbackup, preview, datacolumn
13):
14 casalog.origin('statwt')
15 if not selectdata:
16 # CAS-10761, requirement provided by Urvashi
17 if field or spw or intent or array or observation:
18 casalog.post(
19 "selectdata=False, any explicitly set data "
20 + "selection parameters will be ignored",
21 "WARN"
22 )
23 field = ""
24 spw = ""
25 intent = ""
26 array = ""
27 observation = ""
28 scan = ""
29 try:
30 if (flagbackup):
31 if (preview):
32 casalog.post(
33 "Running in preview mode. No flags will be "
34 + "modified, so existing flags will not be backed up."
35 )
36 else:
37 casalog.post('Backup original flags before applying new flags')
38 flaghelper.backupFlags(aflocal=None, msfile=vis, prename='statwt')
39 myms = ms( )
40 myms.open(vis, nomodify=preview)
41 sel = {}
42 sel['spw'] = spw
43 #sel['time'] = timerange
44 sel['field'] = field
45 #sel['baseline'] = antenna
46 sel['scan'] = scan
47 sel['scanintent'] = intent
48 #sel['polarization'] = correlation
49 #sel['uvdist'] = uvrange
50 sel['observation'] = str(observation)
51 sel['array'] = array
52 #sel['feed'] = feed
53 # Select the data. Only-parse is set to false.
54 myms.msselect(sel, False)
55 rval = None
56 rval = myms.statwt(
57 combine=combine, timebin=timebin,
58 slidetimebin=slidetimebin, chanbin=chanbin,
59 minsamp=minsamp, statalg=statalg, fence=fence,
60 center=center, lside=lside, zscore=zscore,
61 maxiter=maxiter, fitspw=fitspw, excludechans=excludechans,
62 wtrange=wtrange, preview=preview, datacolumn=datacolumn
63 )
64 # Write to HISTORY of MS
65 if rval != None and not preview:
66 try:
67 # Write history to MS
68 local_vars = locals( )
69 param_names = statwt.__code__.co_varnames[:statwt.__code__.co_argcount]
70 param_vals = [local_vars[p] for p in param_names]
71 write_history(
72 ms(), vis, 'statwt', param_names, param_vals, casalog
73 )
74 except Exception as instance:
75 casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN')
77 return rval
79 finally:
80 myms.done()