Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/imrebin.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 imrebin.xml ###################
2##################### 0184451bd9f27710329ee9eca37ad8be ##############################
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_imrebin import imrebin as _imrebin_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 _imrebin:
15 """
16 imrebin ---- Rebin an image by the specified integer factors
18 --------- parameter descriptions ---------------------------------------------
20 imagename Name of the input image
21 outfile Output image name.
22 factor Binning factors for each axis. Use imhead or ia.summary to determine axis ordering.
23 region Region selection. Default is to use the full image.
24 box Rectangular region 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. Stokes planes cannot be rebinned.
27 mask Mask to use. Default is none.
28 dropdeg Drop degenerate axes?
29 overwrite Overwrite the output if it exists? Default False
30 stretch Stretch the mask if necessary and possible?
31 crop Remove pixels from the end of an axis to be rebinned if there are not enough to form an integral bin?
32 [1;42mRETURNS[1;m bool
34 --------- examples -----------------------------------------------------------
37 PARAMETER SUMMARY
38 imagename Name of the input (CASA, FITS, MIRIAD) image
39 outfile Name of output CASA image. Must be specified.
40 factor Array of binning factors for each axis, eg [2,3]. Use imhead or ia.summary()
41 to determine order of axes in your image.
42 region Region selection. Default is to use the
43 full image.
44 box Rectangular region to select in direction plane. for
45 details. Default is to use the entire direction plane.
46 chans Channels to use. Default is to use all channels.
47 stokes Stokes planes to use. Default is to use all
48 Stokes planes. Stokes planes cannot be rebiined.
49 mask Mask to use. Default is none.
50 dropdeg Drop degenerate axes?
51 overwrite Should the image of the same name as specified in outfile be overwritten?
52 If true, the file if it exists is automatically overwritten.
53 stretch Stretch the input mask if necessary and possible.
54 crop Only considered if the length of the input axis is not an integral multiple of
55 the associated binning factor. If True, pixels at the end of the axis that do not
56 form a complete bin are not included in the binning. If False, the remaining extra
57 pixels are averaged to form the final bin along the axis.
59 DESCRIPTION
61 This application rebins the specified image by the specified integer binning
62 factors for each axis. It supports both float valued and complex valued images.
63 The corresponding output pixel value is the average of the
64 input pixel values. The output pixel will be masked False if there
65 were no good input pixels. A polarization axis cannot be rebinned.
67 The binning factors array must contain at least one element and no more
68 elements than the number of input image axes. If the number of elements
69 specified is less than the number of image axes, then the remaining axes
70 not specified are not rebinned. All specified values must be positive. A
71 value of one indicates that no rebinning of the associated axis will occur.
72 Should this array contain any float values, they will be rounded to the next
73 lowest integer. Note that in many images with both frequency and polarization
74 axes, the polarization axis preceeds the frequency axis. If you wish to rebin
75 the frequency axis, it is recommended that you inspect your image with imhead
76 or ia.summary() to determine the axis ordering.
78 Binning starts from the origin pixel of the bounding box of the selected region or
79 the origin pixel of the input image if no region is specified. The value of crop
80 is used to determine how to handle cases where there are pixels
81 at the end of the axis that do not form a complete bin. If crop=True,
82 extra pixels at the end of the axis are discarded. If crop=False, the remaining
83 pixels are averaged into the final bin along that axis. Should the length
84 of the axis to be rebinned be an integral multiple of the associated binning
85 factor, the value of crop is irrelevant.
87 A value of dropdeg=True will result in the output image not containing
88 axes that are degenerate in the specified region or in the input image if no
89 region is specified. Note that, however, the binning
90 factors array must still account for degenerate axes, and the binning
91 factor associated with a degenerate axis must always be 1.
93 EXAMPLE
95 # rebin the first two axes (normally the direction axes)
96 imrebin(imagename="my.im", outfile="rebinned.im", factor=[2,3])
98 # rebin the frequency axis, which is the fourth axis in this image
99 imrebin(imagename="my2.im", outfile="rebinned2.im", factor=[1,1,1,4])
104 """
106 _info_group_ = """analysis"""
107 _info_desc_ = """Rebin an image by the specified integer factors"""
109 def __call__( self, imagename='', outfile='', factor=[ ], region='', box='', chans='', stokes='', mask='', dropdeg=False, overwrite=False, stretch=False, crop=True ):
110 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'factor': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'region': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, '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}, 'dropdeg': {'type': 'cBool'}, 'overwrite': {'type': 'cBool'}, 'stretch': {'type': 'cBool'}, 'crop': {'type': 'cBool'}}
111 doc = {'imagename': imagename, 'outfile': outfile, 'factor': factor, 'region': region, 'box': box, 'chans': chans, 'stokes': stokes, 'mask': mask, 'dropdeg': dropdeg, 'overwrite': overwrite, 'stretch': stretch, 'crop': crop}
112 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
113 _logging_state_ = _start_log( 'imrebin', [ 'imagename=' + repr(_pc.document['imagename']), 'outfile=' + repr(_pc.document['outfile']), 'factor=' + repr(_pc.document['factor']), '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']), 'dropdeg=' + repr(_pc.document['dropdeg']), 'overwrite=' + repr(_pc.document['overwrite']), 'stretch=' + repr(_pc.document['stretch']), 'crop=' + repr(_pc.document['crop']) ] )
114 task_result = None
115 try:
116 task_result = _imrebin_t( _pc.document['imagename'], _pc.document['outfile'], _pc.document['factor'], _pc.document['region'], _pc.document['box'], _pc.document['chans'], _pc.document['stokes'], _pc.document['mask'], _pc.document['dropdeg'], _pc.document['overwrite'], _pc.document['stretch'], _pc.document['crop'] )
117 except Exception as exc:
118 _except_log('imrebin', exc)
119 raise
120 finally:
121 task_result = _end_log( _logging_state_, 'imrebin', task_result )
122 return task_result
124imrebin = _imrebin( )