Coverage for /home/casatest/venv/lib/python3.12/site-packages/casatasks/phaseshift.py: 56%
27 statements
« prev ^ index » next coverage.py v7.10.4, created at 2025-08-21 07:43 +0000
« prev ^ index » next coverage.py v7.10.4, created at 2025-08-21 07:43 +0000
1##################### generated by xml-casa (v2) from phaseshift.xml ################
2##################### be1991bbcde10a2e6d9bb46ac807ccf2 ##############################
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_phaseshift import phaseshift as _phaseshift_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 _phaseshift:
15 """
16 phaseshift ---- Rotate a Measurement Set to a new phase-center
19 This application changes the phase center of a selected subset of an input MS, by taking into
20 account the full 3D geometry in the UVW plane (similar to the phasecenter setting in the
21 imaging tasks). This function produces an output MS with modified UVW values, visibility
22 phases, and a new phase_direction entry in the FIELD sub-table.
25 --------- parameter descriptions ---------------------------------------------
27 vis Name of input visibility file
28 Default: none, must be specified
30 Example: vis='ngc5921.ms'
31 outputvis Name of output visibility file
32 Default: None, must be specified
34 Example: outputvis='ngc5921_out.ms'
35 keepmms Create a Multi-MS as the output if the input is a
36 Multi-MS.
38 Default: True
39 Options: True|False
41 By default it will create a Multi-MS when the
42 input is a Multi-MS. The output Multi-MS will
43 have the same partition axis of the input
44 MMS. See CASA Docs for more information on
45 the MMS format.
46 field Select field using field id(s) or field name(s)
47 Default: '' (all fields)
49 Use 'listobs' to obtain the list id's or
50 names. If field string is a non-negative integer,
51 it is assumed a field index, otherwise, it is
52 assumed a field name.
54 Examples:
55 field='0~2'; field ids 0,1,2
56 field='0,4,5~7'; field ids 0,4,5,6,7
57 field='3C286,3C295'; field named 3C286 and
58 3C295
59 field = '3,4C\*'; field id 3, all names
60 starting with 4C
61 spw Select spectral window/channels
62 Default: ''=all spectral windows and channels
64 Examples:
65 spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
66 spw='<2'; spectral windows less than 2 (i.e. 0,1)
67 spw='0:5~61'; spw 0, channels 5 to 61
68 spw='0,10,3:3~45'; spw 0,10 all channels, spw
69 3 - chans 3 to 45.
70 spw='0~2:2~6'; spw 0,1,2 with channels 2
71 through 6 in each.
72 spw = '\*:3~64' channels 3 through 64 for all sp id's
73 spw = ' :3~64' will NOT work.
74 scan Scan number range
75 Default: '' = all
76 intent Select observing intent
77 Default: '' (no selection by intent)
79 Example: intent='*BANDPASS*' (selects data
80 labelled with BANDPASS intent)
81 array (Sub)array number range
82 Default: '' (all)
83 observation Select by observation ID(s)
84 Default: '' = all
86 Example: observation='0~2,4'
87 datacolumn Which data column(s) to process
88 (case-insensitive).
89 Default: 'all' (= whichever of the options that
90 are present)
91 Options: 'data', 'model', 'corrected',
92 'all','float_data', 'lag_data',
93 'float_data,data', 'lag_data,data'
95 Example: datacolumn='data'
96 phasecenter Direction coordinates of new phase center. It can be given as a
97 string or as a dictionary of phase center strings per field.
99 The phase center values must be specified as absolute world coordinates
100 including frame, e.g.:
102 phasecenter = 'J2000 19h53m50 40d06m00'
103 phasecenter = 'B1950 292.5deg -40.0deg'
104 phasecenter = 'ICRS 13:05:27.2780 -049.28.04.458'
105 phasecenter = 'GALACTIC 47.5rad -60.22rad'
106 phasecenter = '19h53m50 40d06m00' # implicitly J2000 (default if not specified)
108 Time dependent systems (eg, AZEL) are not supported, nor are ephemeris objects.
109 Note that the reference frame can be omitted in the phasecenter string, in which case a
110 default frame J2000 is used.
112 When phasecenter is given as a dictionary, the keys are field indices and the
113 values are the phase center strings for the respective fields. For example:
115 phasecenter = {"3": 'ICRS 13:05:27.2780 -049.28.04.458',
116 "5": 'J2000 19h53m50 40d06m00',
117 "6": 'J2000 19h54m52 30d09m10',
118 }
120 When phasecenter is a single string, the phase shifting operation will be done
121 for all selected fields using the same output phase center, so all fields in the
122 output MeasurementSet will have as center the specified direction.
124 When phasecenter is a dictionary, the output phase center can be specified
125 separately for every field. If one or more input fields are not present in the
126 dictionary they will be included in the output unmodified. A subset of the fields
127 from the input MeasurementSet can be selected using the field parameter.
129 Phaseshift changes the phase of the baseline visibilities so that the final image
130 is centered at the specified direction. Additionally the uvw coordinates and the
131 PHASE_DIR column from the FIELD sub-table will be changed accordingly.
133 The new phase center is not constrained to be located inside any images to be
134 created.
136 --------- examples -----------------------------------------------------------
141 """
143 _info_group_ = """manipulation"""
144 _info_desc_ = """Rotate a Measurement Set to a new phase-center"""
146 def __call__( self, vis='', outputvis='', keepmms=True, field='', spw='', scan='', intent='', array='', observation='', datacolumn='all', phasecenter='' ):
147 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outputvis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'keepmms': {'type': 'cBool'}, '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,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' ]}, 'phasecenter': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cDict'}]}}
148 doc = {'vis': vis, 'outputvis': outputvis, 'keepmms': keepmms, 'field': field, 'spw': spw, 'scan': scan, 'intent': intent, 'array': array, 'observation': observation, 'datacolumn': datacolumn, 'phasecenter': phasecenter}
149 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
150 _logging_state_ = _start_log( 'phaseshift', [ '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']), 'intent=' + repr(_pc.document['intent']), 'array=' + repr(_pc.document['array']), 'observation=' + repr(_pc.document['observation']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'phasecenter=' + repr(_pc.document['phasecenter']) ] )
151 task_result = None
152 try:
153 task_result = _phaseshift_t( _pc.document['vis'], _pc.document['outputvis'], _pc.document['keepmms'], _pc.document['field'], _pc.document['spw'], _pc.document['scan'], _pc.document['intent'], _pc.document['array'], _pc.document['observation'], _pc.document['datacolumn'], _pc.document['phasecenter'] )
154 except Exception as exc:
155 _except_log('phaseshift', exc)
156 raise
157 finally:
158 task_result = _end_log( _logging_state_, 'phaseshift', task_result )
159 return task_result
161phaseshift = _phaseshift( )