Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/imcollapse.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-01 07:19 +0000

1##################### generated by xml-casa (v2) from imcollapse.xml ################ 

2##################### b131fe08644211a85ce28c27c66e74c8 ############################## 

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_imcollapse import imcollapse as _imcollapse_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 

13 

14class _imcollapse: 

15 """ 

16 imcollapse ---- Collapse image along one axis, aggregating pixel values along that axis. 

17 

18  

19 This task collapses an image along a specified axis or set of axes of 

20 N pixels to a single pixel on each specified axis. Both float valued 

21 and complex valued images are supported. It computes the specified 

22 aggregate function for pixel values along the specified axes and 

23 places those values in the single remaining plane of those axes in the 

24 output image. 

25  

26 The reference pixel of the collapsed axis is set to 0 and its 

27 reference value is set to the mean of the the first and last values of 

28 that axis in the specified region of the input image. Convolution to a 

29 common beam is not performed automatically as part of the 

30 preprocessing before the collapse operation occurs. Therefore, if the 

31 input image has per-plane beams, then the user should consider first 

32 smoothing the data to have the same resolution, and use the resulting 

33 image as the input for imcollapse. 

34 

35 --------- parameter descriptions --------------------------------------------- 

36 

37 imagename Name of the input image 

38 Default: none 

39  

40 Example: imagename='ngc5921.im' 

41 function Function used to compute aggregation of pixel values 

42 along the collapsed axis. 

43 Default: none 

44 Options: flux, madm, max, mean, median, min, 

45 npts, rms, stddev, sum, variance, xmadm 

46  

47 Minimum match is supported for the function 

48 parameter (eg, function="r" will compute the rms 

49 of the pixel values). 

50  

51 If one specifies function='flux', the following 

52 constraints must be true: 

53 1. The image must have a direction coordinate, 

54 2. The image must have at least one beam, 

55 3. The specified axes must be exactly the 

56 direction coordinate axes, 

57 4. Only one of the non-directional axes may be 

58 non-degenerate, 

59 5. The iamge brightness unit must be conformant 

60 with x*yJy/beam, where x is an optional unit 

61 (such as km/s for moments images) and y is an 

62 optional SI prefix. 

63 axes Zero-based axis number(s) or minimal match strings to 

64 collapse. 

65 Default: [0] 

66 Axes can be specified as a single integer or 

67 array of integers indicating the zero-based axes 

68 along which to collapse the image. Axes may also 

69 be specified as a single or array of strings 

70 which minimally and uniquely match (ignoring 

71 case) world axes names in the image (eg "dec" or 

72 ["ri, "d"] for collapsing along the declination 

73 axis or along the right ascension and declination 

74 axes, respectively). 

75 outfile Name of output CASA image. Must be specified. 

76 Default: none 

77  

78 Example: outfile='collapsed.im' 

79 box Rectangular region to select in direction plane.  

80 Default: '' (use the entire direction plane) 

81  

82 Example: box="100,100,200,200" 

83 region Region selection. 

84 Default: '' (use the full image) 

85 chans Channels to use.  

86 Default: '' (use all channels) 

87 stokes Stokes planes to use. 

88 Default: '' (use all stokes planes) 

89 mask Mask to use. 

90 Default: none 

91 overwrite Overwrite output image if it exists? 

92 Default: False 

93 Options: False|True 

94 stretch Stretch the mask if necessary and possible?  

95 Default: False 

96 Options: False|True 

97  

98 Stretch the input mask if necessary and 

99 possible. Only used if a mask is specified. 

100 RETURNS bool 

101 

102 --------- examples ----------------------------------------------------------- 

103 

104  

105 FOR MORE INFORMATION, SEE THE TASK PAGES OF IMCOLLAPSE IN CASA DOCS: 

106 https://casa.nrao.edu/casadocs/ 

107 

108 

109 """ 

110 

111 _info_group_ = """analysis""" 

112 _info_desc_ = """Collapse image along one axis, aggregating pixel values along that axis.""" 

113 

114 def __call__( self, imagename='', function='', axes=[ ], outfile='', box='', region='', chans='', stokes='', mask='', overwrite=False, stretch=False ): 

115 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'function': {'type': 'cStr', 'coerce': _coerce.to_str}, 'axes': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'box': {'type': 'cStr', 'coerce': _coerce.to_str}, 'region': {'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}, 'overwrite': {'type': 'cBool'}, 'stretch': {'type': 'cBool'}} 

116 doc = {'imagename': imagename, 'function': function, 'axes': axes, 'outfile': outfile, 'box': box, 'region': region, 'chans': chans, 'stokes': stokes, 'mask': mask, 'overwrite': overwrite, 'stretch': stretch} 

117 assert _pc.validate(doc,schema), create_error_string(_pc.errors) 

118 _logging_state_ = _start_log( 'imcollapse', [ 'imagename=' + repr(_pc.document['imagename']), 'function=' + repr(_pc.document['function']), 'axes=' + repr(_pc.document['axes']), 'outfile=' + repr(_pc.document['outfile']), 'box=' + repr(_pc.document['box']), 'region=' + repr(_pc.document['region']), 'chans=' + repr(_pc.document['chans']), 'stokes=' + repr(_pc.document['stokes']), 'mask=' + repr(_pc.document['mask']), 'overwrite=' + repr(_pc.document['overwrite']), 'stretch=' + repr(_pc.document['stretch']) ] ) 

119 task_result = None 

120 try: 

121 task_result = _imcollapse_t( _pc.document['imagename'], _pc.document['function'], _pc.document['axes'], _pc.document['outfile'], _pc.document['box'], _pc.document['region'], _pc.document['chans'], _pc.document['stokes'], _pc.document['mask'], _pc.document['overwrite'], _pc.document['stretch'] ) 

122 except Exception as exc: 

123 _except_log('imcollapse', exc) 

124 raise 

125 finally: 

126 task_result = _end_log( _logging_state_, 'imcollapse', task_result ) 

127 return task_result 

128 

129imcollapse = _imcollapse( ) 

130