Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/imhead.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 18:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 18:48 +0000
1##################### generated by xml-casa (v2) from imhead.xml ####################
2##################### ec19dbdd3c2dd6df7f47f3edfab28dfd ##############################
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_imhead import imhead as _imhead_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 _imhead:
15 """
16 imhead ---- List, get and put image header parameters
19 List, get and put image header parameters.
21 This task allows the user to manipulate metadata associated with a
22 CASA image. Both float and complex valued images are fully supported.
24 For measurement sets, the task vishead should be used.
26 --------- parameter descriptions ---------------------------------------------
28 imagename Input image cube.
29 Default: none
31 Example: imagename='ngc5921_task.image'
32 mode Mode of operation.
33 Default: summary
34 Options: "add", "del", "get", "history", "list",
35 "put", or "summary".
37 * add: Add a new metadata value to the image. The
38 behavior of mode="add" depends on the
39 keyword. In general, the return value will be
40 True if the operation succeeds, or False if it
41 fails or is not supported. If unsuccessful or
42 not supported, a message is normally logged
43 which describes the failure. In most cases, you
44 probably want to use mode='put' rather than
45 mode='add'. We continue to support mode='add'
46 mainly for backward compatibility.
47 * del: Delete a key or reset its value to a
48 fidicual value if possible. Ignores all but
49 imagename, mode, and hdkey parameters. In
50 general, the return value will be True if the
51 operation succeeds, or False if it fails or is
52 not supported. If unsuccessful or not
53 supported, a warning message is normally logged
54 which describes the failure.
55 * get: Return the specified keyword
56 value. Ignores all but imagename, mode, and
57 hdkey parameters.
58 * history: Log image history. Ignores all but
59 imagename and mode parameters.
60 * list: Show supported keywords and their
61 values. Ignores all but imagename and mode
62 parameters.
63 * put: Modify the specified value associated with
64 the keyword. True is returned if the metadatum
65 was successfully modified, False
66 otherwise. Normally, a diagnostic message is
67 logged if there is a failure. Only the
68 parameter specified is modified; eg, no
69 modification of reference direction occurs to
70 implicitly account for precession to a new
71 reference frame.
72 * summary: Log a summary of the image and return
73 a dictionary of various metadata
74 values. Ignores all but imagename and mode
75 parameters.
77 IMPORTANT: Lists of keywords for the various
78 modes of operation are given in the imhead task
79 pages of CASA Docs
80 (https://casa.nrao.edu/casadocs/).
82 The behavior of mode='add|del|get depends on the
83 keyword. Modes "add", "del", and "put" will not
84 work if the image is read-only (eg a FITS
85 image).
87 NOTE: Only limited checking is implemented to
88 ensure modifying a specific value will leave the
89 image metadata in a consistent state, so, if one
90 is not careful, one could end up with an image
91 that has an inconsistent set of metadata and is
92 therefore, nonsensical and useless That is,
93 PROCEED AT YOUR OWN RISK when using modes add,
94 del, or put.
95 hdkey Keyword to use with get, put, add, or del.
96 Subparameter of mode=get|put|add|del
98 Only "get" will work if the image is read-only
99 (eg, a FITS image).
101 Example: hdkey='telescope'
102 hdvalue Keyword value used for modes 'put' and 'add'.
103 Subparameter of mode='put|add' ('del')
105 Also used for mode="del" when hdvalue="masks.
107 Example: hdvalue='VLA'
108 verbose Give a full listing of beams or just a short summary? Only used when the image has multiple beams and mode="summary".
109 [1;42mRETURNS[1;m variant
111 --------- examples -----------------------------------------------------------
114 FOR MORE INFORMATION, SEE THE TASK PAGES OF IMHEAD IN CASA DOCS:
115 https://casa.nrao.edu/casadocs/
118 """
120 _info_group_ = """information, analysis, manipulation"""
121 _info_desc_ = """List, get and put image header parameters"""
123 def __call__( self, imagename='', mode='summary', hdkey='', hdvalue='', verbose=False ):
124 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'mode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'add', 'put', 'history', 'get', 'summary', 'list', 'del' ]}, 'hdkey': {'type': 'cStr', 'coerce': _coerce.to_str}, 'hdvalue': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'verbose': {'type': 'cBool'}}
125 doc = {'imagename': imagename, 'mode': mode, 'hdkey': hdkey, 'hdvalue': hdvalue, 'verbose': verbose}
126 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
127 _logging_state_ = _start_log( 'imhead', [ 'imagename=' + repr(_pc.document['imagename']), 'mode=' + repr(_pc.document['mode']), 'hdkey=' + repr(_pc.document['hdkey']), 'hdvalue=' + repr(_pc.document['hdvalue']), 'verbose=' + repr(_pc.document['verbose']) ] )
128 task_result = None
129 try:
130 task_result = _imhead_t( _pc.document['imagename'], _pc.document['mode'], _pc.document['hdkey'], _pc.document['hdvalue'], _pc.document['verbose'] )
131 except Exception as exc:
132 _except_log('imhead', exc)
133 raise
134 finally:
135 task_result = _end_log( _logging_state_, 'imhead', task_result )
136 return task_result
138imhead = _imhead( )