Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/imtrans.py: 100%
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 imtrans.xml ###################
2##################### 30ff8089f93306fba45c8fab1f49a731 ##############################
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_imtrans import imtrans as _imtrans_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 _imtrans:
15 """
16 imtrans ---- Reorder image axes
18 --------- parameter descriptions ---------------------------------------------
20 imagename Name of the input image which must be specified.
21 outfile Name of output CASA image.
22 order New zero-based axes order.
23 [1;42mRETURNS[1;m bool
25 --------- examples -----------------------------------------------------------
28 PARAMETER SUMMARY
29 imagename Name of the input image
30 outfile Name of output CASA image. Must be specified.
31 order Output axes mapping
33 This task reorders (transposes) the axes in the input image to the specified
34 order. The associated pixel values and coordinate system are transposed.
36 The order parameter describes the mapping of the input axes to the output axes.
37 It can be one of three types: a non-negative integer, a string, or a list of
38 strings. If a string or non-negative integer, it should contain
39 zero-based digits describing the new order of the input axes. It must
40 contain the same number of (unique) digits as the number of input axes. For example,
41 specifying order="1032" or order=1032 for a four axes image maps input axes
42 1, 0, 3, 2 to output axes 0, 1, 2, 3. In the case of order being a nonnegative integer
43 and the zeroth axis in the input being mapped to zeroth axis in the output, the zeroth
44 digit is implicitly understood to be 0 so that to transpose an image where one would
45 use a string order="0321", one could equivalently specify an int order=321.
46 IMPORTANT: When specifying a non-negative integer and mapping the zeroth axis of
47 the input to the zeroth axis of the output, do *not* explicitly specify the leading
48 0; eg, specify order=321 rather than order=0321. Python interprets an integer with
49 a leading 0 as an octal number.
51 Because of ambiguity for axes numbers greater than nine, using string or integer order
52 specifications cannot handle images containing more than 10 axes.
53 The order parameter can also be specified as a list of strings which uniquely match,
54 ignoring case, the first characters of the image axis names (ia.coordsys().names()).
55 So to reorder an image with right ascension, declination, and frequency axes, one could
56 specify order=["d", "f", "r"] or equivalently ["decl", "frequ", "right a"]. Note that
57 specifying "ra" for the right ascension axis will result in an error because "ra" does
58 not match the first two characters of "right ascension".
59 Axes can be simultaneously inverted in cases where order is a string or an array of
60 strings by specifying negative signs in front of the axis/axes to be inverted. So,
61 in a 4-D image, order="-10-3-2" maps input axes 1, 0, 3, 2 to output axes 0, 1, 2, 3
62 and reverses the direction and values of input axes 1, 3, and 2.
63 EXAMPLE:
64 # Swap the stokes and spectral axes in an RA-Dec-Stokes-Frequency image
65 imagename = "myim.im"
66 outfile = "outim.im"
67 order = "0132"
68 imtrans()
70 # or
72 outfile = "myim_2.im"
73 order = 132
74 imtrans()
76 # or
78 outfile = "myim_3.im"
79 order = ["r", "d", "f", "s"]
80 imtrans()
82 # or
84 utfile = "myim_4.im"
85 order = ["rig", "declin", "frequ", "stok"]
86 imtrans()
89 """
91 _info_group_ = """analysis"""
92 _info_desc_ = """Reorder image axes"""
94 def __call__( self, imagename='', outfile='', order='' ):
95 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'order': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}}
96 doc = {'imagename': imagename, 'outfile': outfile, 'order': order}
97 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
98 _logging_state_ = _start_log( 'imtrans', [ 'imagename=' + repr(_pc.document['imagename']), 'outfile=' + repr(_pc.document['outfile']), 'order=' + repr(_pc.document['order']) ] )
99 task_result = None
100 try:
101 task_result = _imtrans_t( _pc.document['imagename'], _pc.document['outfile'], _pc.document['order'] )
102 except Exception as exc:
103 _except_log('imtrans', exc)
104 raise
105 finally:
106 task_result = _end_log( _logging_state_, 'imtrans', task_result )
107 return task_result
109imtrans = _imtrans( )