Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/uvcontsub.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
1##################### generated by xml-casa (v2) from uvcontsub.xml #################
2##################### 608b29d7e73cf5fff26de07ecd06eac3 ##############################
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_uvcontsub import uvcontsub as _uvcontsub_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 _uvcontsub:
15 """
16 uvcontsub ---- continuum subtraction in the uv domain
18 --------- parameter descriptions ---------------------------------------------
20 vis Name of input visibility file.
21 Default: '', must be specified
23 Example: vis='ngc5921.ms'
24 outputvis Name of output visibility file
25 Default: '', must be specified
27 Example: outputvis='ngc5921_contsub.ms'
29 If an MS with the output name already exists, it
30 will not be overwritten and the task stops with
31 an error.
32 field Select field using field id(s) or field name(s)
33 Default: '' (all fields)
35 Use 'listobs' to obtain the list of id's or
36 names. If field string is a non-negative integer,
37 it is assumed a field index, otherwise, it is
38 assumed a field name.
40 Examples:
41 field='0~2'; field ids 0,1,2
42 field='0,4,5~7'; field ids 0,4,5,6,7
43 field='3C286,3C295'; field named 3C286 and
44 3C295
45 field = '3,4C*'; field id 3, all names
46 starting with 4C
47 spw Select spectral window/channels
48 Default: '' (meaning all spectral windows and channels)
50 Examples:
51 spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
52 spw='<2'; spectral windows less than 2 (i.e. 0,1)
53 spw='0:5~61'; spw 0, channels 5 to 61
54 spw='0,10,3:3~45'; spw 0,10 all channels, spw
55 3 - chans 3 to 45.
56 spw='0~2:2~6'; spw 0,1,2 with channels 2
57 through 6 in each.
58 spw = '*:3~64' channels 3 through 64 for all sp id's
59 spw = ' :3~64' will NOT work.
60 scan Select scans by scan numbers
61 Default: '' = all
63 Examples:
64 scan='3'
65 scan='2~23'
66 scan=''4,7,9,12'
67 intent Select observing intent
68 Default: '' (no selection by intent)
70 Example: intent='*BANDPASS*' (selects data
71 labelled with BANDPASS intent)
72 array Select (sub)array(s) by array ID number
73 Default: '' (all)
74 observation Select by observation ID(s)
75 Default: '' = all
77 Example: observation='0~2,4'
78 datacolumn Which data column to use for processing
79 (case-insensitive).
80 Default: 'data'
81 Options: 'data', 'model', 'corrected',
82 'float_data', 'lag_data',
84 Example: datacolumn='corrected'
85 fitspec Specification of fit, which can be general or
86 specific for every field and SPW. The continuum will be fitted
87 using a polynomial shape and using as input data points the
88 channels given, which can be considered the line-free
89 channels. fitspec can be a simple string or a dictionary. If
90 it is a simple string, it gives an spw:channel specification in
91 MSSelection syntax, and that same spw:channel specification is
92 used for all fields. In that case, the polynomial order for
93 all fields and SPWs is defined by the fitorder parameter.
95 If it is a dictionary, its entries can define a different
96 specification of fit order and channels for every field and
97 for every SPW. The dictionary can have up to as many entries
98 as fields are present in the MeasurementSet, and within each
99 field entry, as many entries as SPWs are present. Each SPW
100 entry specifies the polynomial order (in a 'fitorder' entry)
101 and the line-free channels (in a 'chan' entry).
103 If a field or SPW is not included, the default is assumed (all
104 channels, and polynomial order given in the global fitorder
105 parameter).
107 Default: '' (all channels for all SPWs for all fields)
108 Examples:
109 '17:100~500;600~910;1215~1678;1810~1903,19:7~100'
110 (The ranges of channels given for SPW 17 and 19
111 are used for all the fields present in the
112 MeasurementSet.)
114 Dictionary to use different channels and polynomial
115 orders for different fields and SPWs, assuming:
116 4 SPWs, with IDs 17, 19, 21, 23
117 6 fields, with IDs 0, 1, 4, 5, 6, 7
118 {'0': {'17,19,21,23': {'chan': '', 'fitorder': 1}},
119 '1': {'17': {'chan': '8~120', 'fitorder': 0},
120 '19': {'chan': '7~100', 'fitorder': 1},
121 '21': {'chan': '21:2~119', 'fitorder': 1},
122 '23': {'chan': '', 'fitorder': 0}},
123 '4,5,6': {'19': {'chan': '7~115', 'fitorder': 1},
124 '21': {'chan': '', 'fitorder': 1},
125 '23': {'chan': '', 'fitorder': 2}},
126 '7': 'NONE'}
128 (Field 0: fit all SPWs and channels (same as not giving it),
129 but using polynomial order 1 for all SPWs.
130 Field 1: fit only some channel ranges (all for SPW 23), with
131 different polynomial orders.
132 Fields 4,5,6: fit only some channel ranges in SPW 19, all
133 channels for SPWs 21 and 23, and don't fit SPWs 17),
134 also using different polynomial orders.
135 Field 7: do not subtract continuum)
136 (The dictionary fields 'chan' can be given in channel
137 numbers, as in the example above, or in frequencies, using
138 the MSSelection syntax)
140 In the example, the empty string given for field 0 and all its
141 SPWs means that all the channels are fitted (and subtracted)
142 in all those SPWs. For the corner case where for a given field
143 no channels should be fitted in any SPW, the field entry can
144 be given as a string set to 'NONE'.
146 This specification of SPWs and channels uses a syntax similar
147 to the spw parameter. But in contrast to the spw parameter,
148 the SPWs and channels given in fitspec are not used to select
149 data but as a mask applied on the input data only for fitting
150 purposes. The channels that are not included in the
151 specification are masked out and not used as input by the
152 polynomial fitting algorithm. This is different from the spw
153 parameter, which selects the data that will be included in the
154 output. All channels present in the output are
155 continuum-subtracted, regardless of whether they were
156 specified as inputs to the fitting in fitspec
157 fitmethod Choose fitting methods
158 Default: 'gsl'
159 Options: 'gsl', 'casacore'
161 Example: fitmethod='gsl'
162 fitorder Polynomial order for the fits
163 Default: 0
165 Values of fitorder > 1 should be used with
166 care. Higher order polynomials are more flexible,
167 and may overfit and absorb line emission. They
168 also tend to go wild at the edges of the range of
169 channels used for fitting.
170 writemodel Write fitted model into the MODEL column of the
171 output MeasurementSet.
173 Default: False
174 Options: True|False
176 By default the task creates an MS with the
177 continuum subtracted data in the DATA column. If
178 this option is enabled, the task will also write
179 the fitted model data into the MODEL column of the
180 output MS.
182 --------- examples -----------------------------------------------------------
185 For more information, see the task pages of uvcontsub in CASA Docs:
186 https://casadocs.readthedocs.io
190 """
192 _info_group_ = """manipulation"""
193 _info_desc_ = """continuum subtraction in the uv domain"""
195 def __call__( self, vis='', outputvis='', field='', spw='', scan='', intent='', array='', observation='', datacolumn='data', fitspec='', fitmethod='gsl', fitorder=int(0), writemodel=False ):
196 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outputvis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'scan': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'array': {'type': 'cStr', 'coerce': _coerce.to_str}, 'observation': {'type': 'cStr', 'coerce': _coerce.to_str}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'DATA', 'model', 'corrected', 'LAG_DATA', 'lag_data', 'FLOAT_DATA', 'CORRECTED', 'float_data', 'MODEL', 'data' ]}, 'fitspec': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cDict'}]}, 'fitmethod': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'gsl', 'casacore', 'GSL', 'CASACORE' ]}, 'fitorder': {'type': 'cInt'}, 'writemodel': {'type': 'cBool'}}
197 doc = {'vis': vis, 'outputvis': outputvis, 'field': field, 'spw': spw, 'scan': scan, 'intent': intent, 'array': array, 'observation': observation, 'datacolumn': datacolumn, 'fitspec': fitspec, 'fitmethod': fitmethod, 'fitorder': fitorder, 'writemodel': writemodel}
198 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
199 _logging_state_ = _start_log( 'uvcontsub', [ 'vis=' + repr(_pc.document['vis']), 'outputvis=' + repr(_pc.document['outputvis']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'scan=' + repr(_pc.document['scan']), 'intent=' + repr(_pc.document['intent']), 'array=' + repr(_pc.document['array']), 'observation=' + repr(_pc.document['observation']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'fitspec=' + repr(_pc.document['fitspec']), 'fitmethod=' + repr(_pc.document['fitmethod']), 'fitorder=' + repr(_pc.document['fitorder']), 'writemodel=' + repr(_pc.document['writemodel']) ] )
200 task_result = None
201 try:
202 task_result = _uvcontsub_t( _pc.document['vis'], _pc.document['outputvis'], _pc.document['field'], _pc.document['spw'], _pc.document['scan'], _pc.document['intent'], _pc.document['array'], _pc.document['observation'], _pc.document['datacolumn'], _pc.document['fitspec'], _pc.document['fitmethod'], _pc.document['fitorder'], _pc.document['writemodel'] )
203 except Exception as exc:
204 _except_log('uvcontsub', exc)
205 raise
206 finally:
207 task_result = _end_log( _logging_state_, 'uvcontsub', task_result )
208 return task_result
210uvcontsub = _uvcontsub( )