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

27 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-31 17:39 +0000

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

2##################### f23b664397bb9692ae29987ba974c717 ############################## 

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_uvmodelfit import uvmodelfit as _uvmodelfit_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 _uvmodelfit: 

15 """ 

16 uvmodelfit ---- Fit a single component source model to the uv data 

17 

18  

19 Fit a single component source model to the uv data 

20 

21 --------- parameter descriptions --------------------------------------------- 

22 

23 vis Name of input visibility file 

24 field Select field using field id(s) or field name(s) 

25 spw Select spectral window/channels 

26 selectdata Other data selection parameters 

27 timerange Select data based on time range 

28 uvrange Select data within uvrange (default units meters) 

29 antenna Select data based on antenna/baseline 

30 scan Scan number range 

31 msselect Optional complex data selection (ignore for now) 

32 niter Number of fitting iterations to execute 

33 comptype component model type: P(oint), G(aussian), or D(isk) 

34 sourcepar Starting guess for component parameters (3 values for type P, 5 for G and D) 

35 varypar Control which parameters to let vary in the fit 

36 outfile Optional output component list table 

37 

38 --------- examples ----------------------------------------------------------- 

39 

40  

41  

42 Fit a single component source model to the uv data. Three models 

43 are available: P=point; G=Gaussian; D=Disk. Fitting parameters can 

44 be held fixed. The results are given in the log and placed in a 

45 components file. 

46  

47 Keyword arguments: 

48 vis -- Name of input visibility file 

49 default: none; example: vis='ngc5921.ms' 

50  

51 --- Data Selection 

52 field -- Select data based on field id(s) or name(s) 

53 default: '' (all); example: field='1' 

54 field='0~2' # field ids inclusive from 0 to 2 

55 field='3C*' # all field names starting with 3C 

56 spw -- Select data based on spectral window 

57 default: '' (all); example: spw='1' 

58 spw='<2' #spectral windows less than 2 

59 spw='>1' #spectral windows greater than 1 

60 selectdata -- Select a subset of the visibility using MSSelection 

61 default: False; example: selectdata=True 

62 timerange -- Select data based on time range: 

63 default = '' (all); example, 

64 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 

65 Note: YYYY/MM/DD can be dropped as needed: 

66 timerange='09:14:0~09:54:0' # this time range 

67 timerange='09:44:00' # data within one integration of time 

68 timerange='>10:24:00' # data after this time 

69 timerange='09:44:00+00:13:00' #data 13 minutes after time 

70 uvrange -- Select data within uvrange (default units kilo-lambda) 

71 default: '' (all); example: 

72 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lamgda 

73 uvrange='>4klambda';uvranges greater than 4 kilo lambda 

74 uvrange='0~1000km'; uvrange in kilometers 

75 antenna -- Select data based on antenna/baseline 

76 default: '' (all); example: antenna='5&6' baseline 5-6 

77 antenna='5&6;7&8' #baseline 5-6 and 7-8 

78 antenna='5' # all baselines with antenna 5 

79 antenna='5,6' # all baselines with antennas 5 and 6 

80 scan -- Select data based on scan number - New, under developement 

81 default: '' (all); example: scan='>3' 

82 msselect -- Optional data selection (field,spw,time,etc) 

83 default:'' means select all; example:msselect='FIELD_ID==0', 

84 msselect='FIELD_ID IN [0,1,2]' means select fields 0,1 and 2 

85 msselect='FIELD_ID <= 1 means select fields 0, 1 

86 msselect='FIELD_ID==0 && ANTENNA1 IN [0] && ANTENNA2 IN [2:26]' 

87 means select field 0 and antennas 0 to 26, except antenna 1. 

88 Other msselect fields are: 'DATA_DESC_ID', 'SPECTRAL_WINDOW_ID', 

89 'POLARIZATION_ID', 'SCAN_NUMBER', 'TIME', 'UVW' 

90 See ccokbook for more details 

91  

92 niter -- Number of fitting iterations to execute 

93 default: 5; example: niter=20 

94 comptype -- component model type 

95 default: 'P'; 

96 Options: 'P' (point source), 'G' (elliptical gaussian), 

97 'D' (elliptical disk) 

98 sourcepar -- Starting guess for component parameters 

99 default: [1,0,0]; (for comptype='P') 

100 IF comptype = 'P' then 

101 sourcepar = [flux,xoff,yoff] where 

102 flux = Jy, xoff = offset east (arcsec), yoff = offset north (arcsec). 

103 IF comptype = 'G' or 'D', then 

104 sourcepar = [flux,xoff,yoff,majax,axrat,pos] where 

105 majax = FWHM along the major axis (arcsec), axrat < 1 is 

106 the ratio of minor to major axis, pos=angle in deg 

107 varypar -- Control which parameters to let vary in the fit 

108 default: [] (all vary); 

109 example: vary=[F,T,T] 

110  

111 examples: 

112  

113 fit a point: 

114 comptype = 'P' 

115 sourcepar = [0.4,0.2,-0.3]; 

116 varypar = [T,T,T] 

117  

118 fit a circular Gaussian: 

119 comptype = 'G' 

120 sourcepar = [1.4,0.3,-0.2,0.3, 1, 0] 

121 varypar = [ T , T , T , T , F, F] 

122  

123  

124 outfile -- Optional output component list table 

125 default: ''; example: outfile='componentlist.cl' 

126  

127  

128 How to get the output values: 

129  

130 cl.open('componentlist.cl') 

131 fit = cl.getcompoent() stores component information 

132 fit to see the whole mess 

133 flux = fit['flux']['value'] to store the I,Q,U,V, flux 

134 print flux 

135  

136 ra = fit['shape']['direction']['m0']['value'] 

137 dec =fit['shape']['direction']['m1']['value'] 

138 print ra, dec 

139  

140 bmaj = fit['shape']['majoraxis']['value'] to get major axis 

141 bmin = fit['shape']['minoraxis']['value'] to get minor axis 

142  

143 

144 

145 """ 

