Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/msuvbin.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 07:19 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 07:19 +0000
1##################### generated by xml-casa (v2) from msuvbin.xml ###################
2##################### 1b0767ff69d778776ecf7ddce14ced3c ##############################
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_msuvbin import msuvbin as _msuvbin_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 _msuvbin:
15 """
16 msuvbin ---- grid the visibility data onto a defined uniform grid (in the form of an ms); multiple MS's can be done onto the same grid
19 msuvbin is a uv gridding task. The use is for large volumes
20 of data (from multiple epochs) that needs to be imaged into
21 one image. One way of proceeding is to image the epochs and
22 average them after wards. Rather than doing this averaging
23 the visibilities on a common uv grid has several convenience
24 advantages like easily doing the proper weighted averaging and imaging.
25 If an output grid already exists and a second ms is gridded on the grid
26 then the output grid parameters is ignored but the existant grid is used.
30 --------- parameter descriptions ---------------------------------------------
32 vis Name of input visibility file (MS)
33 default: none;
34 field Field selection of input ms; use mssel syntax
35 spw Spw selection; mssel syntax
36 taql TaQl string for data selection; the advance user can do
37 sophisticated data selection; see http://casacore.github.io/casacore-notes/199.html
38 outputvis name of output uvgrid; if it existant the data will be binned additively into
39 that uvgrid (as long as the parameters match for the grid description). If the gridded ms
40 exists
41 and the gridding parameters do not match the ones with which the grid was made---
42 msuvbin will exit with an exception
43 phasecenter phase center of uv grid; if empty it will default
44 the first field selected in the input ms
45 imsize Number of pixels
46 example:
48 imsize = [350,250]
49 imsize = 500 is equivalent to [500,500]
51 To take proper advantage of internal optimized FFT routines, the
52 number of pixels must be even and factorizable by 2,3,5 only.
53 To find the nearest optimal imsize to that desired by the user, please use the following tool method:
55 from casatools import synthesisutils
56 su = synthesisutils()
57 su.getOptimumSize(345)
58 Output : 360
59 cell pixel cell size defined in sky dimension
60 This should be in the units of sky angle. Usually you want to have a pixel size that
61 is smaller than the maximum resolution that can be expected from the data.
62 ncorr number of correlations to store in grid
63 if 1 is chosen and data have cross hands, then both XX and YY (or RR and LL)
64 will be gridded on the same correlation plane (XX or RR as MS V2.0 does not support
65 I as a correlation type).
66 if 2 is chosen the parallel hands will be stored on independent grids for each frequency channel
67 if 4 is chosen the all correlation type will be gridded independently.
68 nchan Nunmber of spectral channels in the output grid
69 start Frequency of first channel of grid. If left empty, it will try to use the
70 lowest frequency in the selected data
71 width Spectral channel width. If left empty the badwidth of the selected data will be divided by the nchan
72 selected to determine the width of an output channel. This happens only when not output grid already exists.
73 wproject Do wprojection correction while gridding. This should be used with care as it is known to have issues like perfomance
74 and for Cotton-Schwab style cleaning.
75 memfrac Limit fraction of RAM available to use. Default is half.
76 mode when mode will transfer back flag from grid to input ms
77 For this to work both the original ms and the gridded ms has to exist and the flags will be
78 transferred from the gridded ms back to original ms. This is provided as a utility to
79 msuvbinflagger task.
80 flagbackup Backup flags before saving flags when using write_flags_back
81 [1;42mRETURNS[1;m void
83 --------- examples -----------------------------------------------------------
90 Keyword arguments:
91 vis -- Name of input visibility file
92 default: none; example: vis='ngc5921.ms'
93 field -- Field name list
94 default: '' ==> all
95 field = '1328+307' specifies source '1328+307'
96 field = '4' specified field with index 4
97 spw -- Spw selection
98 default: spw = '' (all spw)
99 spw='2'
100 taql --TaQl expression for data selection (see https://casacore.github.io/casacore-notes/199.html)
101 default taql=''
102 Example select all data where U > 1 m in the ms
103 taql='UVW[0] > 1'
104 outputvis -- name of output grid
105 default: '' The user has to give something here
106 phasecenter -- phasecenter of the grid
107 default= ''
108 phasecenter='J2000 18h03m04 -20d00m45.1'
109 imsize -- number of pixels along the x and y axes of the grid
110 default=100
111 imsize=[1000, 1000]
112 cell -- cellsize of the grid (given in sky units)
113 default: '1arcsec'
114 cell='0.1arcsec'
115 ncorr -- number of correlation/polarization plane in uv grid (allowed 1, 2, 4)
116 default: 1
117 ncorr=4
118 nchan -- number of spectral channel
119 default: 1
120 nchan=2000
121 start -- frequency of the first channel
122 default: ''; User has to give something useful here
123 width -- spectral channel width
124 default: ''
125 wproject -- do wprojection correction while gridding
126 default: False
127 wproject=True
128 memfrac -- control how much of computer's memory is available for gridding
129 default=0.5
130 memfrac=0.9
135 """
137 _info_group_ = """manipulation, imaging"""
138 _info_desc_ = """grid the visibility data onto a defined uniform grid (in the form of an ms); multiple MS\'s can be done onto the same grid"""
140 def __call__( self, vis='', field='', spw='', taql='', outputvis='', phasecenter='', imsize=[ int(100) ], cell='1arcsec', ncorr=int(1), nchan=int(1), start='', width='', wproject=False, memfrac=float(0.5), mode='bin', flagbackup=False ):
141 schema = {'vis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'taql': {'type': 'cStr', 'coerce': _coerce.to_str}, 'outputvis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'phasecenter': {'type': 'cStr', 'coerce': _coerce.to_str}, 'imsize': {'anyof': [{'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'cell': {'type': 'cStr', 'coerce': _coerce.to_str}, 'ncorr': {'type': 'cInt', 'allowed': [ 1, 2, 4 ]}, 'nchan': {'type': 'cInt'}, 'start': {'type': 'cStr', 'coerce': _coerce.to_str}, 'width': {'type': 'cStr', 'coerce': _coerce.to_str}, 'wproject': {'type': 'cBool' # <allowed> IS NOT ALLOWED FOR A PARAMETER OF TYPE bool
142}, 'memfrac': {'type': 'cFloat', 'coerce': _coerce.to_float, 'min': 0.01, 'max': 0.99}, 'mode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'bin', 'write_flags_back' ]}, 'flagbackup': {'type': 'cBool'}}
143 doc = {'vis': vis, 'field': field, 'spw': spw, 'taql': taql, 'outputvis': outputvis, 'phasecenter': phasecenter, 'imsize': imsize, 'cell': cell, 'ncorr': ncorr, 'nchan': nchan, 'start': start, 'width': width, 'wproject': wproject, 'memfrac': memfrac, 'mode': mode, 'flagbackup': flagbackup}
144 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
145 _logging_state_ = _start_log( 'msuvbin', [ 'vis=' + repr(_pc.document['vis']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'taql=' + repr(_pc.document['taql']), 'outputvis=' + repr(_pc.document['outputvis']), 'phasecenter=' + repr(_pc.document['phasecenter']), 'imsize=' + repr(_pc.document['imsize']), 'cell=' + repr(_pc.document['cell']), 'ncorr=' + repr(_pc.document['ncorr']), 'nchan=' + repr(_pc.document['nchan']), 'start=' + repr(_pc.document['start']), 'width=' + repr(_pc.document['width']), 'wproject=' + repr(_pc.document['wproject']), 'memfrac=' + repr(_pc.document['memfrac']), 'mode=' + repr(_pc.document['mode']), 'flagbackup=' + repr(_pc.document['flagbackup']) ] )
146 task_result = None
147 try:
148 task_result = _msuvbin_t( _pc.document['vis'], _pc.document['field'], _pc.document['spw'], _pc.document['taql'], _pc.document['outputvis'], _pc.document['phasecenter'], _pc.document['imsize'], _pc.document['cell'], _pc.document['ncorr'], _pc.document['nchan'], _pc.document['start'], _pc.document['width'], _pc.document['wproject'], _pc.document['memfrac'], _pc.document['mode'], _pc.document['flagbackup'] )
149 except Exception as exc:
150 _except_log('msuvbin', exc)
151 raise
152 finally:
153 task_result = _end_log( _logging_state_, 'msuvbin', task_result )
154 return task_result
156msuvbin = _msuvbin( )