Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/split.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:10 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:10 +0000
1##################### generated by xml-casa (v2) from split.xml #####################
2##################### 153f85b9b5e0c34f95358068857257ea ##############################
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_split import split as _split_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 _split:
15 """
16 split ---- Create a visibility subset from an existing visibility set
19 Split is the general purpose program to make a new data set that is a
20 subset or averaged form of an existing data set. General selection
21 parameters are included, and one or all of the various data columns
22 (DATA, LAG_DATA and/or FLOAT_DATA, MODEL_DATA and/or CORRECTED_DATA)
23 can be selected.
25 Split is often used after the initial calibration of the data to make
26 a smaller Measurement Set with only the data that will be used in
27 further flagging, imaging and/or self-calibration. Split can average
28 over frequency (channels) and time (integrations).
30 The split task uses the MSTransform framework underneath. Split also
31 supports the Multi-MS (MMS) format as input.
33 --------- parameter descriptions ---------------------------------------------
35 vis Name of input visibility file
36 Default: none
38 Example: vis='ngc5921.ms'
39 outputvis Name of output visibility file
40 Default: '' (same as vis)
42 Example: outputvis='ngc5921_out.ms'
44 IMPORTANT: if a .flagversions file with the name
45 of the output MS exist, this task will exit with
46 an error. The user needs to rename or remove the
47 existing flagbackup or choose a different output
48 name for the MS.
49 keepmms Create a Multi-MS as the output if the input is a
50 Multi-MS.
51 Default: True
52 Options: True|False
54 By default it will create a Multi-MS when the
55 input is a Multi-MS. The output Multi-MS will
56 have the same partition axis of the input
57 MMS. See CASA Docs for more information on
58 the MMS format.
60 NOTE: It is not possible to do time average with
61 combine='scan' if the input MMS was partitioned
62 with separationaxis='scan' or 'auto'. In this
63 case, the task will abort with an error.
64 field Select field using field id(s) or field name(s)
65 Default: '' (all fields)
67 Use 'go listobs' to obtain the list id's or
68 names. If field string is a non-negative integer,
69 it is assumed a field index, otherwise, it is
70 assumed a field name.
72 Examples:
73 field='0~2'; field ids 0,1,2
74 field='0,4,5~7'; field ids 0,4,5,6,7
75 field='3C286,3C295'; field named 3C286 and
76 3C295
77 field = '3,4C\*'; field id 3, all names
78 starting with 4C
79 spw Select spectral window/channels
80 Default: ''=all spectral windows and channels
82 Examples:
83 spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
84 spw='<2'; spectral windows less than 2 (i.e. 0,1)
85 spw='0:5~61'; spw 0, channels 5 to 61
86 spw='0,10,3:3~45'; spw 0,10 all channels, spw
87 3 - chans 3 to 45.
88 spw='0~2:2~6'; spw 0,1,2 with channels 2
89 through 6 in each.
90 spw = '\*:3~64' channels 3 through 64 for all sp id's
91 spw = ' :3~64' will NOT work.
93 NOTE: mstransform does not support multiple
94 channel ranges per spectral window (';').
95 scan Scan number range
96 Subparameter of selectdata=True
97 Default: '' = all
98 antenna Select data based on antenna/baseline
99 Subparameter of selectdata=True
100 Default: '' (all)
102 If antenna string is a non-negative integer, it
103 is assumed an antenna index, otherwise, it is
104 assumed as an antenna name
106 Examples:
107 antenna='5&6'; baseline between antenna
108 index 5 and index 6.
109 antenna='VA05&VA06'; baseline between VLA
110 antenna 5 and 6.
111 antenna='5&6;7&8'; baselines with
112 indices 5-6 and 7-8
113 antenna='5'; all baselines with antenna index
114 5
115 antenna='05'; all baselines with antenna
116 number 05 (VLA old name)
117 antenna='5,6,10'; all baselines with antennas
118 5,6,10 index numbers
119 correlation Select data based on correlation
120 Default: '' ==> all
122 Example: correlation="XX,YY".
123 timerange Select data based on time range
124 Subparameter of selectdata=True
125 Default = '' (all)
127 Examples:
128 timerange =
129 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
130 (Note: if YYYY/MM/DD is missing date defaults
131 to first day in data set.)
132 timerange='09:14:0~09:54:0' picks 40 min on
133 first day
134 timerange= '25:00:00~27:30:00' picks 1 hr to 3
135 hr 30min on NEXT day
136 timerange='09:44:00' pick data within one
137 integration of time
138 timerange='>10:24:00' data after this time
139 intent Select observing intent
140 Default: '' (no selection by intent)
142 Example: intent='*BANDPASS*' (selects data
143 labelled with BANDPASS intent)
144 array (Sub)array number range
145 Default: '' (all)
146 uvrange Select data by baseline length.
147 Default = '' (all)
149 Examples:
150 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda
151 uvrange='>4klambda';uvranges greater than 4 kilo-lambda
152 uvrange='0~1000km'; uvrange in kilometers
153 observation Select by observation ID(s)
154 Subparameter of selectdata=True
155 Default: '' = all
157 Example: observation='0~2,4'
158 feed Selection based on the feed
159 NOT IMPLEMENTED YET!
160 Default: '' = all
161 datacolumn Which data column(s) to use for processing
162 (case-insensitive).
163 Default: 'corrected'
164 Options: 'data', 'model', 'corrected',
165 'all','float_data', 'lag_data',
166 'float_data,data', 'lag_data,data'
168 Example: datacolumn='data'
170 NOTE: 'all' = whichever of the above that are
171 present. If the requested column does not exist,
172 the task will exit with an error.
173 keepflags Keep *completely flagged rows* instead of dropping them.
174 Default: True (keep completely flagged rows in
175 the output)
176 Options: True|False
178 Keepflags has no effect on partially flagged
179 rows. All of the channels and correlations of a
180 row must be flagged for it to be droppable, and a
181 row must be well defined to be keepable.
183 IMPORTANT: Regardless of this parameter, flagged
184 data is never included in channel averaging. On
185 the other hand, partially flagged rows will
186 always be included in time averaging. The average
187 value of the flagged data for averages containing
188 ONLY flagged data in the relevant output channel
189 will be written to the output with the
190 corresponding flag set to True, while only
191 unflagged data is used on averages where there is
192 some unflagged data with the flag set to False.
193 width Number of channels to average to form one output channel
194 If a list is given, each bin will apply to one
195 spw in the selection.
196 Default: 1 (no channel average)
197 Options: (int)|[int]
199 Example: chanbin=[2,3] => average 2 channels
200 of 1st selected spectral window and 3 in the
201 second one.
202 timebin Bin width for time averaging
203 Default: '0s'
205 Bin width for time averaging. When timebin is
206 greater than 0s, the task will average data in
207 time. Flagged data will be included in the
208 average calculation, unless the parameter
209 keepflags is set to False. In this case only
210 partially flagged rows will be used in the
211 average.
212 combine Let the timebin span across scan, state or both.
213 Default: '' (separate time bins by both of the
214 above)
215 Options: 'scan', 'state', 'state,scan'
217 State is equivalent to sub-scans. One scan may
218 have several state ids. For ALMA MSs, the
219 sub-scans are limited to about 30s duration
220 each. In these cases, the task will automatically
221 add state to the combine parameter. To see the
222 number of states in an MS, use the msmd tool. See
223 help msmd.
225 Examples:
227 - combine = 'scan'; can be useful when the scan
228 number goes up with each integration as in
229 many WSRT MSs.
230 - combine = ['scan', 'state']: disregard scan
231 and state numbers when time averaging.
232 - combine = 'state,scan'; same as above.
234 NOTE: It is not possible to do time average with
235 combine='scan' if the input MMS was partitioned
236 with separationaxis='scan' or 'auto'. In this
237 case, the task will abort with an error.
239 --------- examples -----------------------------------------------------------
243 For more information, see the task pages of split in CASA Docs:
245 https://casa.nrao.edu/casadocs/
248 """
250 _info_group_ = """manipulation"""
251 _info_desc_ = """Create a visibility subset from an existing visibility set"""
253 def __call__( self, vis='', outputvis='', keepmms=True, field='', spw='', scan='', antenna='', correlation='', timerange='', intent='', array='', uvrange='', observation='', feed='', datacolumn='corrected', keepflags=True, width=int(1), timebin='0s', combine='' ):
254 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outputvis': {'type': 'cPath', 'coerce': _coerce.expand_path}, 'keepmms': {'type': 'cBool'}, 'field': {'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]}]}, 'spw': {'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]}]}, 'scan': {'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]}]}, 'antenna': {'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]}]}, 'correlation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'timerange': {'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]}]}, '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]}]}, 'array': {'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]}]}, 'uvrange': {'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]}]}, 'observation': {'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]}]}, 'feed': {'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]}]}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'DATA', 'model', 'corrected', 'LAG_DATA', 'lag_data', 'FLOAT_DATA,DATA', 'FLOAT_DATA', 'CORRECTED', 'lag_data,data', 'float_data', 'float_data,data', 'DATA,MODEL,CORRECTED', 'ALL', 'MODEL', 'all', 'data,model,corrected', 'LAG_DATA,DATA', 'data' ]}, 'keepflags': {'type': 'cBool'}, 'width': {'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]}]}, 'timebin': {'type': 'cStr', 'coerce': _coerce.to_str}, 'combine': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}}
255 doc = {'vis': vis, 'outputvis': outputvis, 'keepmms': keepmms, 'field': field, 'spw': spw, 'scan': scan, 'antenna': antenna, 'correlation': correlation, 'timerange': timerange, 'intent': intent, 'array': array, 'uvrange': uvrange, 'observation': observation, 'feed': feed, 'datacolumn': datacolumn, 'keepflags': keepflags, 'width': width, 'timebin': timebin, 'combine': combine}
256 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
257 _logging_state_ = _start_log( 'split', [ 'vis=' + repr(_pc.document['vis']), 'outputvis=' + repr(_pc.document['outputvis']), 'keepmms=' + repr(_pc.document['keepmms']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'scan=' + repr(_pc.document['scan']), 'antenna=' + repr(_pc.document['antenna']), 'correlation=' + repr(_pc.document['correlation']), 'timerange=' + repr(_pc.document['timerange']), 'intent=' + repr(_pc.document['intent']), 'array=' + repr(_pc.document['array']), 'uvrange=' + repr(_pc.document['uvrange']), 'observation=' + repr(_pc.document['observation']), 'feed=' + repr(_pc.document['feed']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'keepflags=' + repr(_pc.document['keepflags']), 'width=' + repr(_pc.document['width']), 'timebin=' + repr(_pc.document['timebin']), 'combine=' + repr(_pc.document['combine']) ] )
258 task_result = None
259 try:
260 task_result = _split_t( _pc.document['vis'], _pc.document['outputvis'], _pc.document['keepmms'], _pc.document['field'], _pc.document['spw'], _pc.document['scan'], _pc.document['antenna'], _pc.document['correlation'], _pc.document['timerange'], _pc.document['intent'], _pc.document['array'], _pc.document['uvrange'], _pc.document['observation'], _pc.document['feed'], _pc.document['datacolumn'], _pc.document['keepflags'], _pc.document['width'], _pc.document['timebin'], _pc.document['combine'] )
261 except Exception as exc:
262 _except_log('split', exc)
263 raise
264 finally:
265 task_result = _end_log( _logging_state_, 'split', task_result )
266 return task_result
268split = _split( )