Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/initweights.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 17:39 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 17:39 +0000
1##################### generated by xml-casa (v2) from initweights.xml ###############
2##################### dc4e272a28b720b03ce054150b7b2269 ##############################
3from __future__ import absolute_import
4import numpy
5from casatools.typecheck import CasaValidator as _val_ctor
6_pc = _val_ctor( )
7from casatools.coercetype import coerce as _coerce
8from casatools.errors import create_error_string
9from .private.task_initweights import initweights as _initweights_t
10from casatasks.private.task_logging import start_log as _start_log
11from casatasks.private.task_logging import end_log as _end_log
12from casatasks.private.task_logging import except_log as _except_log
14class _initweights:
15 """
16 initweights ---- Initializes weight information in the MS
18 --------- parameter descriptions ---------------------------------------------
20 vis Name of input visibility file (MS)
21 wtmode Initialization mode
22 tsystable Tsys calibration table to apply on the fly
23 gainfield Select a subset of calibrators from Tsys table
24 interp Interpolation type in time[,freq]. default==\'linear,linear\'
25 spwmap Spectral windows combinations to form for gaintable(s)
26 dowtsp Initialize the WEIGHT_SPECTRUM column
27 [1;42mRETURNS[1;m void
29 --------- examples -----------------------------------------------------------
33 This task provides for initialization of the weight information
34 in the MS. For ALMA interferometry and EVLA data, it should not
35 generally be necessary to use this task, as the per-spectral window
36 weight information should have been initialized properly at
37 fill time (v4.2.2 and later). To set per-channel weights, use
38 initweights(vis=finalvis,wtmode='weight',dowtsp=True)
40 Several initialization modes are supported via the wtmode parameter.
42 If wtmode='nyq' (the default), SIGMA and WEIGHT will be
43 initialized according to bandwidth and integration time. This
44 is the theoretically correct mode for raw normalized visibilities.
45 (e.g., ALMA). For the EVLA, this is correct if switched-power
46 and bandpass calibration will later be applied.
48 If wtmode='sigma', WEIGHT will be initialized according to the
49 existing SIGMA column.
51 If wtmode='weight', WEIGHT_SPECTRUM will be initialized according
52 to the existing WEIGHT column; dowtspec=T must be specified in
53 this case.
55 If wtmode='ones', SIGMA and WEIGHT will be initialized with 1.0,
56 globally. This is a traditional means of initializing weight
57 information, and is adequate when the integration time and
58 bandwidth are uniform. It is not recommended for modern
59 instruments (ALMA, EVLA), where variety in observational setups
60 is common, and properly initialized and calibrated weights
61 will be used for imaging sensitivity estimates.
63 There are two EXPERIMENTAL modes, wtmode='tsys' and 'tinttsys'.
64 In the modes, SIGMA and WEIGHT will be initialized according to
65 Tsys, bandwidth, and integration time (used only in 'tinttsys'),
66 i.e.,
67 tsys : weight=bw/Tsys^2
68 tinttsys: weight=bw*t_int/Tsys^2
69 These modes use Tsys values to calculate weight as is done in
70 Tsys calibration. Tsys values are taken from a tsys calibration
71 table given as tsystable. Selection of gain field (gainfield),
72 interpolation method (interp), and spectral window mapping (spwmap)
73 are supported, too.
74 Available types of interpolation are,
75 Time: 'nearest', 'linear', the variation of those with 'perobs'
76 or 'perscan', e.g., 'linearperobs' (enforce obsId
77 boundaries in interpolation)
78 Freq: 'nearest', 'linear', 'cubic', 'spline', and the variation
79 of those with 'flag', e.g., 'linearflag' (with
80 channelized flag).
81 See the help of applycal for details of interpolations.
82 Note if the weight in an MS is initialized with these modes and
83 Tsys calibration table is applied with calwt=True after that, the
84 weight would be contaminated by being devided by square of Tsys
85 twice.
86 !!! USERS ARE ADVISED TO USE THESE EXPERIMENTAL MODES WITH CARE !!!
88 For the above wtmodes, if dowtsp=T (or if the WEIGHT_SPECTRUM
89 column already exists), the WEIGHT_SPECTRUM column will be
90 initialized (uniformly in channel in wtmode='nyq', 'sigma',
91 'weight', and 'ones'), in a manner consistent with the
92 disposition of the WEIGHT column. If the WEIGHT_SPECTRUM
93 column does not exist, dowtsp=T will force its creation.
94 Use of the WEIGHT_SPECTRUM column is only meaningful
95 for ALMA data which will be calibrated with channelized
96 Tsys information, or if the weights will become channelized
97 after calibration, e.g., via averaging over time- and
98 channel-dependent flagging. (A task for channel-dependent
99 weight estimation from the data itself is also currently under
100 development).
101 In non-channelized modes (wtmode='nyq', 'sigma', 'weight', and
102 'ones') or when dowtsp=F, SIGMA_SPECTRUM column will be removed
103 from MS. On the other hand, SIGMA_SPECTRUM column is added and
104 initialized in channelized modes (wtmode='tsys' and 'tinttsys')
105 if dowtsp=T or WEIGHT_SPECTRUM already column exists.
107 Two additional modes are available for managing the spectral
108 weight info columns; these should be used with extreme care: If
109 wtmode='delwtsp', the WEIGHT_SPECTRUM column will be deleted (if
110 it exists). If wtmode='delsigsp', the SIGMA_SPECTRUM column
111 will be deleted (if it exists). Note that creation of
112 SIGMA_SPECTRUM is not supported via this method.
114 Note that this task does not support any prior selection.
115 Intialization of the weight information must currently be done
116 globally or not at all. This is to maintain consistency.
121 """
123 _info_group_ = """calibration"""
124 _info_desc_ = """Initializes weight information in the MS"""
126 def __call__( self, vis='', wtmode='nyq', tsystable='', gainfield='', interp='', spwmap=[ ], dowtsp=False ):
127 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'wtmode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'delwtsp', 'nyq', 'ones', 'tsys', 'weight', 'tinttsys', 'sigma', 'delsigsp' ]}, 'tsystable': {'type': 'cPath', 'coerce': _coerce.expand_path}, 'gainfield': {'type': 'cStr', 'coerce': _coerce.to_str}, 'interp': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spwmap': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'dowtsp': {'type': 'cBool'}}
128 doc = {'vis': vis, 'wtmode': wtmode, 'tsystable': tsystable, 'gainfield': gainfield, 'interp': interp, 'spwmap': spwmap, 'dowtsp': dowtsp}
129 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
130 _logging_state_ = _start_log( 'initweights', [ 'vis=' + repr(_pc.document['vis']), 'wtmode=' + repr(_pc.document['wtmode']), 'tsystable=' + repr(_pc.document['tsystable']), 'gainfield=' + repr(_pc.document['gainfield']), 'interp=' + repr(_pc.document['interp']), 'spwmap=' + repr(_pc.document['spwmap']), 'dowtsp=' + repr(_pc.document['dowtsp']) ] )
131 task_result = None
132 try:
133 task_result = _initweights_t( _pc.document['vis'], _pc.document['wtmode'], _pc.document['tsystable'], _pc.document['gainfield'], _pc.document['interp'], _pc.document['spwmap'], _pc.document['dowtsp'] )
134 except Exception as exc:
135 _except_log('initweights', exc)
136 raise
137 finally:
138 task_result = _end_log( _logging_state_, 'initweights', task_result )
139 return task_result
141initweights = _initweights( )