Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/immoments.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 immoments.xml #################
2##################### 71135811d8080ad40de603edf0247328 ##############################
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_immoments import immoments as _immoments_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 _immoments:
15 """
16 immoments ---- Compute moments from an image
18 --------- parameter descriptions ---------------------------------------------
20 imagename Name of the input image
21 moments List of moments you would like to compute
22 axis The momement axis: ra, dec, lat, long, spectral, or stokes
23 region Region selection. Default is to use the full image.
24 box Rectangular region(s) to select in direction plane. Default is to use the entire direction plane.
25 chans Channels to use. Default is to use all channels.
26 stokes Stokes planes to use. Default is to use all Stokes planes.
27 mask Mask to use. Default is none.
28 includepix Range of pixel values to include
29 excludepix Range of pixel values to exclude
30 outfile Output image file name (or root for multiple moments)
31 stretch Stretch the mask if necessary and possible?
32 [1;42mRETURNS[1;m bool
34 --------- examples -----------------------------------------------------------
37 The spectral moment distributions at each pixel are
38 determined. See the cookbook and User Reference Manual for
39 mathematical details.
41 The main control of the calculation is given by parameter
42 moments:
44 moments=-1 - mean value of the spectrum
45 moments=0 - integrated value of the spectrum
46 moments=1 - intensity weighted coordinate;traditionally used to get
47 'velocity fields'
48 moments=2 - intensity weighted dispersion of the coordinate; traditionally
49 used to get "velocity dispersion"
50 moments=3 - median of I
51 moments=4 - median coordinate
52 moments=5 - standard deviation about the mean of the spectrum
53 moments=6 - root mean square of the spectrum
54 moments=7 - absolute mean deviation of the spectrum
55 moments=8 - maximum value of the spectrum
56 moments=9 - coordinate of the maximum value of the spectrum
57 moments=10 - minimum value of the spectrum
58 moments=11 - coordinate of the minimum value of the spectrum
60 Keyword arguments:
61 imagename Name of input image
62 default: none; example: imagename="ngc5921_task.image"
63 moments List of moments you would like to compute
64 default: 0 (integrated spectrum);example: moments=[0,1]
65 see list above
66 axis The moment axis
67 default: (spectral axis); example: axis=spec
68 options: ra, dec, lattitude, longitude, spectral, stokes
69 mask Mask to use. Default is none.
70 stretch Stretch the input mask if necessary and possible. See below.
71 region Region selection. Default
72 is to use the full image.
73 box Rectangular region to select in direction plane. See
74 Default is to use the entire direction plane.
75 Example: box="10,10,50,50"
76 box = "10,10,30,30,35,35,50,50" (two boxes)
77 chans Channels to use. Default is to use
78 all channels.
80 stokes Stokes planes to use. Default is to
81 use all Stokes planes.
82 Example: stokes="IQUV";
83 Example:stokes="I,Q"
84 includepix Range of pixel values to include
85 default: [-1] (all pixels); example=[0.02,100.0]
86 excludepix Range of pixel values to exclude
87 default: [-1] (don"t exclude pixels); example=[100.,200.]
88 outfile Output image file name (or root for multiple moments)
89 default: "" (input+auto-determined suffix);example: outfile="source_moment"
91 If stretch is true and if the number of mask dimensions is less than
92 or equal to the number of image dimensions and some axes in the
93 mask are degenerate while the corresponding axes in the image are not,
94 the mask will be stetched in the degenerate axis dimensions. For example,
95 if the input image has shape [100, 200, 10] and the input
96 mask has shape [100, 200, 1] and stretch is true, the mask will be
97 stretched along the third dimension to shape [100, 200, 10]. However if
98 the mask is shape [100, 200, 2], stretching is not possible and an
99 error will result.
101 Example for finding the 1-momment, intensity-weighted
102 coordinate, often used for finding velocity fields.
103 immoments( axis="spec", imagename="myimage", moment=1, outfile="velocityfields" )
105 Example finding the spectral mean, -1 moment, on a specified region
106 of the image as defined by the box and stokes parameters
107 taskname="immoments"
108 default()
109 imagename = "myimage"
110 moment = -1
112 axis = "spec"
113 stokes = "I"
114 box = [55,12,97,32]
115 go
117 Example using a mask created with a second file to select the
118 data used to calculate the 0-moments, integrated values. In
119 this case the mask is from the calibrated.im file and all values
120 that have a value greater than 0.5 will be positive in the mask..
121 immoments( "clean.image", axis="spec", mask="calibrated.im>0.5", outfile="mom_withmask.im" )
123 If an image has multiple (per-channel beams) and the moment axis is equal to the
124 spectral axis, each channel will be convolved with a beam that is equal to the beam
125 having the largest area in the beamset prior to moment determination.
128 """
130 _info_group_ = """analysis"""
131 _info_desc_ = """Compute moments from an image"""
133 def __call__( self, imagename='', moments=[ int(0) ], axis='spectral', region='', box='', chans='', stokes='', mask='', includepix=int(-1), excludepix=int(-1), outfile='', stretch=False ):
134 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'moments': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'axis': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}]}, 'region': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'box': {'type': 'cStr', 'coerce': _coerce.to_str}, 'chans': {'type': 'cStr', 'coerce': _coerce.to_str}, 'stokes': {'type': 'cStr', 'coerce': _coerce.to_str}, 'mask': {'type': 'cStr', 'coerce': _coerce.to_str}, 'includepix': {'anyof': [{'type': 'cInt'}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'excludepix': {'anyof': [{'type': 'cInt'}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'stretch': {'type': 'cBool'}}
135 doc = {'imagename': imagename, 'moments': moments, 'axis': axis, 'region': region, 'box': box, 'chans': chans, 'stokes': stokes, 'mask': mask, 'includepix': includepix, 'excludepix': excludepix, 'outfile': outfile, 'stretch': stretch}
136 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
137 _logging_state_ = _start_log( 'immoments', [ 'imagename=' + repr(_pc.document['imagename']), 'moments=' + repr(_pc.document['moments']), 'axis=' + repr(_pc.document['axis']), 'region=' + repr(_pc.document['region']), 'box=' + repr(_pc.document['box']), 'chans=' + repr(_pc.document['chans']), 'stokes=' + repr(_pc.document['stokes']), 'mask=' + repr(_pc.document['mask']), 'includepix=' + repr(_pc.document['includepix']), 'excludepix=' + repr(_pc.document['excludepix']), 'outfile=' + repr(_pc.document['outfile']), 'stretch=' + repr(_pc.document['stretch']) ] )
138 task_result = None
139 try:
140 task_result = _immoments_t( _pc.document['imagename'], _pc.document['moments'], _pc.document['axis'], _pc.document['region'], _pc.document['box'], _pc.document['chans'], _pc.document['stokes'], _pc.document['mask'], _pc.document['includepix'], _pc.document['excludepix'], _pc.document['outfile'], _pc.document['stretch'] )
141 except Exception as exc:
142 _except_log('immoments', exc)
143 raise
144 finally:
145 task_result = _end_log( _logging_state_, 'immoments', task_result )
146 return task_result
148immoments = _immoments( )