146 

147 _info_group_ = """manipulation, calibration""" 

148 _info_desc_ = """Fit a single component source model to the uv data""" 

149 

150 def __call__( self, vis='', field='', spw='', selectdata=True, timerange='', uvrange='', antenna='', scan='', msselect='', niter=int(5), comptype='P', sourcepar=[ float(1.0),float(0.0),float(0.0) ], varypar=[ ], outfile='' ): 

151 schema = {'vis': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'selectdata': {'type': 'cBool'}, 'timerange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'uvrange': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'scan': {'type': 'cStr', 'coerce': _coerce.to_str}, 'msselect': {'type': 'cStr', 'coerce': _coerce.to_str}, 'niter': {'type': 'cInt'}, 'comptype': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'P', 'G', 'D' ]}, 'sourcepar': {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, 'varypar': {'type': 'cBoolVec', 'coerce': [_coerce.to_list,_coerce.to_boolvec]}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}} 

152 doc = {'vis': vis, 'field': field, 'spw': spw, 'selectdata': selectdata, 'timerange': timerange, 'uvrange': uvrange, 'antenna': antenna, 'scan': scan, 'msselect': msselect, 'niter': niter, 'comptype': comptype, 'sourcepar': sourcepar, 'varypar': varypar, 'outfile': outfile} 

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

154 _logging_state_ = _start_log( 'uvmodelfit', [ 'vis=' + repr(_pc.document['vis']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'selectdata=' + repr(_pc.document['selectdata']), 'timerange=' + repr(_pc.document['timerange']), 'uvrange=' + repr(_pc.document['uvrange']), 'antenna=' + repr(_pc.document['antenna']), 'scan=' + repr(_pc.document['scan']), 'msselect=' + repr(_pc.document['msselect']), 'niter=' + repr(_pc.document['niter']), 'comptype=' + repr(_pc.document['comptype']), 'sourcepar=' + repr(_pc.document['sourcepar']), 'varypar=' + repr(_pc.document['varypar']), 'outfile=' + repr(_pc.document['outfile']) ] ) 

155 task_result = None 

156 try: 

157 task_result = _uvmodelfit_t( _pc.document['vis'], _pc.document['field'], _pc.document['spw'], _pc.document['selectdata'], _pc.document['timerange'], _pc.document['uvrange'], _pc.document['antenna'], _pc.document['scan'], _pc.document['msselect'], _pc.document['niter'], _pc.document['comptype'], _pc.document['sourcepar'], _pc.document['varypar'], _pc.document['outfile'] ) 

158 except Exception as exc: 

159 _except_log('uvmodelfit', exc) 

160 raise 

161 finally: 

162 task_result = _end_log( _logging_state_, 'uvmodelfit', task_result ) 

163 return task_result 

164 

165uvmodelfit = _uvmodelfit( ) 

166