Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/specflux.py: 89%
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 specflux.xml ##################
2##################### 5ea1d87b65024c4cc319bd392691af0f ##############################
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_specflux import specflux as _specflux_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 _specflux:
15 """
16 specflux ---- Report spectral profile and calculate spectral flux over a user specified region
18 --------- parameter descriptions ---------------------------------------------
20 imagename Name of the input image
21 region Region selection. Default is to use the full image.
22 box Rectangular region to select in direction plane. Default is to use the entire direction plane.
23 chans Channels to use. Default is to use all channels.
24 stokes Stokes planes to use. Default is to use all Stokes planes.
25 mask Mask to use. Default is none.
26 stretch Stretch the mask if necessary and possible?
27 function Aggregate function to use for computing per channel values. Supported values are "flux density", "mean", "median", "sum". Minimal match supported.
28 unit Unit to use for the spectral flux calculation. Must be conformant with a typical spectral axis unit.
29 major Major axis of overriding restoring beam. If specified, must be a valid quantity.
30 minor Minor axis of overriding restoring beam. If specified, must be a valid quantity
31 logfile File which to write details. Default is to not write to a file.
32 overwrite Overwrite exisitng ouput file if it exists?
33 [1;42mRETURNS[1;m record
35 --------- examples -----------------------------------------------------------
38 PARAMETER SUMMARY
39 imagename Name of the input (CASA, FITS, MIRIAD) image
40 region Region selection. Default is to use
41 the full image.
42 box Rectangular region to select in direction plane.
43 for details. Default is to use the entire direction plane.
44 chans Channels to use. Default is to use
45 all channels.
46 stokes Stokes planes to use. Default is to use
47 all Stokes planes.
48 mask Mask to use. Default is none.
49 stretch Stretch the input mask if necessary and possible. Only used if a mask is specified.
51 function Aggregate function to use for computing per channel values. Supported values are
52 "flux density", "mean", "median", "sum". Minimal match supported.
53 unit Unit to use for the spectral flux calculation. Must be conformant with a typical
54 spectral axis unit (ie something conformant with a velocity, frequency, or length).
55 Velocity units may only be used if the spectral coordinate has a rest frequency and
56 if it is > 0.
57 major Major axis of overriding restoring beam. If specified, must be a valid quantity
58 If specified, minor must also be specified. The overriding beam is used for computing
59 flux and flux density values. Ignored if the image brightness units do not contain
60 "/beam". Example "4arcsec".
61 minor Minor axis of overriding restoring beam. If specified, must be a valid quantity.
62 If specified, major must also be specified. See help on parameter major for details.
63 Example: "3arcsec".
64 logfile Name of file to which to write tabular output. Default is to not write to a file.
65 overwrite Controls if an already existing log file by the
66 same name can be overwritten. If true, the user is not prompted, the file
67 if it exists is automatically overwritten.
69 This application retrieves details of an image spectrum which has been integrated over a specified
70 region (or the entire image if no region has been specified).
72 One may specify which function to use to aggregate pixel values using the function parameter. Supported
73 values are "flux density", "mean", "median", and "sum". Minimal match is supported.
75 The spectral flux is reported in units flux density consistent with the image brightness unit times the
76 specified spectral unit (eg, Jy*km/s, K*arcsec2*km/s). If the units are K*arcsec2..., multiply the
77 reported value by 2.3504430539098e-8*d*d, where d is the distance in pc, to convert to units of K*pc2...
78 If provided, major and minor will be used to compute the beam size, and hence the per channel flux
79 densities (if function="flux density"), overriding the input image beam information, if present.
81 # write spectrum to file that has been integrated over
82 # rectangular region, using only pixels with non-negative values.
83 # if the log file already exists, overwrite it with the new data.
84 specflux(imagename="my.im", box="10,10,45,50", mask="my.im>=0", unit="km/s", logfile="my.log", overwrite=True)
86 # Extract the spectral profile using "sum" as the aggregate function from a cube over a given region:
87 specflux(imagename="myimage.image", box="10,10,45,50", mask="my.im>=0", function="sum", unit="km/s", logfile="profile.log", overwrite=True)
89 # Calculate the integrated line flux over a given region and channel range
90 # (this value will be reported as "Total Flux" in the output of specflux)
91 specflux(imagename="myimage.image", region="myregion.crtf", chans="14~25", unit="km/s", logfile="integrated_line_flux.log", overwrite=True)
94 """
96 _info_group_ = """analysis"""
97 _info_desc_ = """Report spectral profile and calculate spectral flux over a user specified region"""
99 def __call__( self, imagename='', region='', box='', chans='', stokes='', mask='', stretch=False, function='flux density', unit='km/s', major='', minor='', logfile='', overwrite=False ):
100 schema = {'imagename': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, '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}, 'stretch': {'type': 'cBool'}, 'function': {'type': 'cStr', 'coerce': _coerce.to_str}, 'unit': {'type': 'cStr', 'coerce': _coerce.to_str}, 'major': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'minor': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'logfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'overwrite': {'type': 'cBool'}}
101 doc = {'imagename': imagename, 'region': region, 'box': box, 'chans': chans, 'stokes': stokes, 'mask': mask, 'stretch': stretch, 'function': function, 'unit': unit, 'major': major, 'minor': minor, 'logfile': logfile, 'overwrite': overwrite}
102 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
103 _logging_state_ = _start_log( 'specflux', [ 'imagename=' + repr(_pc.document['imagename']), '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']), 'stretch=' + repr(_pc.document['stretch']), 'function=' + repr(_pc.document['function']), 'unit=' + repr(_pc.document['unit']), 'major=' + repr(_pc.document['major']), 'minor=' + repr(_pc.document['minor']), 'logfile=' + repr(_pc.document['logfile']), 'overwrite=' + repr(_pc.document['overwrite']) ] )
104 task_result = None
105 try:
106 task_result = _specflux_t( _pc.document['imagename'], _pc.document['region'], _pc.document['box'], _pc.document['chans'], _pc.document['stokes'], _pc.document['mask'], _pc.document['stretch'], _pc.document['function'], _pc.document['unit'], _pc.document['major'], _pc.document['minor'], _pc.document['logfile'], _pc.document['overwrite'] )
107 except Exception as exc:
108 _except_log('specflux', exc)
109 raise
110 finally:
111 task_result = _end_log( _logging_state_, 'specflux', task_result )
112 return task_result
114specflux = _specflux( )