Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/visstat.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 visstat.xml ###################
2##################### c86ed6b951fe8f7d2801da8c7294893f ##############################
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_visstat import visstat as _visstat_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 _visstat:
15 """
16 visstat ---- Calculates statistical information from a MeasurementSet
18 --------- parameter descriptions ---------------------------------------------
20 vis Name of MeasurementSet or Multi-MS
21 axis Values on which to compute statistics
22 datacolumn Which data column to use (data, corrected, model, float_data)
23 useflags Take flagging into account?
24 spw spectral-window/frequency/channel
25 field Field names or field index numbers: \'\'==>all, field=\'0~2,3C286\'
26 selectdata More data selection parameters (antenna, timerange etc)
27 antenna antenna/baselines: \'\'==>all, antenna = \'3,VA04\'
28 uvrange uv range: \'\'==>all; uvrange = \'0~100klambda\', default units=meters
29 timerange time range: \'\'==>all, timerange=\'09:14:0~09:54:0\'
30 correlation Select data based on correlation
31 scan scan numbers: \'\'==>all
32 array (sub)array numbers: \'\'==>all
33 observation observation ID number(s): \'\' = all
34 timeaverage Average data in time.
35 timebin Bin width for time averaging.
36 timespan Span the timebin across scan, state or both.
37 maxuvwdistance Maximum separation of start-to-end baselines that can be included in an average. (meters)
38 disableparallel Hidden parameter for internal use only. Do not change it!
39 ddistart Hidden parameter for internal use only. Do not change it!
40 taql Table query for nested selections
41 monolithic_processing Hidden parameter for internal use only. Do not change it!
42 intent Select data by scan intent.
43 reportingaxes Which reporting axis to use (ddid, field, integration)
44 doquantiles If False, quantile-like statistics are not computed. These include the first and third quartiles, the median, and the median of the absolute deviation from the median.
45 [1;42mRETURNS[1;m record
47 --------- examples -----------------------------------------------------------
51 This task returns statistical information about data in a MeasurementSet
52 or Multi-MS.
54 The following statistics are computed: mean value, sum of values, sum of
55 squared values, median, median absolute deviation, first and third
56 quartiles, minimum, maximum, variance, standard deviation, and root mean
57 square.
59 Statistics may be computed on any of the following values: flag, antenna1,
60 antenna2, feed1, feed2, field_id, array_id, data_desc_id, flag_row,
61 interval, scan_number, time, weight_spectrum, amplitude, phase, real,
62 imaginary, and uvrange (for the 'axis' parameter value, 'amp' is treated
63 as an alias for amplitude, as are 'imag' for imaginary, and 'scan' for
64 scan_number.)
66 The 'reportingaxes' argument is used to partition the sample set along an
67 axis. For example, setting its value to 'ddid' will result in the
68 statistics of the chosen sample values partitioned by unique values of the
69 data description id. Thus setting 'axis' to 'amp' and 'reportingaxes' to
70 'ddid' will report statistics of visibility amplitudes for each unique
71 value of data description id in the MeasurementSet.
73 Optionally, the statistical information can be computed based only
74 on a given subset of the MeasurementSet.
76 Note: If the MS consists of inhomogeneous data, for example several
77 spectral windows each having a different number of channels, it may be
78 necessary to use selection parameters to select a homogeneous subset of
79 the MS, e.g. spw='2'.
81 Keyword arguments:
83 vis --- Name of input MeasurementSet or Multi-MS
84 default: '', example: vis='my.ms'
86 axis -- Which data to analyze.
88 default: 'amplitude'
89 axis='phase'
90 axis='imag'
91 axis='scan_number'
92 axis='flag'
94 The phase of a complex number is in radians in the range [-pi; pi].
97 datacolumn -- Which data column to use for complex data.
98 default: 'data'
99 datacolumn='data'
100 datacolumn='corrected'
101 datacolumn='model'
102 datacolumn='float_data'
104 useflags -- Take MS flags into account?
105 default: True
106 useflags=False
107 useflags=True
108 If useflags=False, flagged values are included in the statistics.
109 If useflags=True, any flagged values are not used in the statistics.
111 spw -- Select data based on spectral window and channels
112 default: '' (all); example: spw='1'
113 spw='<2' #spectral windows less than 2
114 spw='>1' #spectral windows greater than 1
115 spw='0:0~10' # first 10 channels from spw 0
116 spw='0:0~5;56~60' # multiple separated channel chunks.
118 field -- Select data based on field id(s) or name(s)
119 default: '' (all); example: field='1'
120 field='0~2' # field ids inclusive from 0 to 2
121 field='3C*' # all field names starting with 3C
123 selectdata -- Other data selection parameters
124 default: True
125 antenna -- Select data based on baseline
126 default: '' (all); example: antenna='5&6' baseline 5-6
127 antenna='5&6;7&8' #baseline 5-6 and 7-8
128 antenna='5' # all baselines with antenna 5
129 antenna='5,6' # all baselines with antennas 5 and 6
130 correlation -- Correlation types
131 default: '' (all);
132 example: correlation='RR LL'
133 uvrange -- Select data within uvrange (default units meters)
134 default: '' (all); example:
135 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda
136 uvrange='>4klambda';uvranges greater than 4 kilo-lambda
137 uvrange='0~1000km'; uvrange in kilometers
138 timerange -- Select data based on time range:
139 default = '' (all); example,
140 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
141 Note: YYYY/MM/DD can be dropped as needed:
142 timerange='09:14:0~09:54:0' # this time range
143 timerange='09:44:00' # data within one integration of time
144 timerange='>10:24:00' # data after this time
145 timerange='09:44:00+00:13:00' #data 13 minutes after time
146 scan -- Select data based on scan number
147 default: '' (all); example: scan='>3'
148 array -- Selection based on the antenna array
149 observation -- Selection by observation ID(s).
150 default: '' (all); example: observation='1~3'
155 --- Time averaging parameters ---
156 timeaverage -- Average data in time. Flagged data will be included in the
157 average calculation, unless the parameter useflags is set to True. In this
158 case only partially flagged rows will be used in the average.
159 default: False
161 timebin -- Bin width for time averaging.
162 default: '0s'
164 timespan -- Let the timebin span across scan, state or both.
165 State is equivalent to sub-scans. One scan may have several
166 state ids. For ALMA MSs, the sub-scans are limited to about
167 30s duration each. In these cases, the task will automatically
168 add state to the timespan parameter. To see the number of states
169 in an MS, use the msmd tool. See help msmd.
171 default: '' (separate time bins by both of the above)
172 options: 'scan', 'state', 'state,scan'
174 examples:
175 timespan = 'scan'; can be useful when the scan number
176 goes up with each integration as in many WSRT MSs.
177 timespan = ['scan', 'state']: disregard scan and state
178 numbers when time averaging.
179 timespan = 'state,scan'; same as above.
181 maxuvwdistance -- Provide a maximum separation of start-to-end baselines
182 that can be included in an average. (int)
183 default: 0.0 (given in meters)
194 """
196 _info_group_ = """information"""
197 _info_desc_ = """Calculates statistical information from a MeasurementSet"""
199 def __call__( self, vis='', axis='amplitude', datacolumn='data', useflags=True, spw='', field='', selectdata=True, antenna='', uvrange='', timerange='', correlation='', scan='', array='', observation='', timeaverage=False, timebin='0s', timespan='', maxuvwdistance=float(0.0), disableparallel=False, ddistart=int(-1), taql='', monolithic_processing=False, intent='', reportingaxes='ddid', doquantiles=True ):
200 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'axis': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'data_desc_id', 'field_id', 'flag', 'imaginary', 'feed1', 'flag_row', 'interval', 'imag', 'phase', 'array_id', 'amp', 'real', 'antenna2', 'weight_spectrum', 'scan_number', 'amplitude', 'uvrange', 'antenna1', 'feed2', 'time', 'scan' ]}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'data', 'corrected', 'model', 'float_data' ]}, 'useflags': {'type': 'cBool'}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'selectdata': {'type': 'cBool'}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'uvrange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'timerange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'correlation': {'type': 'cStr', 'coerce': _coerce.to_str}, 'scan': {'type': 'cStr', 'coerce': _coerce.to_str}, 'array': {'type': 'cStr', 'coerce': _coerce.to_str}, 'observation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}]}, 'timeaverage': {'type': 'cBool'}, 'timebin': {'type': 'cStr', 'coerce': _coerce.to_str}, 'timespan': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'maxuvwdistance': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'disableparallel': {'type': 'cBool'}, 'ddistart': {'type': 'cInt'}, 'taql': {'type': 'cStr', 'coerce': _coerce.to_str}, 'monolithic_processing': {'type': 'cBool'}, 'intent': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'reportingaxes': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'ddid', 'field', 'integration' ]}, 'doquantiles': {'type': 'cBool'}}
201 doc = {'vis': vis, 'axis': axis, 'datacolumn': datacolumn, 'useflags': useflags, 'spw': spw, 'field': field, 'selectdata': selectdata, 'antenna': antenna, 'uvrange': uvrange, 'timerange': timerange, 'correlation': correlation, 'scan': scan, 'array': array, 'observation': observation, 'timeaverage': timeaverage, 'timebin': timebin, 'timespan': timespan, 'maxuvwdistance': maxuvwdistance, 'disableparallel': disableparallel, 'ddistart': ddistart, 'taql': taql, 'monolithic_processing': monolithic_processing, 'intent': intent, 'reportingaxes': reportingaxes, 'doquantiles': doquantiles}
202 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
203 _logging_state_ = _start_log( 'visstat', [ 'vis=' + repr(_pc.document['vis']), 'axis=' + repr(_pc.document['axis']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'useflags=' + repr(_pc.document['useflags']), 'spw=' + repr(_pc.document['spw']), 'field=' + repr(_pc.document['field']), 'selectdata=' + repr(_pc.document['selectdata']), 'antenna=' + repr(_pc.document['antenna']), 'uvrange=' + repr(_pc.document['uvrange']), 'timerange=' + repr(_pc.document['timerange']), 'correlation=' + repr(_pc.document['correlation']), 'scan=' + repr(_pc.document['scan']), 'array=' + repr(_pc.document['array']), 'observation=' + repr(_pc.document['observation']), 'timeaverage=' + repr(_pc.document['timeaverage']), 'timebin=' + repr(_pc.document['timebin']), 'timespan=' + repr(_pc.document['timespan']), 'maxuvwdistance=' + repr(_pc.document['maxuvwdistance']), 'disableparallel=' + repr(_pc.document['disableparallel']), 'ddistart=' + repr(_pc.document['ddistart']), 'taql=' + repr(_pc.document['taql']), 'monolithic_processing=' + repr(_pc.document['monolithic_processing']), 'intent=' + repr(_pc.document['intent']), 'reportingaxes=' + repr(_pc.document['reportingaxes']), 'doquantiles=' + repr(_pc.document['doquantiles']) ] )
204 task_result = None
205 try:
206 task_result = _visstat_t( _pc.document['vis'], _pc.document['axis'], _pc.document['datacolumn'], _pc.document['useflags'], _pc.document['spw'], _pc.document['field'], _pc.document['selectdata'], _pc.document['antenna'], _pc.document['uvrange'], _pc.document['timerange'], _pc.document['correlation'], _pc.document['scan'], _pc.document['array'], _pc.document['observation'], _pc.document['timeaverage'], _pc.document['timebin'], _pc.document['timespan'], _pc.document['maxuvwdistance'], _pc.document['disableparallel'], _pc.document['ddistart'], _pc.document['taql'], _pc.document['monolithic_processing'], _pc.document['intent'], _pc.document['reportingaxes'], _pc.document['doquantiles'] )
207 except Exception as exc:
208 _except_log('visstat', exc)
209 raise
210 finally:
211 task_result = _end_log( _logging_state_, 'visstat', task_result )
212 return task_result
214visstat = _visstat( )