Coverage for /home/casatest/venv/lib/python3.12/site-packages/casatasks/tclean.py: 89%

27 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-21 07:43 +0000

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

2##################### 214e4c0dbbbeb35a4a041ccbbea77d9a ############################## 

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_tclean import tclean as _tclean_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 _tclean: 

15 """ 

16 tclean ---- Radio Interferometric Image Reconstruction 

17 

18 Form images from visibilities and reconstruct a sky model. 

19 This task handles continuum images and spectral line cubes, 

20 supports outlier fields, contains standard clean based algorithms 

21 along with algorithms for multi-scale and wideband image 

22 reconstruction, widefield imaging correcting for the w-term, 

23 full primary-beam imaging and joint mosaic imaging (with 

24 heterogeneous array support for ALMA). 

25 

26 --------- parameter descriptions --------------------------------------------- 

27 

28 vis Name(s) of input visibility file(s) 

29 default: none; 

30 example: vis='ngc5921.ms' 

31 vis=['ngc5921a.ms','ngc5921b.ms']; multiple MSs 

32 selectdata Enable data selection parameters. 

33 field to image or mosaic. Use field id(s) or name(s). 

34 ['go listobs' to obtain the list id's or names] 

35 default: ''= all fields.  

36 If field string is a non-negative integer, it is assumed to 

37 be a field index, otherwise it is assumed to be a 

38 field name. 

39 field='0~2'; field ids 0,1,2. 

40 field='0,4,5~7'; field ids 0,4,5,6,7. 

41 field='3C286,3C295'; field names 3C286 and 3C295. 

42 field = '3,4C\*'; field id 3, all names starting with 4C. 

43 For multiple MS input, a list of field strings can be used: 

44 field = ['0~2','0~4']; field ids 0-2 for the first MS and 0-4 

45 for the second. 

46 field = '0~2'; field ids 0-2 for all input MSs. 

47 spw l window/channels. 

48 NOTE: channels not selected here will contain all zeros if 

49 selected by other subparameters. 

50 default: ''=all spectral windows and channels. 

51 spw='0~2,4'; spectral windows 0,1,2,4 (all channels). 

52 spw='0:5~61'; spw 0, channels 5 to 61. 

53 spw='<2'; spectral windows less than 2 (i.e. 0,1). 

54 spw='0,10,3:3~45'; spw 0,10 all channels, and spw 3 

55 channels 3 to 45. 

56 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 

57 For multiple MS input, a list of spw strings can be used: 

58 spw=['0','0~3']; spw ids 0 for the first MS and 0-3 for the second. 

59 spw='0~3' spw ids 0-3 for all input MS. 

60 spw='3:10~20;50~60' for multiple channel ranges within spw id 3. 

61 spw='3:10~20;50~60,4:0~30' for different channel ranges for spw ids 3 and 4. 

62 spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10, 

63 spw 1, channels 20-30, and spw 2, channels, 1,2 and 3. 

64 spw='1~4;6:15~48' for channels 15 through 48 for spw ids 1,2,3,4 and 6. 

65 timerange Range of time to select from data 

66  

67 default: '' (all); examples, 

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

69 Note: if YYYY/MM/DD is missing date defaults to first 

70 day in data set. 

71 timerange='09:14:0~09:54:0' picks 40 min on first day. 

72 timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 

73 30min on NEXT day. 

74 timerange='09:44:00' pick data within one integration 

75 of time. 

76 timerange='> 10:24:00' data after this time. 

77 For multiple MS input, a list of timerange strings can be 

78 used: 

79 timerange=['09:14:0~09:54:0','> 10:24:00']. 

80 timerange='09:14:0~09:54:0''; apply the same timerange for 

81 all input MSs. 

82 uvrange Select data within uvrange (default unit is meters) 

83 default: '' (all); example: 

84 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda. 

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

86 For multiple MS input, a list of uvrange strings can be 

87 used: 

88 uvrange=['0~1000klambda','100~1000klamda']. 

89 uvrange='0~1000klambda'; apply 0-1000 kilo-lambda for all 

90 input MSs. 

91 uvrange='0~1000'; apply 0-1000 meter for all input MSs. 

92 antenna Select data based on antenna/baseline 

93  

94 default: '' (all) 

95 If antenna string is a non-negative integer, it is 

96 assumed to be an antenna index, otherwise, it is 

97 considered an antenna name. 

98 antenna='5\&6'; baseline between antenna index 5 and 

99 index 6. 

100 antenna='VA05\&VA06'; baseline between VLA antenna 5 

101 and 6. 

102 antenna='5\&6;7\&8'; baselines 5-6 and 7-8. 

103 antenna='5'; all baselines with antenna index 5. 

104 antenna='05'; all baselines with antenna number 05 

105 (VLA old name). 

106 antenna='5,6,9'; all baselines with antennas 5,6,9 

107 index number. 

108 For multiple MS input, a list of antenna strings can be 

109 used: 

110 antenna=['5','5\&6']; 

111 antenna='5'; antenna index 5 for all input MSs. 

112 antenna='!DV14'; use all antennas except DV14. 

113 scan Scan number range 

114  

115 default: '' (all). 

116 example: scan='1~5'. 

117 For multiple MS input, a list of scan strings can be used: 

118 scan=['0~100','10~200']. 

119 scan='0~100; scan ids 0-100 for all input MSs. 

120 observation Observation ID range 

121 default: '' (all). 

122 example: observation='1~5'. 

123 intent Scan Intent(s) 

124  

125 default: '' (all). 

126 example: intent='TARGET_SOURCE'. 

127 example: intent='TARGET_SOURCE1,TARGET_SOURCE2'. 

128 example: intent='TARGET_POINTING\*'. 

129 datacolumn Data column to image (data or observed, corrected) 

130 default:'corrected' 

131 ( If 'corrected' does not exist, it will use 'data' instead ) 

132 imagename Pre-name of output images 

133  

134 example : imagename='try' 

135  

136 Output images will be (a subset of) : 

137  

138 try.psf - Point Spread Function (PSF). 

139 try.residual - Residual image. 

140 try.image - Restored image. 

141 try.model - Model image (contains only flux components). 

142 try.sumwt - Single pixel image containing sum-of-weights. 

143 (for natural weighting, sensitivity=1/sqrt(sumwt)). 

144 try.pb - Primary Beam (PB) model (values depend on the gridder used). 

145  

146 A-projection algorithms (gridder=mosaic,awproject, awp2) will 

147 compute the following images too. 

148  

149 try.weight - FT of gridded weights or the 

150 un-normalized sum of PB-square (for all pointings). 

151 Here, PB = sqrt(weight) normalized to a maximum of 1.0. 

152  

153 For multi-term wideband imaging, all relevant images above will 

154 have additional .tt0,.tt1, etc suffixes to indicate Taylor terms, 

155 plus the following extra output images. 

156 try.alpha - spectral index. 

157 try.alpha.error - estimate of error on spectral index. 

158 try.beta - spectral curvature (if nterms \> 2). 

159  

160 Tip : Include a directory name in 'imagename' for all 

161 output images to be sent there instead of the 

162 current working directory : imagename='mydir/try'. 

163  

164 Tip : Restarting an imaging run without changing 'imagename' 

165 implies continuation from the existing model image on disk. 

166 - If 'startmodel' was initially specified it needs to be set to "" 

167 for the restart run (or tclean will exit with an error message). 

168 - By default, the residual image and psf will be recomputed 

169 but if no changes were made to relevant parameters between 

170 the runs, set calcres=False, calcpsf=False to resume directly from 

171 the minor cycle without the (unnecessary) first major cycle. 

172 To automatically change 'imagename' with a numerical 

173 increment, set restart=False (see tclean docs for 'restart'). 

174  

175 Note : All imaging runs will by default produce restored images. 

176 For a niter=0 run, this will be redundant and can optionally 

177 be turned off via the 'restoration=T/F' parameter. 

178 imsize Number of pixels 

179 example: 

180  

181 imsize = [350,250]. 

182 imsize = 500 is equivalent to [500,500]. 

183  

184 To take proper advantage of internal optimized FFT routines, the 

185 number of pixels must be even and factorizable by 2,3,5 only. 

186 To find the nearest optimal imsize to that desired by the user, please use the following tool method: 

187  

188 from casatools import synthesisutils 

189 su = synthesisutils() 

190 su.getOptimumSize(345)  

191 Output : 360 

192 cell Cell size 

193 example: cell=['0.5arcsec,'0.5arcsec'] or 

194 cell=['1arcmin', '1arcmin']. 

195 cell = '1arcsec' is equivalent to ['1arcsec','1arcsec']. 

196 phasecenter Phase center of the image (string or field id); if the phasecenter is the name known major solar system object ('MERCURY', 'VENUS', 'MARS', 'JUPITER', 'SATURN', 'URANUS', 'NEPTUNE', 'PLUTO', 'SUN', 'MOON') or is an ephemerides table then that source is tracked and the background sources get smeared. There is a special case, when phasecenter='TRACKFIELD', which will use the ephemerides or polynomial phasecenter in the FIELD table of the MS's as the source center to track. 

197  

198 Note : If unspecified, tclean will use the phase-center from the first data field of the MS (or list of MSs) selected for imaging.  

199  

200 example: phasecenter='6'. 

201 phasecenter='J2000 19h30m00 -40d00m00'. 

202 phasecenter='J2000 292.5deg -40.0deg'. 

203 phasecenter='J2000 5.105rad -0.698rad'. 

204 phasecenter='ICRS 13:05:27.2780 -049.28.04.458'. 

205 phasecenter='myComet_ephem.tab'. 

206 phasecenter='MOON'. 

207 phasecenter='TRACKFIELD'. 

208 stokes Stokes Planes to make 

209 default='I'; example: stokes='IQUV'; 

210 Options: 'I','Q','U','V','IV','QU','IQ','UV','IQUV','RR','LL','XX','YY','RRLL','XXYY','pseudoI' 

211  

212 Note : Due to current internal code constraints, if any correlation pair 

213 is flagged, by default, no data for that row in the MS will be used. 

214 So, in an MS with XX,YY, if only YY is flagged, neither a 

215 Stokes I image nor an XX image can be made from those data points. 

216 In such a situation, please split out only the unflagged correlation into 

217 a separate MS, or use the option 'pseudoI'. 

218  

219 Note : The 'pseudoI' option is a partial solution, allowing Stokes I imaging 

220 when either of the parallel-hand correlations are unflagged. 

221  

222 The remaining constraints shall be removed (where logical) in a future release. 

223 projection Coordinate projection 

224 Examples : SIN, NCP. 

225 A list of supported (but untested) projections can be found here : 

226 http://casa.nrao.edu/active/docs/doxygen/html/classcasa_1_1Projection.html#a3d5f9ec787e4eabdce57ab5edaf7c0cd 

227 startmodel Name of starting model image 

228  

229 The contents of the supplied starting model image will be 

230 copied to the imagename.model before the run begins. 

231  

232 example : startmodel = 'singledish.im'. 

233  

234 For deconvolver='mtmfs', one image per Taylor term must be provided. 

235 example : startmodel = ['try.model.tt0', 'try.model.tt1']. 

236 startmodel = ['try.model.tt0'] will use a starting model only 

237 for the zeroth order term. 

238 startmodel = ['','try.model.tt1'] will use a starting model only 

239 for the first order term. 

240  

241 This starting model can be of a different image shape and size from 

242 what is currently being imaged. If so, an image regrid is first triggered 

243 to resample the input image onto the target coordinate system. 

244  

245 A common usage is to set this parameter equal to a single dish image. 

246  

247 Negative components in the model image will be included as is. 

248  

249 Note : If an error occurs during image resampling/regridding, 

250 please try using task imregrid to resample the starting model 

251 image onto a CASA image with the target shape and 

252 coordinate system before supplying it via startmodel. 

253 specmode Spectral definition mode (mfs,cube,cubedata, cubesource, mvc) 

254  

255 specmode='mfs' : Continuum imaging with only one output image channel. 

256 (mode='cont' can also be used here) 

257  

258 specmode='cube' : Spectral line imaging with one or more channels. 

259 Parameters start, width,and nchan define the spectral 

260 coordinate system and can be specified either in terms 

261 of channel numbers, frequency or velocity in whatever 

262 spectral frame is specified in 'outframe'. 

263 All internal and output images are made with outframe as the 

264 base spectral frame. However imaging code internally uses the fixed 

265 spectral frame, LSRK for automatic internal software 

266 Doppler correction, so that a spectral line observed over an 

267 extended time range will line up appropriately. 

268 Therefore the output images have additional spectral frame conversion 

269 layer in LSRK on the top the base frame. 

270  

271  

272  

273  

274 specmode='cubedata' : Spectral line imaging with one or more channels. 

275 There is no internal software Doppler correction, so 

276 a spectral line observed over an extended time range 

277 may be smeared out in frequency. There is strictly 

278 no valid spectral frame with which to associate with the 

279 output images, thus the image spectral frame will 

280 be labelled "Undefined". 

281  

282  

283 specmode='cubesource': Spectral line imaging while 

284 tracking moving source (near field or solar system 

285 objects). The velocity of the source is accounted 

286 and the frequency reported is in the source frame. 

287 As there is no "SOURCE" frame defined in CASA, 

288 the frame in the image will be labelled "REST" (but do note the 

289 velocity of a given line reported may be different from the rest frame 

290 velocity if the emission region is moving w.r.t the systemic 

291 velocity frame of the source). 

292  

293 specmode='mvc' : Multiterm continuum imaging with cube major cycles.  

294 This mode requires deconvolver='mtmfs' with nterms>1  

295 and user-set choices of 'reffreq' and 'nchan'.  

296  

297 The output images and minor cycle are similar to specmode='mfs'  

298 with deconvolver='mtmfs', but the major cycles are done in  

299 cube mode (and require a setting of 'reffreq' and 'nchan').  

300 By default, frequency-dependent primary beam correction is  

301 applied to each channel, before being combined across frequency 

302 to make the inputs to the 'mtmfs' deconvolver. This results in  

303 implicit wideband pb-correction, with the deconvolver seeing only 

304 the sky spectral structure. 

305  

306 Note : There is currently no option to turn off wideband pb correction 

307 as part of the flat-sky normalization between the major and minor cycles. 

308 Therefore, 'mvc' with the 'standard' and 'wproject' gridders will also apply 

309 pblimits per channel, masking all regions outside of pblimit.  

310 An option to retain sources outside the pblimit will be added in a future release.  

311  

312 Note : Below is some guidance for choosing 'nchan' and 'reffreq' : 

313  

314 The cube produced by the major cycle is used in a linear least square fits for Taylor 

315 polynomials per pixel. Therefore, one only needs as many channels in the cube, as 

316 required for an accurate polynomial fit for sources that have the strongest 

317 spectral structure. 

318  

319 In general, 'nchan' needs to be greater than or equal to 'nterms', and the 

320 frequency range selected by the data will be evenly split into nchan channels. 

321 For a low-order polynomial fit, only a small number (around 10) 

322 channels are typically needed (for VLA/ALMA bandwidth ratios). 

323 'nchan=-1' applies a heuristic that results in a default of 10 cube channels 

324 for a 2:1 bandwidth ratio. 

325  

326 nchan = MAX( bandwidth/(0.1*startfreq) , nterms+1 ) 

327  

328 Note: When running in parallel, the nchan selected may limit the speedup if it 

329 is smaller than the number of processes used. 

330  

331 The 'reffreq' is the reference frequency used for the Taylor polynomial expansion. 

332 By default, in specmode='mvc', reffreq is set to the middle of the selected 

333 frequency range. 

334 reffreq Reference frequency of the output image coordinate system. 

335  

336 Example : reffreq='1.5GHz' as a string with units. 

337  

338 By default, it is calculated as the middle of the selected frequency range. 

339  

340 For deconvolver='mtmfs' the Taylor expansion is also done about 

341 this specified reference frequency. 

342 nchan Number of channels in the output image. 

343 For default (=-1), the number of channels will be automatically determined 

344 based on data selected by 'spw' with 'start' and 'width'. 

345 It is often easiest to leave nchan at the default value. 

346 example: nchan=100 

347 start First channel (e.g. start=3,start=\'1.1GHz\',start=\'15343km/s\') 

348 of output cube images specified by data channel number (integer), 

349 velocity (string with a unit), or frequency (string with a unit). 

350 Default:''; The first channel is automatically determined based on 

351 the 'spw' channel selection and 'width'. 

352 channels in 'spw'.  

353 Since the integer number in 'start' represents the data channel number, 

354 when the channel number is used along with the spectral window id selection 

355 in 'spw', 'start' specified as an integer should be carefully set otherwise 

356 it may result in the blank image channels if the 'start' channel (i.e. absolute  

357 channel number) is outside of the channel range specified in 'spw'. 

358 In such a case, 'start' can be left as a default (='') to ensure 

359 matching with the data spectral channel selection. 

360 For specmode='cube', when velocity or frequency is used it is 

361 interpreted with the frame defined in outframe. [The parameters of 

362 the desired output cube can be estimated by using the 'transform' 

363 functionality of 'plotms']. 

364 examples: start='5.0km/s'; 1st channel, 5.0km/s in outframe. 

365 start='22.3GHz'; 1st channel, 22.3GHz in outframe. 

366 width Channel width (e.g. width=2,width=\'0.1MHz\',width=\'10km/s\') of output cube images 

367 specified by data channel number (integer), velocity (string with a unit), or 

368 or frequency (string with a unit). 

369 Default:''; data channel width. 

370 The sign of width defines the direction of the channels to be incremented. 

371 For width specified in velocity or frequency with '-' in front gives image channels in 

372 decreasing velocity or frequency, respectively. 

373 For specmode='cube', when velocity or frequency is used it is interpreted with 

374 the reference frame defined in outframe. 

375 examples: width='2.0km/s'; results in channels with increasing velocity. 

376 width='-2.0km/s'; results in channels with decreasing velocity. 

377 width='40kHz'; results in channels with increasing frequency. 

378 width=-2; results in channels averaged of 2 data channels incremented from 

379 high to low channel numbers. 

380 outframe Spectral reference frame in which to interpret \'start\' and \'width\' 

381 Options: '','LSRK','LSRD','BARY','GEO','TOPO','GALACTO','LGROUP','CMB' 

382 example: outframe='bary' for Barycentric frame. 

383  

384 REST -- Rest frequency. 

385 LSRD -- Local Standard of Rest (J2000). 

386 -- as the dynamical definition (IAU, [9,12,7] km/s in galactic coordinates). 

387 LSRK -- LSR as a kinematical (radio) definition. 

388 -- 20.0 km/s in direction ra,dec = [270,+30] deg (B1900.0). 

389 BARY -- Barycentric (J2000). 

390 GEO --- Geocentric. 

391 TOPO -- Topocentric. 

392 GALACTO -- Galacto centric (with rotation of 220 km/s in direction l,b = [90,0] deg. 

393 LGROUP -- Local group velocity -- 308km/s towards l,b = [105,-7] deg (F. Ghigo). 

394 CMB -- CMB velocity -- 369.5km/s towards l,b = [264.4, 48.4] deg (F. Ghigo). 

395 DEFAULT = LSRK. 

396 veltype Velocity type (radio, z, ratio, beta, gamma, optical) 

397 For 'start' and/or 'width' specified in velocity, specifies the velocity definition 

398 Options: 'radio','optical','z','beta','gamma','optical' 

399 NOTE: the viewer always defaults to displaying the 'radio' frame, 

400 but that can be changed in the position tracking pull down. 

401  

402 The different types (with F = f/f0, the frequency ratio), are: 

403  

404 Z = (-1 + 1/F). 

405 RATIO = (F) \*. 

406 RADIO = (1 - F). 

407 OPTICAL == Z. 

408 BETA = ((1 - F^2)/(1 + F^2)). 

409 GAMMA = ((1 + F^2)/2F) \*. 

410 RELATIVISTIC == BETA (== v/c). 

411 DEFAULT == RADIO. 

412 Note that the ones with an '\*' have no real interpretation 

413 (although the calculation will proceed) if given as a velocity. 

414 restfreq List of rest frequencies or a rest frequency in a string. 

415 Specify rest frequency to use for output image. 

416  

417 Currently it uses the first rest frequency in the list for translation of 

418 velocities. The list will be stored in the output images. 

419 Default: []; look for the rest frequency stored in the MS, if not available, 

420 use center frequency of the selected channels. 

421 examples: restfreq=['1.42GHz']. 

422 restfreq='1.42GHz'. 

423 interpolation Spectral interpolation (nearest,linear,cubic) 

424  

425 Interpolation rules to use when binning data channels onto image channels 

426 and evaluating visibility values at the centers of image channels. 

427  

428 Note : 'linear' and 'cubic' interpolation requires data points on both sides of 

429 each image frequency. Errors are therefore possible at edge channels, or near 

430 flagged data channels. When image channel width is much larger than the data 

431 channel width there is nothing much to be gained using linear or cubic thus 

432 not worth the extra computation involved. 

433 perchanweightdensity When calculating weight density for Briggs 

434 style weighting in a cube, this parameter 

435 determines whether to calculate the weight 

436 density for each channel independently  

437 (the default, True) 

438 or a common weight density for all of the selected 

439 data. This parameter has no 

440 meaning for continuum (specmode='mfs') imaging 

441 or for natural and radial weighting schemes. 

442 For cube imaging 

443 perchanweightdensity=True is a recommended 

444 option that provides more uniform 

445 sensitivity per channel for cubes, but with 

446 generally larger psfs than the 

447 perchanweightdensity=False (prior behavior) 

448 option. When using Briggs style weight with 

449 perchanweightdensity=True, the imaging weight 

450 density calculations use only the weights of 

451 data that contribute specifically to that 

452 channel. On the other hand, when 

453 perchanweightdensity=False, the imaging 

454 weight density calculations sum all of the 

455 weights from all of the data channels 

456 selected whose (u,v) falls in a given uv cell 

457 on the weight density grid. Since the 

458 aggregated weights, in any given uv cell, 

459 will change depending on the number of 

460 channels included when imaging, the psf 

461 calculated for a given frequency channel will 

462 also necessarily change, resulting in 

463 variability in the psf for a given frequency 

464 channel when perchanweightdensity=False. In 

465 general, perchanweightdensity=False results 

466 in smaller psfs for the same value of 

467 robustness compared to 

468 perchanweightdensity=True, but the rms noise 

469 as a function of channel varies and increases 

470 toward the edge channels; 

471 perchanweightdensity=True provides more 

472 uniform sensitivity per channel for 

473 cubes. This may make it harder to find 

474 estimates of continuum when 

475 perchanweightdensity=False. If you intend to 

476 image a large cube in many smaller subcubes 

477 and subsequently concatenate, it is advisable 

478 to use perchanweightdensity=True to avoid 

479 surprisingly varying sensitivity and psfs 

480 across the concatenated cube. 

481 gridder Gridding options (standard, wproject, widefield, mosaic, awproject, awp2, awphpg) 

482  

483  

484 The following options choose different gridding convolution 

485 functions for the process of convolutional resampling of the measured 

486 visibilities onto a regular uv-grid prior to an inverse FFT. 

487 Model prediction (degridding) also uses these same functions. 

488 Several wide-field effects can be accounted for via careful choices of 

489 convolution functions. Gridding (degridding) runtime will rise in 

490 proportion to the support size of these convolution functions (in uv-pixels). 

491  

492 standard : Prolate Spheroid with 7x7 uv pixel support size. 

493  

494 [ This mode can also be invoked using 'ft' or 'gridft' ] 

495  

496 wproject : W-Projection algorithm to correct for the widefield 

497 non-coplanar baseline effect. [Cornwell et.al 2008] 

498  

499 wprojplanes is the number of distinct w-values at 

500 which to compute and use different gridding convolution 

501 functions (see help for wprojplanes). 

502 Convolution function support size can range 

503 from 5x5 to few 100 x few 100. 

504  

505 [ This mode can also be invoked using 'wprojectft' ] 

506  

507 widefield : Facetted imaging with or without W-Projection per facet. 

508  

509 A set of facets x facets subregions of the specified image 

510 are gridded separately using their respective phase centers 

511 (to minimize max W). Deconvolution is done on the joint 

512 full size image, using a PSF from the first subregion. 

513  

514 wprojplanes=1 : standard prolate spheroid gridder per facet. 

515 wprojplanes > 1 : W-Projection gridder per facet. 

516 nfacets=1, wprojplanes > 1 : Pure W-Projection and no facetting. 

517 nfacets=1, wprojplanes=1 : Same as standard,ft,gridft. 

518  

519 A combination of facetting and W-Projection is relevant only for 

520 very large fields of view. (In our current version of tclean, this  

521 combination runs only with parallel=False.  

522  

523 mosaic : A-Projection with azimuthally symmetric beams without 

524 sidelobes, beam rotation or squint correction. 

525 Gridding convolution functions per visibility are computed 

526 from FTs of PB models per antenna. 

527 This gridder can be run on single fields as well as mosaics. 

528  

529 VLA : PB polynomial fit model (Napier and Rots, 1982). 

530 EVLA : PB polynomial fit model (Perley, 2015). 

531 ALMA : Airy disks for a 10.7m dish (for 12m dishes) and 

532 6.25m dish (for 7m dishes) each with 0.75m 

533 blockages (Hunter/Brogan 2011). Joint mosaic 

534 imaging supports heterogeneous arrays for ALMA. 

535  

536 Typical gridding convolution function support sizes are 

537 between 7 and 50 depending on the desired 

538 accuracy (given by the uv cell size or image field of view). 

539  

540 [ This mode can also be invoked using 'mosaicft' or 'ftmosaic' ] 

541  

542 awproject : A-Projection with azimuthally asymmetric beams and 

543 including beam rotation, squint correction, 

544 conjugate frequency beams and W-projection. 

545 [Bhatnagar et.al, 2008] 

546  

547 Gridding convolution functions are computed from 

548 aperture illumination models per antenna and optionally 

549 combined with W-Projection kernels and a prolate spheroid. 

550 This gridder can be run on single fields as well as mosaics. 

551  

552 VLA : Uses ray traced model (VLA and EVLA) including feed 

553 leg and subreflector shadows, off-axis feed location 

554 (for beam squint and other polarization effects), and 

555 a Gaussian fit for the feed beams (Brisken 2009) 

556 ALMA : Similar ray-traced model as above (but the correctness 

557 of its polarization properties remains un-verified). 

558  

559 Typical gridding convolution function support sizes are 

560 between 7 and 50 depending on the desired 

561 accuracy (given by the uv cell size or image field of view). 

562 When combined with W-Projection they can be significantly larger. 

563  

564 [ This mode can also be invoked using 'awprojectft' ] 

565  

566  

567 awp2 : A-Projection with azimuthally asymmetric beams and 

568 including beam rotation, squint correction and W-projection. 

569 [Bhatnagar et.al, 2008] 

570  

571 Gridding convolution functions are computed from 

572 aperture illumination models (assuming similar antennas) and optionally 

573 combined with W-Projection kernels. 

574 This gridder can be run on single fields as well as mosaics. 

575 The other sub-parameters that are of significance when using this gridder 

576 are wprojplanes, computepastep, mosweight, usepointing, pblimit and normtype. 

577  

578 Only supports VLA : Uses ray traced model (VLA and EVLA) including feed 

579 leg and subreflector shadows, off-axis feed location 

580 (for beam squint and other polarization effects), and 

581 a Gaussian fit for the feed beams (Ref: Brisken 2009) 

582  

583 For squint correction the value passed in computepastep has to be smaller than 180. 

584 Anything larger awp2 will use an average of LL and RR beams. If computepastep=5, for 

585 e.g., PB every 5 degrees, over the range of parallactic angle covered by the data, will be calculated 

586 and the nearest beam to every integration will be used to correct for the squint between the L and R beams.  

587  

588 NOTE : For mtmfs with nterms >1 and using awp2 gridder, for accurate results always use specmode="mvc" 

589 as awp2 with specmode="mfs" does not use conjugate beams to remove the spectral 

590 index of the primary beam. 

591  

592 awphpg : Implementation of the high performance gridder (HPG; Pokorny, ngVLA Computing Memo #5). 

593 For CASA 6.7.0 this mode is only available on the internal VLASS release of CASA. 

594 It will be made available for general use in a future CASA release. 

595  

596  

597 imagemosaic : (untested implementation). 

598  

599 Grid and iFT each pointing separately and combine the 

600 images as a linear mosaic (weighted by a PB model) in 

601 the image domain before a joint minor cycle. 

602  

603 VLA/ALMA PB models are same as for gridder='mosaicft'. 

604  

605 ------ Notes on PB models : 

606  

607 (1) Several different sources of PB models are used in the modes 

608 listed above. This is partly for reasons of algorithmic flexibility 

609 and partly due to the current lack of a common beam model 

610 repository or consensus on what beam models are most appropriate. 

611  

612 (2) For ALMA and gridder='mosaic', ray-traced (TICRA) beams 

613 are also available via the vpmanager tool. 

614 For example, call the following before the tclean run. 

615 vp.setpbimage(telescope="ALMA", 

616 compleximage='/home/casa/data/trunk/alma/responses/ALMA_0_DV__0_0_360_0_45_90_348.5_373_373_GHz_ticra2007_VP.im', 

617 antnames=['DV'+'%02d'%k for k in range(25)]) 

618 vp.saveastable('mypb.tab') 

619 Then, supply vptable='mypb.tab' to tclean. 

620 ( Currently this will work only for non-parallel runs ) 

621  

622  

623 ------ Note on PB masks : 

624  

625 In tclean, A-Projection gridders (mosaic, awproject, and awp2) produce a 

626 .pb image and use the 'pblimit' subparameter to decide normalization 

627 cutoffs and construct an internal T/F mask in the .pb and .image images. 

628 However, this T/F mask cannot directly be used during deconvolution 

629 (which needs a 1/0 mask). There are two options for making a pb based 

630 deconvolution mask. 

631 -- Run tclean with niter=0 to produce the .pb, construct a 1/0 image 

632 with the desired threshold (using ia.open('newmask.im'); 

633 ia.calc('iif("xxx.pb">0.3,1.0,0.0)');ia.close() for example), 

634 and supply it via the 'mask' parameter in a subsequent run 

635 (with calcres=F and calcpsf=F to restart directly from the minor cycle). 

636 -- Run tclean with usemask='pb' for it to automatically construct 

637 a 1/0 mask from the internal T/F mask from .pb at a fixed 0.2 threshold. 

638  

639  

640 ----- Making PBs for gridders other than mosaic, awproject, awp2 

641  

642 After the PSF generation, a PB is constructed using the same 

643 models used in gridder='mosaic' but just evaluated in the image 

644 domain without consideration to weights. 

645 facets Number of facets on a side 

646  

647 A set of (facets x facets) subregions of the specified image 

648 are gridded separately using their respective phase centers 

649 (to minimize max W). Deconvolution is done on the joint 

650 full size image, using a PSF from the first subregion/facet. 

651  

652 In our current version of tclean, facets>1 may be used only 

653 with parallel=False. 

654 psfphasecenter For mosaic use psf centered on this 

655 optional direction. You may need to use 

656 this if for example the mosaic does not 

657 have any pointing in the center of the 

658 image. Another reason; as the psf is 

659 approximate for a mosaic, this may help 

660 to deconvolve a non central bright source 

661 well and quickly. 

662  

663 example: 

664  

665 psfphasecenter='6' #center psf on field 6. 

666 psfphasecenter='J2000 19h30m00 -40d00m00'. 

667 psfphasecenter='J2000 292.5deg -40.0deg'. 

668 psfphasecenter='J2000 5.105rad -0.698rad'. 

669 psfphasecenter='ICRS 13:05:27.2780 -049.28.04.458'. 

670 wprojplanes Number of distinct w-values at which to compute and use different 

671 gridding convolution functions for W-Projection 

672  

673 An appropriate value of wprojplanes depends on the presence/absence 

674 of a bright source far from the phase center, the desired dynamic 

675 range of an image in the presence of a bright far out source, 

676 the maximum w-value in the measurements, and the desired trade off 

677 between accuracy and computing cost. 

678  

679 As a (rough) guide, VLA L-Band D-config may require a 

680 value of 128 for a source 30arcmin away from the phase 

681 center. A-config may require 1024 or more. To converge to an 

682 appropriate value, try starting with 128 and then increasing 

683 it if artifacts persist. W-term artifacts (for the VLA) typically look 

684 like arc-shaped smears in a synthesis image or a shift in source 

685 position between images made at different times. These artifacts 

686 are more pronounced the further the source is from the phase center. 

687  

688 There is no harm in simply always choosing a large value (say, 1024) 

689 but there will be a significant performance cost to doing so, especially 

690 for gridder='awproject' where it is combined with A-Projection. 

691  

692 wprojplanes=-1 is an option for gridder='widefield' or 'wproject' 

693 in which the number of planes is automatically computed. 

694 vptable vpmanager 

695  

696 vptable="" : Choose default beams for different telescopes. 

697 ALMA : Airy disks. 

698 EVLA : old VLA models. 

699  

700 Other primary beam models can be chosen via the vpmanager tool. 

701  

702 Step 1 : Set up the vpmanager tool and save its state in a table. 

703  

704 vp.setpbpoly(telescope='EVLA', coeff=[1.0, -1.529e-3, 8.69e-7, -1.88e-10]) 

705 vp.saveastable('myvp.tab') 

706  

707 Step 2 : Supply the name of that table in tclean. 

708  

709 tclean(....., vptable='myvp.tab',....) 

710  

711 Please see the documentation for the vpmanager for more details on how to 

712 choose different beam models. Work is in progress to update the defaults 

713 for EVLA and ALMA. 

714  

715 Note : AWProjection currently does not use this mechanism to choose 

716 beam models. It instead uses ray-traced beams computed from 

717 parameterized aperture illumination functions, which are not 

718 available via the vpmanager. So, gridder='awproject' does not allow 

719 the user to set this parameter. 

720 mosweight When doing Brigg's style weighting (including uniform) to perform the weight density calculation for each field indepedently if True. If False the weight density is calculated from the average uv distribution of all the fields. 

721 aterm Use aperture illumination functions during gridding. 

722  

723 This parameter turns on the A-term of the AW-Projection gridder. 

724 Gridding convolution functions are constructed from aperture illumination 

725 function models of each antenna. 

726 psterm Include the Prolate Spheroidal (PS) funtion as the anti-aliasing  

727 operator in the gridding convolution functions used for gridding. 

728  

729 Setting this parameter to true is necessary when aterm is set to  

730 false. It can be set to false when aterm is set to true, though  

731 with this setting effects of aliasing may be there in the image,  

732 particularly near the edges. 

733  

734 When set to true, the .pb images will contain the fourier transform 

735 of the of the PS funtion. 

736  

737 For more information on the functional 

738 effects of the psterm, aterm and wprojplanes settings, see the  

739 'Wide-field Imaging' pages in CASA Docs (https://casadocs.readthedocs.io). 

740 wbawp Use frequency dependent A-terms. 

741 Scale aperture illumination functions appropriately with frequency 

742 when gridding and combining data from multiple channels. 

743 conjbeams Use conjugate frequency for wideband A-terms. 

744  

745 While gridding data from one frequency channel, choose a convolution  

746 function from a 'conjugate' frequency such that the resulting baseline  

747 primary beam is approximately constant across frequency. For a system in  

748 which the primary beam scales with frequency, this step will eliminate  

749 instrumental spectral structure from the measured data and leave only the  

750 sky spectrum for the minor cycle to model and reconstruct [Bhatnagar et al., ApJ, 2013]. 

751  

752 As a rough guideline for when this is relevant, a source at the half power  

753 point of the PB at the center frequency will see an artificial spectral  

754 index of -1.4 due to the frequency dependence of the PB [Sault and Wieringa, 1994].  

755 If left uncorrected during gridding, this spectral structure must be modeled  

756 in the minor cycle (using the mtmfs algorithm) to avoid dynamic range limits  

757 (of a few hundred for a 2:1 bandwidth). 

758 This works for specmode='mfs' and its value is ignored for cubes. 

759 cfcache Convolution function cache directory name. 

760  

761 Name of a directory in which to store gridding convolution functions. 

762 This cache is filled at the beginning of an imaging run. This step can be time 

763 consuming but the cache can be reused across multiple imaging runs that 

764 use the same image parameters (cell size, image size , spectral data 

765 selections, wprojplanes, wbawp, psterm, aterm). The effect of the wbawp,  

766 psterm and aterm settings is frozen-in in the cfcache. Using an existing cfcache 

767 made with a different setting of these parameters will not reflect the current 

768 settings. 

769  

770 In a parallel execution, the construction of the cfcache is also parallelized  

771 and the time to compute scales close to linearly with the number of compute  

772 cores used. With the re-computation of Convolution Functions (CF) due to PA  

773 rotation turned-off (the computepastep parameter), the total number of in the 

774 cfcache can be computed as [No. of wprojplanes x No. of selected spectral windows x 4] 

775  

776 By default, cfcache = imagename + '.cf' 

777 usepointing The usepointing flag informs the gridder that it should utilize the pointing table 

778 to use the correct direction in which the antenna is pointing with respect to the pointing phasecenter. 

779 computepastep Parallactic angle interval after the AIFs are recomputed (deg). 

780  

781 This parameter controls the accuracy of the aperture illumination function 

782 used with AProjection for alt-az mount dishes where the AIF rotates on the 

783 sky as the synthesis image is built up. Once the PA in the data changes by  

784 the given interval, AIFs are re-computed at the new PA. 

785  

786 A value of 360.0 deg (the default) implies no re-computation due to PA rotation. 

787 AIFs are computed for the PA value of the first valid data received and used for  

788 all of the data. 

789  

790 For gridder=awp2 a value of 180.0 deg or larger implies no squint correction will be 

791 attempted i.e an average beam of the left hand and right hand polarization will be calculated 

792 rotatepastep Parallactic angle interval after which the nearest AIF is rotated (deg)  

793  

794 Instead of recomputing the AIF for every timestep's parallactic angle, 

795 the nearest existing AIF is used and rotated 

796 after the PA changed by rotatepastep value. 

797  

798 A value of 360.0 deg (the default) disables rotation of the AIF. 

799  

800 For example, computepastep=360.0 and rotatepastep=5.0 will compute 

801 the AIFs at only the starting parallactic angle and all other timesteps will 

802 use a rotated version of that AIF at the nearest 5.0 degree point. 

803 pointingoffsetsigdev Corrections for heterogenous and time-dependent pointing  

804 offsets via AWProjection are controlled by this parameter.  

805 It is a vector of 2 ints or doubles each of which is interpreted  

806 in units of arcsec. Based on the first threshold, a clustering  

807 algorithm is applied to entries from the POINTING subtable  

808 of the MS to determine how distinct antenna groups for which 

809 the pointing offset must be computed separately. The second  

810 number controls how much a pointing change across time can  

811 be ignored and after which an antenna rebinning is required.  

812  

813  

814 Note : The default value of this parameter is [], due a programmatic constraint. 

815 If run with this value, it will internally pick [600,600] and exercise the 

816 option of using large tolerances (10arcmin) on both axes. Please choose 

817 a setting explicitly for runs that need to use this parameter.  

818  

819 Note : This option is available only for gridder='awproject' and usepointing=True and 

820 and has been validated primarily with VLASS on-the-fly mosaic data 

821 where POINTING subtables have been modified after the data are recorded. 

822  

823  

824 Examples of parameter usage :  

825  

826 [100.0,100.0] : Pointing offsets of 100 arcsec or less are considered  

827 small enough to be ignored. Using large values for both 

828 indicates a homogeneous array. 

829  

830  

831 [10.0, 100.0] : Based on entries in the POINTING subtable, antennas  

832 are grouped into clusters based on a 10arcsec bin size.  

833 All antennas in a bin are given a pointing offset calculated 

834 as the average of the offsets of all antennas in the bin. 

835 On the time axis, offset changes upto 100 arcsec will be ignored. 

836  

837 [10.0,10.0] : Calculate separate pointing offsets for each antenna group 

838 (with a 10 arcsec bin size). As a function of time, recalculate  

839 the antenna binning if the POINTING table entries change by 

840 more than 10 arcsec w.r.to the previously computed binning. 

841  

842 [1.0, 1.0] : Tight tolerances will imply a fully heterogenous situation where  

843 each antenna gets its own pointing offset. Also, time-dependent  

844 offset changes greater than 1 arcsec will trigger recomputes of  

845 the phase gradients. This is the most general situation and is also  

846 the most expensive option as it constructs and uses separate  

847 phase gradients for all baselines and timesteps.  

848  

849 For VLASS 1.1 data with two kinds of pointing offsets, the recommended 

850 setting is [ 30.0, 30.0 ]. 

851  

852 For VLASS 1.2 data with only the time-dependent pointing offsets, the 

853 recommended setting is [ 300.0, 30.0 ] to turn off the antenna grouping 

854 but to retain the time dependent corrections required from one timestep 

855 to the next. 

856 pblimit PB gain level at which to cut off normalizations. 

857  

858 Divisions by .pb during normalizations have a cut off at a .pb gain 

859 level given by pblimit. Outside this limit, image values are set to zero. 

860 Additionally, by default, an internal T/F mask is applied to the .pb, .image and 

861 .residual images to mask out (T) all invalid pixels outside the pblimit area. 

862  

863 Note : This internal T/F mask cannot be used as a deconvolution mask. 

864 To do so, please follow the steps listed above in the Notes for the 

865 'gridder' parameter. 

866  

867 Note : To prevent the internal T/F mask from appearing in anything other 

868 than the .pb and .image.pbcor images, 'pblimit' can be set to a 

869 negative number.  

870 The absolute value will still be used as a valid 'pblimit' for normalization 

871 purposes. So, for example, pick pblimit=-0.1 (and not pblimit=-1).  

872 A tclean restart using existing output images on disk that already 

873 have this T/F mask in the .residual and .image but only pblimit set 

874 to a negative value, will remove this mask after the next major cycle. 

875  

876 Note : An existing internal T/F mask may be removed from an image as  

877 follows (without needing to re-run tclean itself).  

878 ia.open('test.image'); 

879 ia.maskhandler(op='set', name=''); 

880 ia.done() 

881 normtype Normalization type (flatnoise, flatsky, pbsquare). 

882  

883 Gridded (and FT'd) images represent the PB-weighted sky image. 

884 Qualitatively it can be approximated as two instances of the PB 

885 applied to the sky image (one naturally present in the data 

886 and one introduced during gridding via the convolution functions). 

887  

888 xxx.weight : Weight image approximately equal to sum ( square ( pb ) ) 

889 xxx.pb : Primary beam calculated as sqrt ( xxx.weight ) 

890  

891 normtype='flatnoise' : Divide the raw image by sqrt(.weight) so that 

892 the input to the minor cycle represents the 

893 product of the sky and PB. The noise is 'flat' 

894 across the region covered by each PB. 

895  

896 normtype='flatsky' : Divide the raw image by .weight so that the input 

897 to the minor cycle represents only the sky. 

898 The noise is higher in the outer regions of the 

899 primary beam where the sensitivity is low. 

900  

901 normtype='pbsquare' : No normalization after gridding and FFT. 

902 The minor cycle sees the sky times pb square 

903 deconvolver Name of minor cycle algorithm (hogbom,clark,multiscale,mtmfs,mem,clarkstokes,asp) 

904  

905 Each of the following algorithms operate on residual images and PSFs 

906 from the gridder and produce output model and restored images. 

907 Minor cycles stop and a major cycle is triggered when cyclethreshold 

908 or cycleniter are reached. For all methods, components are picked from 

909 the entire extent of the image or (if specified) within a mask. 

910  

911 hogbom : An adapted version of Hogbom Clean [Hogbom, 1974]. 

912 - Find the location of the peak residual. 

913 - Add this delta function component to the model image. 

914 - Subtract a scaled and shifted PSF of the same size as the image 

915 from regions of the residual image where the two overlap. 

916 - Repeat. 

917  

918 clark : An adapted version of Clark Clean [Clark, 1980]. 

919 - Find the location of max(I^2+Q^2+U^2+V^2). 

920 - Add delta functions to each stokes plane of the model image. 

921 - Subtract a scaled and shifted PSF within a small patch size 

922 from regions of the residual image where the two overlap. 

923 - After several iterations trigger a Clark major cycle to subtract 

924 components from the visibility domain, but without de-gridding. 

925 - Repeat. 

926  

927 ( Note : 'clark' maps to imagermode='' in the old clean task. 

928 'clark_exp' is another implementation that maps to 

929 imagermode='mosaic' or 'csclean' in the old clean task 

930 but the behavior is not identical. For now, please 

931 use deconvolver='hogbom' if you encounter problems. ) 

932  

933 clarkstokes : Clark Clean operating separately per Stokes plane. 

934  

935 (Note : 'clarkstokes_exp' is an alternate version. See above.) 

936  

937 multiscale : MultiScale Clean [Cornwell, 2008]. 

938 - Smooth the residual image to multiple scale sizes. 

939 - Find the location and scale at which the peak occurs. 

940 - Add this multiscale component to the model image. 

941 - Subtract a scaled,smoothed,shifted PSF (within a small 

942 patch size per scale) from all residual images. 

943 - Repeat from step 2. 

944  

945 mtmfs : Multi-term (Multi Scale) Multi-Frequency Synthesis [Rau and Cornwell, 2011]. 

946 - Smooth each Taylor residual image to multiple scale sizes. 

947 - Solve a NTxNT system of equations per scale size to compute 

948 Taylor coefficients for components at all locations. 

949 - Compute gradient chi-square and pick the Taylor coefficients 

950 and scale size at the location with maximum reduction in 

951 chi-square. 

952 - Add multi-scale components to each Taylor-coefficient 

953 model image. 

954 - Subtract scaled,smoothed,shifted PSF (within a small patch size 

955 per scale) from all smoothed Taylor residual images. 

956 - Repeat from step 2. 

957  

958  

959 mem : Maximum Entropy Method [Cornwell and Evans, 1985]. 

960 - Iteratively solve for values at all individual pixels via the 

961 MEM method. It minimizes an objective function of 

962 chi-square plus entropy (here, a measure of difference 

963 between the current model and a flat prior model). 

964  

965 (Note : This MEM implementation is not very robust. 

966 Improvements will be made in the future.) 

967  

968 asp : Adaptive Scale Pixel algorithm [Bhatnagar and Cornwell, 2004]. 

969 - Define a set of initial scales defined as 0, W, 2W 4W and 8W. 

970 where W is a 2D Gaussian fitting width to the PSF. 

971 - Smooth the residual image by a Gaussian beam at initial scales. 

972 - Search for the global peak (F) among these smoothed residual images. 

973 - form an active Aspen set: amplitude(F), amplitude location(x,y). 

974 - Optimize the Aspen set by minimizing the objective function RI-Aspen*PSF,  

975 where RI is the residual image and * is the convulition operation.  

976 - Compute the model image and update the residual image 

977 - Repeat from step 2 

978 scales List of scale sizes (in pixels) for multi-scale and mtmfs algorithms. 

979 --> scales=[0,6,20] 

980 This set of scale sizes should represent the sizes 

981 (diameters in units of number of pixels) 

982 of dominant features in the image being reconstructed. 

983  

984 The smallest scale size is recommended to be 0 (point source), 

985 the second being the size of the synthesized beam and the third being 3-5 

986 times the synthesized beam, etc. For example, if the synthesized 

987 beam is 10" FWHM and cell=2",try scales = [0,5,15]. 

988  

989 For numerical stability, the largest scale must be 

990 smaller than the image (or mask) size and smaller than or 

991 comparable to the scale corresponding to the lowest measured 

992 spatial frequency (as a scale size much larger than what the 

993 instrument is sensitive to is unconstrained by the data making 

994 it harder to recover from errors during the minor cycle). 

995 nterms Number of Taylor coefficients in the spectral model. 

996  

997 - nterms=1 : Assume flat spectrum source. 

998 - nterms=2 : Spectrum is a straight line with a slope. 

999 - nterms=N : A polynomial of order N-1. 

1000  

1001 From a Taylor expansion of the expression of a power law, the 

1002 spectral index is derived as alpha = taylorcoeff_1 / taylorcoeff_0. 

1003  

1004 Spectral curvature is similarly derived when possible. 

1005  

1006 The optimal number of Taylor terms depends on the available 

1007 signal to noise ratio, bandwidth ratio, and spectral shape of the 

1008 source as seen by the telescope (sky spectrum x PB spectrum). 

1009  

1010 nterms=2 is a good starting point for wideband EVLA imaging 

1011 and the lower frequency bands of ALMA (when fractional bandwidth 

1012 is greater than 10%) and if there is at least one bright source for 

1013 which a dynamic range of greater than few 100 is desired. 

1014  

1015 Spectral artifacts for the VLA often look like spokes radiating out from 

1016 a bright source (i.e. in the image made with standard mfs imaging). 

1017 If increasing the number of terms does not eliminate these artifacts, 

1018 check the data for inadequate bandpass calibration. If the source is away 

1019 from the pointing center, consider including wide-field corrections too. 

1020  

1021 (Note : In addition to output Taylor coefficient images .tt0,.tt1,etc 

1022 images of spectral index (.alpha), an estimate of error on 

1023 spectral index (.alpha.error) and spectral curvature (.beta, 

1024 if nterms is greater than 2) are produced. 

1025 - These alpha, alpha.error and beta images contain 

1026 internal T/F masks based on a threshold computed 

1027 as peakresidual/10. Additional masking based on 

1028 .alpha/.alpha.error may be desirable. 

1029 - .alpha.error is a purely empirical estimate derived 

1030 from the propagation of error during the division of 

1031 two noisy numbers (alpha = xx.tt1/xx.tt0) where the 

1032 'error' on tt1 and tt0 are simply the values picked from 

1033 the corresponding residual images. The absolute value 

1034 of the error is not always accurate and it is best to interpret 

1035 the errors across the image only in a relative sense. 

1036 smallscalebias A numerical control to bias the scales when using multi-scale or mtmfs algorithms. 

1037 The peak from each scale's smoothed residual is 

1038 multiplied by ( 1 - smallscalebias \* scale/maxscale ) 

1039 to increase or decrease the amplitude relative to other scales, 

1040 before the scale with the largest peak is chosen.  

1041 Smallscalebias can be varied between -1.0 and 1.0.  

1042 A score of 0.0 gives all scales equal weight (default).  

1043 A score larger than 0.0 will bias the solution towards smaller scales.  

1044 A score smaller than 0.0 will bias the solution towards larger scales. 

1045 The effect of smallscalebias is more pronounced when using multi-scale relative to mtmfs. 

1046 fusedthreshold ring Hogbom Clean (number in units of Jy). 

1047  

1048 fusedthreshold = 0.0001 : 0.1 mJy. 

1049  

1050 This is a subparameter of the Asp Clean deconvolver. When peak residual  

1051 is lower than the threshold, Asp Clean is "switched to Hogbom Clean" (i.e. only use the 0 scale for cleaning) for  

1052 the following number of iterations until it switches back to Asp Clean. 

1053  

1054 NumberIterationsInHogbom = 50 + 2 * (exp(0.05 * NthHogbom) - 1) 

1055  

1056 , where NthHogbom is the number of times Hogbom Clean has been triggered.  

1057  

1058 When the Asp Clean detects it is approaching convergence, it uses only the 0 scale for the following number of iterations for better computational efficiency.  

1059  

1060 NumberIterationsInHogbom = 500 + 2 * (exp(0.05 * NthHogbom) - 1) 

1061  

1062 Set 'fusedthreshold = -1' to make the Asp Clean deconvolver never "switch" to Hogbom Clean. 

1063 largestscale xels) allowed for the initial guess for the Asp Clean deconvolver. 

1064  

1065 largestscale = 100 

1066  

1067 The default initial scale sizes used by Asp Clean is [0, w, 2w, 4w, 8w],  

1068 where `w` is the PSF width. The default `largestscale` is -1 which indicates  

1069 users accept these initial scales. If `largestscale` is set, the initial scales  

1070 would be [0, w, ... up to the `largestscale`]. This is only an initial guess, 

1071 and actual fitted scale sizes may evolve from these initial values. 

1072  

1073 It is recommended not to set `largestscale` unless Asp Clean picks a large  

1074 scale that has no constraints from the data (the UV hole issue). 

1075 restoration e. 

1076  

1077 Construct a restored image : imagename.image by convolving the model 

1078 image with a clean beam and adding the residual image to the result. 

1079 If a restoringbeam is specified, the residual image is also 

1080 smoothed to that target resolution before adding it in. 

1081  

1082 If a .model does not exist, it will make an empty one and create 

1083 the restored image from the residuals ( with additional smoothing if needed ). 

1084 With algorithm='mtmfs', this will construct Taylor coefficient maps from 

1085 the residuals and compute .alpha and .alpha.error. 

1086 restoringbeam ize to use. 

1087  

1088 - restoringbeam='' or ['']. 

1089 A Gaussian fitted to the PSF main lobe (separately per image plane). 

1090  

1091 - restoringbeam='10.0arcsec'. 

1092 Use a circular Gaussian of this width for all planes. 

1093  

1094 - restoringbeam=['8.0arcsec','10.0arcsec','45deg']. 

1095 Use this elliptical Gaussian for all planes. 

1096  

1097 - restoringbeam='common'. 

1098 Automatically estimate a common beam shape/size appropriate for 

1099 all planes. This option can be used when the beam shape is different as a function of frequency, and will smooth all planes to a single beam, defined by the largest beam in the cube. 

1100  

1101 Note : For any restoring beam different from the native resolution 

1102 the model image is convolved with the beam and added to 

1103 residuals that have been convolved to the same target resolution. 

1104 pbcor the output restored image. 

1105  

1106 A new image with extension .image.pbcor will be created from 

1107 the evaluation of .image / .pb for all pixels above the specified pblimit. 

1108  

1109 Note : Stand-alone PB-correction can be triggered by re-running 

1110 tclean with the appropriate imagename and with 

1111 niter=0, calcpsf=False, calcres=False, pbcor=True, vptable='vp.tab' 

1112 ( where vp.tab is the name of the vpmanager file; 

1113 see the inline help for the 'vptable' parameter ). Alternatively, task impbcor can be used for primary beam correction using the .image and .pb files. 

1114  

1115 Note : For deconvolver='mtmfs', pbcor will divide each Taylor term image by the .tt0 average PB.  

1116 For all gridders, this calculation is accurate for small fractional bandwidths.  

1117  

1118 For large fractional bandwidths, please use one of the following options. 

1119  

1120 (a) For single pointings, run the tclean task with specmode='mfs', deconvolver='mtmfs',  

1121 and gridder='standard' with pbcor=True or False.  

1122 If a PB-corrected spectral index is required,  

1123 please use the widebandpbcor task to apply multi-tern PB-correction. 

1124  

1125 (b) For mosaics, run tclean task with specmode='mfs', deconvolver='mtmfs', 

1126 and gridder='awproject' , wbawp=True, conjbeams=True, with pbcor=True.  

1127 This option applies wideband PB correction as part of the gridding step and 

1128 pbcor=True will be accurate because the spectral index map will already  

1129 be PB-corrected.  

1130  

1131 (c) For mosaics, run tclean with specmode='mvc', deconvolver='mtmfs',  

1132 and gridder='mosaic' or 'awp2' with pbcor=True.  

1133 This option applies wideband PB-correction to channelized residual images 

1134 prior to the minor cycle and pbcor=True will be accurate because the spectral  

1135 index map will already be PB-corrected.  

1136  

1137 Note : Frequency-dependent PB corrections are typically required for full-band imaging with the VLA.  

1138 Wideband PB corrections are required when the amplitude of the 

1139 brightest source is known accurately enough to be sensitive 

1140 to the difference in the PB gain between the upper and lower 

1141 end of the band at its location. As a guideline, the artificial spectral 

1142 index due to the PB is -1.4 at the 0.5 gain level and less than -0.2 

1143 at the 0.9 gain level at the middle frequency ) 

1144 outlierfile Name of outlier-field image definitions. 

1145  

1146 A text file containing sets of parameter=value pairs, 

1147 one set per outlier field. 

1148  

1149 Example : outlierfile='outs.txt' 

1150  

1151 Contents of outs.txt : 

1152  

1153 imagename=tst1 

1154 nchan=1 

1155 imsize=[80,80] 

1156 cell=[8.0arcsec,8.0arcsec] 

1157 phasecenter=J2000 19:58:40.895 +40.55.58.543 

1158 mask=circle[[40pix,40pix],10pix] 

1159  

1160 imagename=tst2 

1161 nchan=1 

1162 imsize=[100,100] 

1163 cell=[8.0arcsec,8.0arcsec] 

1164 phasecenter=J2000 19:58:40.895 +40.56.00.000 

1165 mask=circle[[60pix,60pix],20pix] 

1166  

1167 The following parameters are currently allowed to be different between 

1168 the main field and the outlier fields (i.e. they will be recognized if found 

1169 in the outlier text file). If a parameter is not listed, the value is picked from 

1170 what is defined in the main task input. 

1171  

1172 imagename, imsize, cell, phasecenter, startmodel, mask 

1173 specmode, nchan, start, width, nterms, reffreq, 

1174 gridder, deconvolver, wprojplanes. 

1175  

1176 Note : 'specmode' is an option, so combinations of mfs and cube 

1177 for different image fields, for example, are supported. 

1178 'deconvolver' and 'gridder' are also options that allow different 

1179 imaging or deconvolution algorithm per image field. 

1180  

1181 For example, multiscale with wprojection and 16 w-term planes 

1182 on the main field and mtmfs with nterms=3 and wprojection 

1183 with 64 planes on a bright outlier source for which the frequency 

1184 dependence of the primary beam produces a strong effect that 

1185 must be modeled. The traditional alternative to this approach is 

1186 to first image the outlier, subtract it out of the data (uvsub) and 

1187 then image the main field. 

1188 weighting Weighting scheme (natural,uniform,briggs,superuniform,radial, briggsabs, briggsbwtaper). 

1189  

1190 During gridding of the dirty or residual image, each visibility value is 

1191 multiplied by a weight before it is accumulated on the uv-grid. 

1192 The PSF's uv-grid is generated by gridding only the weights (weightgrid). 

1193  

1194 weighting='natural' : Gridding weights are identical to the data weights 

1195 from the MS. For visibilities with similar data weights, 

1196 the weightgrid will follow the sample density 

1197 pattern on the uv-plane. This weighting scheme 

1198 provides the maximum imaging sensitivity at the 

1199 expense of a PSF with possibly wider main lobes and high sidelobes. 

1200 It is most appropriate for detection experiments 

1201 where sensitivity is most important. 

1202  

1203 weighting='uniform' : Gridding weights per visibility data point are the 

1204 original data weights divided by the total weight of 

1205 all data points that map to the same uv grid cell : 

1206 ' data_weight / total_wt_per_cell '. 

1207  

1208 The weightgrid is as close to flat as possible resulting 

1209 in a PSF with a narrow main lobe and suppressed 

1210 sidelobes. However, since heavily sampled areas of 

1211 the uv-plane get down-weighted, the imaging 

1212 sensitivity is not as high as with natural weighting. 

1213 It is most appropriate for imaging experiments where 

1214 a well behaved PSF can help the reconstruction. 

1215  

1216 weighting='briggs' : Gridding weights per visibility data point are given by 

1217 'data_weight / ( A \* total_wt_per_cell + B ) ' where 

1218 A and B vary according to the 'robust' parameter. 

1219  

1220 robust = -2.0 maps to A=1,B=0 or uniform weighting. 

1221 robust = +2.0 maps to natural weighting. 

1222 (robust=0.5 is equivalent to robust=0.0 in AIPS IMAGR.) 

1223  

1224 Robust/Briggs weighting generates a PSF that can 

1225 vary smoothly between 'natural' and 'uniform' and 

1226 allow customized trade-offs between PSF shape and 

1227 imaging sensitivity. 

1228 weighting='briggsabs' : Experimental option. 

1229 Same as Briggs except the formula is different A= 

1230 robust\*robust and B is dependent on the 

1231 noise per visibility estimated. Giving noise='0Jy' 

1232 is a not a reasonable option. 

1233 In this mode (or formula) robust values 

1234 from -2.0 to 0.0 only make sense (2.0 and 

1235 -2.0 will get the same weighting) 

1236  

1237 weighting='superuniform' : This is similar to uniform weighting except that 

1238 the total_wt_per_cell is replaced by the 

1239 total_wt_within_NxN_cells around the uv cell of 

1240 interest. N=7 is the default (when the  

1241 parameter 'npixels' is set to 0 with 'superuniform')  

1242  

1243 This method tends to give a PSF with inner 

1244 sidelobes that are suppressed as in uniform 

1245 weighting but with far-out sidelobes closer to 

1246 natural weighting. The peak sensitivity is also 

1247 closer to natural weighting. 

1248  

1249 weighting='radial' : Gridding weights are given by ' data_weight \* uvdistance ' 

1250 This method approximately minimizes rms sidelobes 

1251 for an east-west synthesis array. 

1252  

1253 weighting='briggsbwtaper' : A modified version of Briggs weighting for cubes where an inverse uv taper, 

1254 which is proportional to the fractional bandwidth of the entire cube, 

1255 is applied per channel. The objective is to modify cube (perchanweightdensity = True) 

1256 imaging weights to have a similar density to that of the continuum imaging weights. 

1257 This is currently an experimental weighting scheme being developed for ALMA. 

1258  

1259 For more details on weighting please see Chapter3 

1260 of Dan Briggs' thesis (http://www.aoc.nrao.edu/dissertations/dbriggs) 

1261 robust Robustness parameter for Briggs weighting. 

1262  

1263 robust = -2.0 maps to uniform weighting. 

1264 robust = +2.0 maps to natural weighting. 

1265 (robust=0.5 is equivalent to robust=0.0 in AIPS IMAGR.) 

1266 noise noise parameter for briggs abs mode weighting 

1267 npixels Number of pixels to determine uv-cell size for super-uniform weighting 

1268 (0 defaults to -/+ 3 pixels). 

1269  

1270 npixels -- uv-box used for weight calculation 

1271 a box going from -npixel/2 to +npixel/2 on each side 

1272 around a point is used to calculate weight density. 

1273  

1274 npixels=2 goes from -1 to +1 and covers 3 pixels on a side. 

1275  

1276 npixels=0 implies a single pixel, which does not make sense for 

1277 superuniform weighting. Therefore, for 'superuniform' 

1278 weighting, if npixels=0 it will be forced to 6 (or a box  

1279 of -3pixels to +3pixels) to cover 7 pixels on a side. 

1280 uvtaper uv-taper on outer baselines in uv-plane. 

1281  

1282 Apply a Gaussian taper in addition to the weighting scheme specified 

1283 via the 'weighting' parameter. Higher spatial frequencies are weighted 

1284 down relative to lower spatial frequencies to suppress artifacts 

1285 arising from poorly sampled areas of the uv-plane. It is equivalent to 

1286 smoothing the PSF obtained by other weighting schemes and can be 

1287 specified either as the HWHM of a Gaussian in uv-space (eg. units of lambda) 

1288 or as the FWHM of a Gaussian in the image domain (eg. angular units like arcsec). 

1289  

1290 uvtaper = [bmaj, bmin, bpa]. 

1291  

1292 Note : FWHM_uv_lambda = (4 log2) / ( pi * FWHM_lm_radians ).  

1293  

1294 A FWHM_lm of 100.000 arcsec maps to a HWHM_uv of 910.18 lambda. 

1295 A FWHM_lm of 1 arcsec maps to a HWHM_uv of 91 klambda. 

1296  

1297 default: uvtaper=[]; no Gaussian taper applied. 

1298 example: uvtaper=['5klambda'] circular taper of HWHM=5 kilo-lambda. 

1299 uvtaper=['5klambda','3klambda','45.0deg'] uv-domain HWHM. 

1300 uvtaper=['50arcsec','30arcsec','30.0deg'] : image domain FWHM. 

1301 uvtaper=['10arcsec'] : image domain FWHM.  

1302 uvtaper=['300.0'] default units are lambda in aperture plane. 

1303 niter Maximum number of iterations. 

1304  

1305 A stopping criterion based on total iteration count. 

1306 Currently the parameter type is defined as an integer therefore the integer value  

1307 larger than 2147483647 will not be set properly as it causes an overflow. 

1308  

1309 Iterations are typically defined as the selecting one flux component 

1310 and partially subtracting it out from the residual image. 

1311  

1312 niter=0 : Do only the initial major cycle (make dirty image, psf, pb, etc). 

1313  

1314 niter larger than zero : Run major and minor cycles. 

1315  

1316 Note : Global stopping criteria vs major-cycle triggers. 

1317  

1318 In addition to global stopping criteria, the following rules are 

1319 used to determine when to terminate a set of minor cycle iterations 

1320 and trigger major cycles [derived from Cotton-Schwab Clean, 1984]. 

1321  

1322 'cycleniter' : controls the maximum number of iterations per image 

1323 plane before triggering a major cycle. 

1324 'cyclethreshold' : Automatically computed threshold related to the 

1325 max sidelobe level of the PSF and peak residual. 

1326 Divergence, detected as an increase of 10% in peak residual from the 

1327 minimum so far (during minor cycle iterations). 

1328  

1329 The first criterion to be satisfied takes precedence. 

1330  

1331 Note : Iteration counts for cubes or multi-field images : 

1332 For images with multiple planes (or image fields) on which the 

1333 deconvolver operates in sequence, iterations are counted across 

1334 all planes (or image fields). The iteration count is compared with 

1335 'niter' only after all channels/planes/fields have completed their 

1336 minor cycles and exited either due to 'cycleniter' or 'cyclethreshold'. 

1337 Therefore, the actual number of iterations reported in the logger 

1338 can sometimes be larger than the user specified value in 'niter'. 

1339 For example, with niter=100, cycleniter=20,nchan=10,threshold=0, 

1340 a total of 200 iterations will be done in the first set of minor cycles 

1341 before the total is compared with niter=100 and it exits. 

1342  

1343 Note : Additional global stopping criteria include: 

1344 - no change in peak residual across two major cycles. 

1345 - a 50% or more increase in peak residual across one major cycle. 

1346 gain Loop gain. 

1347  

1348 Fraction of the source flux to subtract out of the residual image 

1349 for the CLEAN algorithm and its variants. 

1350  

1351 A low value (0.2 or less) is recommended when the sky brightness 

1352 distribution is not well represented by the basis functions used by 

1353 the chosen deconvolution algorithm. A higher value can be tried when 

1354 there is a good match between the true sky brightness structure and 

1355 the basis function shapes. For example, for extended emission, 

1356 multiscale clean with an appropriate set of scale sizes will tolerate 

1357 a higher loop gain than Clark clean. 

1358 threshold Stopping threshold (number in units of Jy, or string). 

1359  

1360 A global stopping threshold that the peak residual (within clean mask) 

1361 across all image planes is compared to. 

1362  

1363 threshold = 0.005 : 5mJy 

1364 threshold = '5.0mJy' 

1365  

1366 Note : A 'cyclethreshold' is internally computed and used as a major cycle 

1367 trigger. It is related to what fraction of the PSF can be reliably 

1368 used during minor cycle updates of the residual image. By default 

1369 the minor cycle iterations terminate once the peak residual reaches 

1370 the first sidelobe level of the brightest source. 

1371  

1372 'cyclethreshold' is computed as follows using the settings in 

1373 parameters 'cyclefactor','minpsffraction','maxpsffraction','threshold' : 

1374  

1375 psf_fraction = max_psf_sidelobe_level \* 'cyclefactor' 

1376 psf_fraction = max(psf_fraction, 'minpsffraction'); 

1377 psf_fraction = min(psf_fraction, 'maxpsffraction'); 

1378 cyclethreshold = peak_residual \* psf_fraction 

1379 cyclethreshold = max( cyclethreshold, 'threshold' ) 

1380  

1381 If nsigma is set (>0.0), the N-sigma threshold is calculated (see 

1382 the description under nsigma), then cyclethreshold is further modified as, 

1383  

1384 cyclethreshold = max( cyclethreshold, nsgima_threshold ). 

1385  

1386  

1387 'cyclethreshold' is made visible and editable only in the 

1388 interactive GUI when tclean is run with interactive=True. 

1389 nsigma Multiplicative factor for rms-based threshold stopping. 

1390  

1391 N-sigma threshold is calculated as nsigma \* rms value per image plane determined 

1392 from a robust statistics. For nsigma > 0.0, in a minor cycle, a maximum of the two values, 

1393 the N-sigma threshold and cyclethreshold, is used to trigger a major cycle 

1394 (see also the descreption under 'threshold'). 

1395 Set nsigma=0.0 to preserve the previous tclean behavior without this feature. 

1396 The top level parameter, fastnoise is relevant for the rms noise calculation which is used  

1397 to determine the threshold.  

1398  

1399 The parameter 'nsigma' may be an int, float, or a double. 

1400 cycleniter Maximum number of minor-cycle iterations (per plane) before triggering 

1401 a major cycle. 

1402  

1403 For example, for a single plane image, if niter=100 and cycleniter=20, 

1404 there will be 5 major cycles after the initial one (assuming there is no 

1405 threshold based stopping criterion). At each major cycle boundary, if 

1406 the number of iterations left over (to reach niter) is less than cycleniter, 

1407 it is set to the difference. 

1408  

1409 Note : cycleniter applies per image plane, even if cycleniter x nplanes 

1410 gives a total number of iterations greater than 'niter'. This is to 

1411 preserve consistency across image planes within one set of minor 

1412 cycle iterations. 

1413 cyclefactor Scaling on PSF sidelobe level to compute the minor-cycle stopping threshold. 

1414  

1415 Please refer to the Note under the documentation for 'threshold' that 

1416 discussed the calculation of 'cyclethreshold'. 

1417  

1418 cyclefactor=1.0 results in a cyclethreshold at the first sidelobe level of 

1419 the brightest source in the residual image before the minor cycle starts. 

1420  

1421 cyclefactor=0.5 allows the minor cycle to go deeper. 

1422 cyclefactor=2.0 triggers a major cycle sooner. 

1423 minpsffraction PSF fraction that marks the max depth of cleaning in the minor cycle. 

1424  

1425 Please refer to the Note under the documentation for 'threshold' that 

1426 discussed the calculation of 'cyclethreshold'. 

1427  

1428 For example, minpsffraction=0.5 will stop cleaning at half the height of 

1429 the peak residual and trigger a major cycle earlier. 

1430 maxpsffraction PSF fraction that marks the minimum depth of cleaning in the minor cycle. 

1431  

1432 Please refer to the Note under the documentation for 'threshold' that 

1433 discussed the calculation of 'cyclethreshold'. 

1434  

1435 For example, maxpsffraction=0.8 will ensure that at least the top 20 

1436 percent of the source will be subtracted out in the minor cycle even if 

1437 the first PSF sidelobe is at the 0.9 level (an extreme example), or if the 

1438 cyclefactor is set too high for anything to get cleaned. 

1439 interactive Modify masks and parameters at runtime. 

1440  

1441 interactive=True will trigger an interactive GUI at every major cycle 

1442 boundary (after the major cycle and before the minor cycle). 

1443  

1444 Options for runtime parameter modification are : 

1445  

1446 Interactive clean mask : Draw a 1/0 mask (appears as a contour) by hand. 

1447 If a mask is supplied at the task interface or if 

1448 automasking is invoked, the current mask is 

1449 displayed in the GUI and is available for manual 

1450 editing. 

1451  

1452 Note : If a mask contour is not visible, please 

1453 check the cursor display at the bottom of 

1454 GUI to see which parts of the mask image 

1455 have ones and zeros. If the entire mask=1 

1456 no contours will be visible. 

1457  

1458  

1459 Operation buttons : -- Stop execution now (restore current model and exit). 

1460 -- Continue on until global stopping criteria are reached 

1461 without stopping for any more interaction. 

1462 -- Continue with minor cycles and return for interaction 

1463 after the next major cycle. 

1464  

1465 Iteration control : -- max cycleniter : Trigger for the next major cycle. 

1466  

1467 The display begins with 

1468 [ min( cycleniter, niter - itercount ) ] 

1469 and can be edited by hand. 

1470  

1471 -- iterations left : The display begins with [niter-itercount ] 

1472 and can be edited to increase or 

1473 decrease the total allowed niter. 

1474  

1475 -- threshold : Edit global stopping threshold. 

1476  

1477 -- cyclethreshold : The display begins with the 

1478 automatically computed value 

1479 (see Note in help for 'threshold'), 

1480 and can be edited by hand. 

1481  

1482 All edits will be reflected in the log messages that appear 

1483 once minor cycles begin. 

1484 nmajor The nmajor parameter limits the number of minor and major cycle sets 

1485 that tclean executes. It is defined as the number of major cycles after the  

1486 initial set of minor cycle iterations. In other words, the count of nmajor does  

1487 not include the initial residual calculation that occurs when calcres=True.  

1488  

1489 A setting of nmajor=-1 implies no limit (default -1).  

1490 A setting of nmajor=0 implies nothing other than the initial residual calculation 

1491 A setting of nmajor>0 imples that nmajor sets of minor and major cycles will  

1492 be done in addition to the initial residual calculation.  

1493  

1494 If the major cycle limit is reached, stopcode 9 will be returned. Other stopping 

1495 criteria (such as threshold) could cause tclean to stop in fewer than this 

1496 number of major cycles. If tclean reaches another stopping criteria, first 

1497 or at the same time as nmajor, then that stopcode will be returned instead. 

1498  

1499 Note however that major cycle ids in the log messages as well as in the return 

1500 dictionary do begin with 1 for the initial residual calculation, when it exists.  

1501  

1502 Example 1 : A tclean run with 'nmajor=5' and 'calcres=True' will iterate for 

1503 5 major cycles (not counting the initial residual calculation). But, the return 

1504 dictionary will show 'nmajordone:6'. If 'calcres=False', then the return 

1505 dictionary will show 'nmajordone:5'.  

1506  

1507 Example 2 : For both the following cases, there will be a printout in the logs  

1508 "Running Major Cycle 1" and the return value will include "nmajordone: 1",  

1509 however there is a difference in the purpose of the major cycle and the  

1510 number of minor cycles executed: 

1511 Case 1; nmajor=0, calcres=True: The major cycle done is for the creation 

1512 of the residual, and no minor cycles are executed. 

1513 Case 2; nmajor=1, calcres=False: The major cycle is done as part of the 

1514 major/minor cycle loop, and 1 minor cycle will be executed. 

1515 fullsummary Return dictionary with complete convergence history. 

1516  

1517 fullsummary=True: A full version of the summary dictionary is returned. 

1518 Keys include 'iterDone','peakRes','modelFlux','cycleThresh' that record the 

1519 convergence state at the end of each set of minor cycle iterations 

1520 separately for each image plane (i.e. channel/stokes) being 

1521 deconvolved. Additional keys report the convergence state at the 

1522 start of minor cycle iterations, stopping criteria that triggered major 

1523 cycles, and a processor ID per channel, for parallel cube runs. 

1524  

1525 fullsummary=False (default): A shorten version of the summary dictionary is returned 

1526 with only 'iterDone','peakRes','modelFlux', and 'cycleThresh'. 

1527  

1528  

1529 Detailed information about the return dictionary fields may be found 

1530 at CASA Docs > Synthesis Imaging > Iteration Control > Returned Dictionary. 

1531  

1532 Note : With some parallel cube imaging runs that have a large number of channels 

1533 and iterations per cube partition in a parallel run, an MPI message passing limit may 

1534 be reached due to the size of the return dictionaries being passed around, causing 

1535 CASA to crash (with fullsummary=True). The limit has been estimated to be reached 

1536 only when nchan_per_chunk x iterdone_per_minorcycleset > 8e+6. The option to set 

1537 fullsummary=False should be used to guard against this. 

1538 usemask Type of mask(s) to be used for deconvolution. 

1539  

1540 user: (default) mask image(s) or user specified region file(s) or string CRTF expression(s). 

1541 subparameters: mask, pbmask. 

1542 pb: primary beam mask. 

1543 subparameter: pbmask. 

1544  

1545 Example: usemask="pb", pbmask=0.2. 

1546 Construct a mask at the 0.2 pb gain level. 

1547 (Currently, this option will work only with 

1548  

1549 gridders that produce .pb (i.e. mosaic, awp2 and awproject) 

1550 or if an externally produced .pb image exists on disk) 

1551  

1552  

1553 auto-multithresh : auto-masking by multiple thresholds for deconvolution. 

1554 subparameters : sidelobethreshold, noisethreshold, lownoisethreshold, negativethrehsold, smoothfactor, 

1555 minbeamfrac, cutthreshold, pbmask, growiterations, dogrowprune, minpercentchange, verbose. 

1556 Additional top level parameter relevant to auto-multithresh: fastnoise. 

1557  

1558 if pbmask is >0.0, the region outside the specified pb gain level is excluded from 

1559 image statistics in determination of the threshold. 

1560  

1561  

1562  

1563  

1564 Note: By default the intermediate mask generated by automask at each deconvolution cycle 

1565 is over-written in the next cycle but one can save them by setting 

1566 the environment variable, SAVE_ALL_AUTOMASKS="true". 

1567 (e.g. in the CASA prompt, os.environ['SAVE_ALL_AUTOMASKS']="true" ) 

1568 The saved CASA mask image name will be imagename.mask.autothresh#, where 

1569 # is the iteration cycle number. 

1570 mask Mask (a list of image name(s) or region file(s) or region string(s). 

1571  

1572  

1573 The name of a CASA image or region file or region string that specifies 

1574 a 1/0 mask to be used for deconvolution. Only locations with value 1 will 

1575 be considered for the centers of flux components in the minor cycle. 

1576 If regions specified fall completely outside of the image, tclean will throw an error. 

1577  

1578 Manual mask options/examples : 

1579  

1580 mask='xxx.mask' : Use this CASA image named xxx.mask and containing 

1581 ones and zeros as the mask.  

1582 If the mask is only different in spatial coordinates from what is being made  

1583 it will be resampled to the target coordinate system before being used. 

1584 The mask has to have the same shape in velocity and Stokes planes 

1585 as the output image. Exceptions are single velocity and/or single 

1586 Stokes plane masks. They will be expanded to cover all velocity and/or 

1587 Stokes planes of the output cube. 

1588  

1589 [ Note : If an error occurs during image resampling or 

1590 if the expected mask does not appear, please try 

1591 using tasks 'imregrid' or 'makemask' to resample 

1592 the mask image onto a CASA image with the target 

1593 shape and coordinates and supply it via the 'mask' 

1594 parameter. ] 

1595  

1596  

1597 mask='xxx.crtf' : A text file with region strings and the following on the first line 

1598 ( #CRTFv0 CASA Region Text Format version 0 ) 

1599 This is the format of a file created via the viewer's region 

1600 tool when saved in CASA region file format. 

1601  

1602 mask='circle[[40pix,40pix],10pix]' : A CASA region string. 

1603  

1604 mask=['xxx.mask','xxx.crtf', 'circle[[40pix,40pix],10pix]'] : a list of masks. 

1605  

1606  

1607  

1608  

1609  

1610 Note : Mask images for deconvolution must contain 1 or 0 in each pixel. 

1611 Such a mask is different from an internal T/F mask that can be 

1612 held within each CASA image. These two types of masks are not 

1613 automatically interchangeable, so please use the makemask task 

1614 to copy between them if you need to construct a 1/0 based mask 

1615 from a T/F one. 

1616  

1617 Note : Work is in progress to generate more flexible masking options and 

1618 enable more controls. 

1619 pbmask Sub-parameter for usemask: primary beam mask. 

1620  

1621 Examples : pbmask=0.0 (default, no pb mask). 

1622 pbmask=0.2 (construct a mask at the 0.2 pb gain level). 

1623 sidelobethreshold Sub-parameter for "auto-multithresh": mask threshold based on sidelobe levels: sidelobethreshold \* max_sidelobe_level \* peak residual. 

1624 noisethreshold Sub-parameter for "auto-multithresh": mask threshold based on the noise level: noisethreshold \* rms + location (=median). 

1625  

1626 The rms is calculated from the median absolute deviation (MAD), with rms = 1.4826\*MAD. 

1627 lownoisethreshold Sub-parameter for "auto-multithresh": mask threshold to grow previously masked regions via binary dilation: lownoisethreshold \* rms in residual image + location (=median). 

1628  

1629 The rms is calculated from the median absolute deviation (MAD), with rms = 1.4826\*MAD. 

1630 negativethreshold Sub-parameter for "auto-multithresh": mask threshold for negative features: -1.0* negativethreshold \* rms + location(=median). 

1631  

1632 The rms is calculated from the median absolute deviation (MAD), with rms = 1.4826\*MAD. 

1633 smoothfactor Sub-parameter for "auto-multithresh": smoothing factor in a unit of the beam. 

1634 minbeamfrac Sub-parameter for "auto-multithresh": minimum beam fraction in size to prune masks smaller than mimbeamfrac \* beam 

1635 <=0.0 : No pruning 

1636 cutthreshold Sub-parameter for "auto-multithresh": threshold to cut the smoothed mask to create a final mask: cutthreshold \* peak of the smoothed mask. 

1637 growiterations Sub-parameter for "auto-multithresh": Maximum number of iterations to perform using binary dilation for growing the mask. 

1638 dogrowprune Experimental sub-parameter for "auto-multithresh": Do pruning on the grow mask. 

1639 minpercentchange If the change in the mask size in a particular channel is less than minpercentchange, stop masking that channel in subsequent cycles. This check is only applied when noise based threshold is used and when the previous clean major cycle had a cyclethreshold value equal to the clean threshold. Values equal to -1.0 (or any value less than 0.0) will turn off this check (the default). Automask will still stop masking if the current channel mask is an empty mask and the noise threshold was used to determine the mask. 

1640 verbose he summary of automasking at the end of each automasking process 

1641 is printed in the logger. Following information per channel will be listed in the summary. 

1642  

1643 chan: channel number. 

1644 masking?: F - stop updating automask for the subsequent iteration cycles. 

1645 RMS: robust rms noise. 

1646 peak: peak in residual image. 

1647 thresh_type: type of threshold used (noise or sidelobe). 

1648 thresh_value: the value of threshold used. 

1649 N_reg: number of the automask regions. 

1650 N_pruned: number of the automask regions removed by pruning. 

1651 N_grow: number of the grow mask regions. 

1652 N_grow_pruned: number of the grow mask regions removed by pruning. 

1653 N_neg_pix: number of pixels for negative mask regions. 

1654  

1655 Note that for a large cube, extra logging may slow down the process. 

1656 fastnoise Only relevant when automask (user='multi-autothresh') and/or n-sigma stopping threshold (nsigma>0.0) are/is used. If it is set to True, a simpler but faster noise calucation is used.  

1657 In this case, the threshold values are determined based on classic statistics (using all 

1658 unmasked pixels for the calculations). 

1659  

1660 If it is set to False, the new noise calculation 

1661 method is used based on pre-existing mask.  

1662  

1663 Case 1: no exiting mask. 

1664 Calculate image statistics using Chauvenet algorithm. 

1665  

1666 Case 2: there is an existing mask. 

1667 Calculate image statistics by classical method on the region 

1668 outside the mask and inside the primary beam mask. 

1669  

1670 In all cases above RMS noise is calculated from the median absolute deviation (MAD). 

1671 restart images (and start from an existing model image) 

1672 or automatically increment the image name and make a new image set. 

1673  

1674 True : Re-use existing images. If imagename.model exists the subsequent 

1675 run will start from this model (i.e. predicting it using current gridder 

1676 settings and starting from the residual image). Care must be taken 

1677 when combining this option with startmodel. Currently, only one or 

1678 the other can be used. 

1679  

1680 startmodel='', imagename.model exists : 

1681 - Start from imagename.model. 

1682 startmodel='xxx', imagename.model does not exist : 

1683 - Start from startmodel. 

1684 startmodel='xxx', imagename.model exists : 

1685 - Exit with an error message requesting the user to pick 

1686 only one model. This situation can arise when doing one 

1687 run with startmodel='xxx' to produce an output 

1688 imagename.model that includes the content of startmodel, 

1689 and wanting to restart a second run to continue deconvolution. 

1690 Startmodel should be set to '' before continuing. 

1691  

1692 If any change in the shape or coordinate system of the image is 

1693 desired during the restart, please change the image name and 

1694 use the startmodel (and mask) parameter(s) so that the old model 

1695 (and mask) can be regridded to the new coordinate system before starting. 

1696  

1697 False : A convenience feature to increment imagename with '_1', '_2', 

1698 etc as suffixes so that all runs of tclean are fresh starts (without 

1699 having to change the imagename parameter or delete images). 

1700  

1701 This mode will search the current directory for all existing 

1702 imagename extensions, pick the maximum, and adds 1. 

1703 For imagename='try' it will make try.psf, try_2.psf, try_3.psf, etc. 

1704  

1705 This also works if you specify a directory name in the path : 

1706 imagename='outdir/try'. If './outdir' does not exist, it will create it. 

1707 Then it will search for existing filenames inside that directory. 

1708  

1709 If outlier fields are specified, the incrementing happens for each 

1710 of them (since each has its own 'imagename'). The counters are 

1711 synchronized across imagefields, to make it easier to match up sets 

1712 of output images. It adds 1 to the 'max id' from all outlier names 

1713 on disk. So, if you do two runs with only the main field 

1714 (imagename='try'), and in the third run you add an outlier with 

1715 imagename='outtry', you will get the following image names 

1716 for the third run : 'try_3' and 'outtry_3' even though 

1717 'outry' and 'outtry_2' have not been used. 

1718 savemodel Options to save model visibilities (none, virtual, modelcolumn). 

1719  

1720 Often, model visibilities must be created and saved in the MS 

1721 to be later used for self-calibration (or to just plot and view them). 

1722  

1723 none : Do not save any model visibilities in the MS. The MS is opened 

1724 in readonly mode. 

1725  

1726 Model visibilities can be predicted in a separate step by 

1727 restarting tclean with niter=0,savemodel=virtual or modelcolumn 

1728 and not changing any image names so that it finds the .model on 

1729 disk (or by changing imagename and setting startmodel to the 

1730 original imagename). 

1731  

1732 virtual : In the last major cycle, save the image model and state of the 

1733 gridder used during imaging within the SOURCE subtable of the 

1734 MS. Images required for de-gridding will also be stored internally. 

1735 All future references to model visibilities will activate the 

1736 (de)gridder to compute them on-the-fly. This mode is useful 

1737 when the dataset is large enough that an additional model data 

1738 column on disk may be too much extra disk I/O, when the 

1739 gridder is simple enough that on-the-fly recomputing of the 

1740 model visibilities is quicker than disk I/O. 

1741 For e.g. that gridder='awproject' and 'awp2' does not support virtual model.  

1742  

1743 modelcolumn : In the last major cycle, save predicted model visibilities 

1744 in the MODEL_DATA column of the MS. This mode is useful when 

1745 the de-gridding cost to produce the model visibilities is higher 

1746 than the I/O required to read the model visibilities from disk. 

1747 This mode is currently required for gridder='awproject' and 'awp2'. 

1748 This mode is also required for the ability to later pull out 

1749 model visibilities from the MS into a python array for custom 

1750 processing. 

1751  

1752 Note 1 : The imagename.model image on disk will always be constructed 

1753 if the minor cycle runs. This savemodel parameter applies only to 

1754 model visibilities created by de-gridding the model image. 

1755  

1756 Note 2 : It is possible for an MS to have both a virtual model 

1757 as well as a model_data column, but under normal operation, 

1758 the last used mode will get triggered. Use the delmod task to 

1759 clear out existing models from an MS if confusion arises. 

1760 Note 3: when parallel=True, use savemodel='none'; Other options are not yet ready  

1761 for use in parallel. If model visibilities need to be saved (virtual or modelcolumn): 

1762 please run tclean in serial mode with niter=0; after the parallel run 

1763 calcres Calculate initial residual image. 

1764  

1765 This parameter controls what the first major cycle does. 

1766  

1767 calcres=False with niter greater than 0 will assume that 

1768 a .residual image already exists and that the minor cycle can 

1769 begin without recomputing it. 

1770  

1771 calcres=False with niter=0 implies that only the PSF will be made 

1772 and no data will be gridded. 

1773  

1774 calcres=True requires that calcpsf=True or that the .psf and .sumwt 

1775 images already exist on disk (for normalization purposes). 

1776  

1777 Usage example : For large runs (or a pipeline scripts) it may be 

1778 useful to first run tclean with niter=0 to create 

1779 an initial .residual to look at and perhaps make 

1780 a custom mask for. Imaging can be resumed 

1781 without recomputing it. 

1782 calcpsf Calculate PSF 

1783  

1784 This parameter controls what the first major cycle does. 

1785  

1786 calcpsf=False will assume that a .psf image already exists 

1787 and that the minor cycle can begin without recomputing it. 

1788 psfcutoff When the .psf image is created a 2 dimensional Gaussian is fit to the main lobe of the PSF. 

1789 Which pixels in the PSF are fitted is determined by psfcutoff. 

1790 The default value of psfcutoff is 0.35 and can varied from 0.01 to 0.99. 

1791 Fitting algorithm: 

1792 - A region of 41 x 41 pixels around the peak of the PSF is compared against the psfcutoff. 

1793 Sidelobes are ignored by radially searching from the PSF peak. 

1794 - Calculate the bottom left corner (blc) and top right corner (trc) from the points. Expand blc and trc with a number of pixels (5). 

1795 - Create a new sub-matrix from blc and trc. 

1796 - Interpolate matrix to a target number of points (3001) using CUBIC spline. 

1797 - All the non-sidelobe points, in the interpolated matrix, that are above the psfcutoff are used to fit a Gaussian. 

1798 A Levenberg-Marquardt algorithm is used. 

1799 - If the fitting fails the algorithm is repeated with the psfcutoff decreased (psfcutoff=psfcutoff/1.5). 

1800 A message in the log will apear if the fitting fails along with the new value of psfcutoff. 

1801 This will be done up to 50 times if fitting fails. 

1802 This Gaussian beam is defined by a major axis, minor axis, and position angle. 

1803 During the restoration process, this Gaussian beam is used as the Clean beam. 

1804 Varying psfcutoff might be useful for producing a better fit for highly non-Gaussian PSFs, however, the resulting fits should be carefully checked. 

1805 This parameter should rarely be changed. 

1806  

1807 (This is not the support size for clark clean.) 

1808 parallel Run major cycles in parallel. 

1809  

1810 Parallel tclean will run only if casa has already been started using mpirun. 

1811 Please refer to external resources on high performance computing for details on how to start this on your system. 

1812  

1813 Example : mpirun -n 3 -xterm 0 `which casa` 

1814  

1815 Continuum Imaging : 

1816 - Data are partitioned (in time) into NProc pieces. 

1817 - Gridding/iFT is done separately per partition. 

1818 - Images (and weights) are gathered and then normalized. 

1819 - One non-parallel minor cycle is run. 

1820 - Model image is scattered to all processes. 

1821 - Major cycle is done in parallel per partition. 

1822  

1823 Cube Imaging : 

1824 - Data and Image coordinates are partitioned (in freq) into NProc pieces. 

1825 - Each partition is processed independently (major and minor cycles). 

1826 - All processes are synchronized at major cycle boundaries for convergence checks. 

1827 - At the end, cubes from all partitions are concatenated along the spectral axis. 

1828  

1829 Note 1 : Iteration control for cube imaging is independent per partition. 

1830 - There is currently no communication between them to synchronize 

1831 information such as peak residual and cyclethreshold. Therefore, 

1832 different chunks may trigger major cycles at different levels. 

1833 (Proper synchronization of iteration control is work in progress.) 

1834 RETURNS void 

1835 

1836 --------- examples ----------------------------------------------------------- 

1837 

1838  

1839  

1840 For more information, see the task pages of tclean in CASA Docs: 

1841  

1842 https://casadocs.readthedocs.io 

1843  

1844  

1845  

1846 

1847 

1848 """ 

1849 

1850 _info_group_ = """imaging""" 

1851 _info_desc_ = """Radio Interferometric Image Reconstruction""" 

1852 

1853 def __call__( self, vis='', selectdata=True, field='', spw='', timerange='', uvrange='', antenna='', scan='', observation='', intent='', datacolumn='corrected', imagename='', imsize=[ int(100) ], cell=[ ], phasecenter='', stokes='I', projection='SIN', startmodel='', specmode='mfs', reffreq='', nchan=int(-1), start='', width='', outframe='LSRK', veltype='radio', restfreq=[ ], interpolation='linear', perchanweightdensity=True, gridder='standard', facets=int(1), psfphasecenter='', wprojplanes=int(1), vptable='', mosweight=True, aterm=True, psterm=False, wbawp=True, conjbeams=False, cfcache='', usepointing=False, computepastep=float(360.0), rotatepastep=float(360.0), pointingoffsetsigdev=[ ], pblimit=float(0.2), normtype='flatnoise', deconvolver='hogbom', scales=[ ], nterms=int(2), smallscalebias=float(0.0), fusedthreshold=float(0.0), largestscale=int(-1), restoration=True, restoringbeam=[ ], pbcor=False, outlierfile='', weighting='natural', robust=float(0.5), noise='1.0Jy', npixels=int(0), uvtaper=[ '' ], niter=int(0), gain=float(0.1), threshold=float(0.0), nsigma=float(0.0), cycleniter=int(-1), cyclefactor=float(1.0), minpsffraction=float(0.05), maxpsffraction=float(0.8), interactive=False, nmajor=int(-1), fullsummary=False, usemask='user', mask='', pbmask=float(0.0), sidelobethreshold=float(3.0), noisethreshold=float(5.0), lownoisethreshold=float(1.5), negativethreshold=float(0.0), smoothfactor=float(1.0), minbeamfrac=float(0.3), cutthreshold=float(0.01), growiterations=int(75), dogrowprune=True, minpercentchange=float(-1.0), verbose=False, fastnoise=True, restart=True, savemodel='none', calcres=True, calcpsf=True, psfcutoff=float(0.35), parallel=False ): 

1854 schema = {'vis': {'anyof': [{'type': 'cReqPath', 'coerce': _coerce.expand_path}, {'type': 'cReqPathVec', 'coerce': [_coerce.to_list,_coerce.expand_pathvec]}]}, 'selectdata': {'type': 'cBool'}, 'field': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'spw': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'timerange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'uvrange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'antenna': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'scan': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'observation': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}]}, 'intent': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str}, 'imagename': {'anyof': [{'type': 'cInt'}, {'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'imsize': {'anyof': [{'type': 'cInt'}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'cell': {'anyof': [{'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, {'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cInt'}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}]}, 'phasecenter': {'anyof': [{'type': 'cInt'}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'stokes': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'I', 'IQUV', 'UV', 'RRLL', 'IQ', 'V', 'pseudoI', 'QU', 'YY', 'RR', 'Q', 'U', 'IV', 'XX', 'XXYY', 'LL' ]}, 'projection': {'type': 'cStr', 'coerce': _coerce.to_str}, 'startmodel': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'specmode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'cont', 'cubedata', 'cube', 'cubesource', 'mfs', 'mvc' ]}, 'reffreq': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'nchan': {'type': 'cInt'}, 'start': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'width': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'outframe': {'type': 'cStr', 'coerce': _coerce.to_str}, 'veltype': {'type': 'cStr', 'coerce': _coerce.to_str}, 'restfreq': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'interpolation': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'nearest', 'linear', 'cubic' ]}, 'perchanweightdensity': {'type': 'cBool'}, 'gridder': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'widefield', 'wproject', 'awphpg', 'imagemosaic', 'standard', 'awproject', 'wprojectft', 'mosaicft', 'ft', 'ftmosaic', 'mosaic', 'awprojectft', 'gridft', 'awp2' ]}, 'facets': {'type': 'cInt'}, 'psfphasecenter': {'anyof': [{'type': 'cInt'}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'wprojplanes': {'type': 'cInt'}, 'vptable': {'type': 'cStr', 'coerce': _coerce.to_str}, 'mosweight': {'type': 'cBool'}, 'aterm': {'type': 'cBool'}, 'psterm': {'type': 'cBool'}, 'wbawp': {'type': 'cBool'}, 'conjbeams': {'type': 'cBool'}, 'cfcache': {'type': 'cStr', 'coerce': _coerce.to_str}, 'usepointing': {'type': 'cBool'}, 'computepastep': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'rotatepastep': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'pointingoffsetsigdev': {'anyof': [{'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}]}, 'pblimit': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'normtype': {'type': 'cStr', 'coerce': _coerce.to_str}, 'deconvolver': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'clarkstokes_exp', 'mtmfs', 'mem', 'clarkstokes', 'hogbom', 'clark_exp', 'clark', 'asp', 'multiscale' ]}, 'scales': {'anyof': [{'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}]}, 'nterms': {'type': 'cInt'}, 'smallscalebias': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'fusedthreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'largestscale': {'type': 'cInt'}, 'restoration': {'type': 'cBool'}, 'restoringbeam': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'pbcor': {'type': 'cBool'}, 'outlierfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'weighting': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'briggsabs', 'briggs', 'briggsbwtaper', 'natural', 'radial', 'superuniform', 'uniform' ]}, 'robust': {'type': 'cFloat', 'coerce': _coerce.to_float, 'min': -2.0, 'max': 2.0}, 'noise': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'npixels': {'type': 'cInt'}, 'uvtaper': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'niter': {'type': 'cInt'}, 'gain': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'threshold': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'nsigma': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'cycleniter': {'type': 'cInt'}, 'cyclefactor': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'minpsffraction': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'maxpsffraction': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'interactive': {'type': 'cBool'}, 'nmajor': {'type': 'cInt'}, 'fullsummary': {'type': 'cBool'}, 'usemask': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'user', 'pb', 'auto-multithresh' ]}, 'mask': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'pbmask': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'sidelobethreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'noisethreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'lownoisethreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'negativethreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'smoothfactor': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'minbeamfrac': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'cutthreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'growiterations': {'type': 'cInt'}, 'dogrowprune': {'type': 'cBool'}, 'minpercentchange': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'verbose': {'type': 'cBool'}, 'fastnoise': {'type': 'cBool'}, 'restart': {'type': 'cBool'}, 'savemodel': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'none', 'virtual', 'modelcolumn' ]}, 'calcres': {'type': 'cBool'}, 'calcpsf': {'type': 'cBool'}, 'psfcutoff': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'parallel': {'type': 'cBool'}} 

1855 doc = {'vis': vis, 'selectdata': selectdata, 'field': field, 'spw': spw, 'timerange': timerange, 'uvrange': uvrange, 'antenna': antenna, 'scan': scan, 'observation': observation, 'intent': intent, 'datacolumn': datacolumn, 'imagename': imagename, 'imsize': imsize, 'cell': cell, 'phasecenter': phasecenter, 'stokes': stokes, 'projection': projection, 'startmodel': startmodel, 'specmode': specmode, 'reffreq': reffreq, 'nchan': nchan, 'start': start, 'width': width, 'outframe': outframe, 'veltype': veltype, 'restfreq': restfreq, 'interpolation': interpolation, 'perchanweightdensity': perchanweightdensity, 'gridder': gridder, 'facets': facets, 'psfphasecenter': psfphasecenter, 'wprojplanes': wprojplanes, 'vptable': vptable, 'mosweight': mosweight, 'aterm': aterm, 'psterm': psterm, 'wbawp': wbawp, 'conjbeams': conjbeams, 'cfcache': cfcache, 'usepointing': usepointing, 'computepastep': computepastep, 'rotatepastep': rotatepastep, 'pointingoffsetsigdev': pointingoffsetsigdev, 'pblimit': pblimit, 'normtype': normtype, 'deconvolver': deconvolver, 'scales': scales, 'nterms': nterms, 'smallscalebias': smallscalebias, 'fusedthreshold': fusedthreshold, 'largestscale': largestscale, 'restoration': restoration, 'restoringbeam': restoringbeam, 'pbcor': pbcor, 'outlierfile': outlierfile, 'weighting': weighting, 'robust': robust, 'noise': noise, 'npixels': npixels, 'uvtaper': uvtaper, 'niter': niter, 'gain': gain, 'threshold': threshold, 'nsigma': nsigma, 'cycleniter': cycleniter, 'cyclefactor': cyclefactor, 'minpsffraction': minpsffraction, 'maxpsffraction': maxpsffraction, 'interactive': interactive, 'nmajor': nmajor, 'fullsummary': fullsummary, 'usemask': usemask, 'mask': mask, 'pbmask': pbmask, 'sidelobethreshold': sidelobethreshold, 'noisethreshold': noisethreshold, 'lownoisethreshold': lownoisethreshold, 'negativethreshold': negativethreshold, 'smoothfactor': smoothfactor, 'minbeamfrac': minbeamfrac, 'cutthreshold': cutthreshold, 'growiterations': growiterations, 'dogrowprune': dogrowprune, 'minpercentchange': minpercentchange, 'verbose': verbose, 'fastnoise': fastnoise, 'restart': restart, 'savemodel': savemodel, 'calcres': calcres, 'calcpsf': calcpsf, 'psfcutoff': psfcutoff, 'parallel': parallel} 

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

1857 _logging_state_ = _start_log( 'tclean', [ 'vis=' + repr(_pc.document['vis']), 'selectdata=' + repr(_pc.document['selectdata']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'timerange=' + repr(_pc.document['timerange']), 'uvrange=' + repr(_pc.document['uvrange']), 'antenna=' + repr(_pc.document['antenna']), 'scan=' + repr(_pc.document['scan']), 'observation=' + repr(_pc.document['observation']), 'intent=' + repr(_pc.document['intent']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'imagename=' + repr(_pc.document['imagename']), 'imsize=' + repr(_pc.document['imsize']), 'cell=' + repr(_pc.document['cell']), 'phasecenter=' + repr(_pc.document['phasecenter']), 'stokes=' + repr(_pc.document['stokes']), 'projection=' + repr(_pc.document['projection']), 'startmodel=' + repr(_pc.document['startmodel']), 'specmode=' + repr(_pc.document['specmode']), 'reffreq=' + repr(_pc.document['reffreq']), 'nchan=' + repr(_pc.document['nchan']), 'start=' + repr(_pc.document['start']), 'width=' + repr(_pc.document['width']), 'outframe=' + repr(_pc.document['outframe']), 'veltype=' + repr(_pc.document['veltype']), 'restfreq=' + repr(_pc.document['restfreq']), 'interpolation=' + repr(_pc.document['interpolation']), 'perchanweightdensity=' + repr(_pc.document['perchanweightdensity']), 'gridder=' + repr(_pc.document['gridder']), 'facets=' + repr(_pc.document['facets']), 'psfphasecenter=' + repr(_pc.document['psfphasecenter']), 'wprojplanes=' + repr(_pc.document['wprojplanes']), 'vptable=' + repr(_pc.document['vptable']), 'mosweight=' + repr(_pc.document['mosweight']), 'aterm=' + repr(_pc.document['aterm']), 'psterm=' + repr(_pc.document['psterm']), 'wbawp=' + repr(_pc.document['wbawp']), 'conjbeams=' + repr(_pc.document['conjbeams']), 'cfcache=' + repr(_pc.document['cfcache']), 'usepointing=' + repr(_pc.document['usepointing']), 'computepastep=' + repr(_pc.document['computepastep']), 'rotatepastep=' + repr(_pc.document['rotatepastep']), 'pointingoffsetsigdev=' + repr(_pc.document['pointingoffsetsigdev']), 'pblimit=' + repr(_pc.document['pblimit']), 'normtype=' + repr(_pc.document['normtype']), 'deconvolver=' + repr(_pc.document['deconvolver']), 'scales=' + repr(_pc.document['scales']), 'nterms=' + repr(_pc.document['nterms']), 'smallscalebias=' + repr(_pc.document['smallscalebias']), 'fusedthreshold=' + repr(_pc.document['fusedthreshold']), 'largestscale=' + repr(_pc.document['largestscale']), 'restoration=' + repr(_pc.document['restoration']), 'restoringbeam=' + repr(_pc.document['restoringbeam']), 'pbcor=' + repr(_pc.document['pbcor']), 'outlierfile=' + repr(_pc.document['outlierfile']), 'weighting=' + repr(_pc.document['weighting']), 'robust=' + repr(_pc.document['robust']), 'noise=' + repr(_pc.document['noise']), 'npixels=' + repr(_pc.document['npixels']), 'uvtaper=' + repr(_pc.document['uvtaper']), 'niter=' + repr(_pc.document['niter']), 'gain=' + repr(_pc.document['gain']), 'threshold=' + repr(_pc.document['threshold']), 'nsigma=' + repr(_pc.document['nsigma']), 'cycleniter=' + repr(_pc.document['cycleniter']), 'cyclefactor=' + repr(_pc.document['cyclefactor']), 'minpsffraction=' + repr(_pc.document['minpsffraction']), 'maxpsffraction=' + repr(_pc.document['maxpsffraction']), 'interactive=' + repr(_pc.document['interactive']), 'nmajor=' + repr(_pc.document['nmajor']), 'fullsummary=' + repr(_pc.document['fullsummary']), 'usemask=' + repr(_pc.document['usemask']), 'mask=' + repr(_pc.document['mask']), 'pbmask=' + repr(_pc.document['pbmask']), 'sidelobethreshold=' + repr(_pc.document['sidelobethreshold']), 'noisethreshold=' + repr(_pc.document['noisethreshold']), 'lownoisethreshold=' + repr(_pc.document['lownoisethreshold']), 'negativethreshold=' + repr(_pc.document['negativethreshold']), 'smoothfactor=' + repr(_pc.document['smoothfactor']), 'minbeamfrac=' + repr(_pc.document['minbeamfrac']), 'cutthreshold=' + repr(_pc.document['cutthreshold']), 'growiterations=' + repr(_pc.document['growiterations']), 'dogrowprune=' + repr(_pc.document['dogrowprune']), 'minpercentchange=' + repr(_pc.document['minpercentchange']), 'verbose=' + repr(_pc.document['verbose']), 'fastnoise=' + repr(_pc.document['fastnoise']), 'restart=' + repr(_pc.document['restart']), 'savemodel=' + repr(_pc.document['savemodel']), 'calcres=' + repr(_pc.document['calcres']), 'calcpsf=' + repr(_pc.document['calcpsf']), 'psfcutoff=' + repr(_pc.document['psfcutoff']), 'parallel=' + repr(_pc.document['parallel']) ] ) 

1858 task_result = None 

1859 try: 

1860 task_result = _tclean_t( _pc.document['vis'], _pc.document['selectdata'], _pc.document['field'], _pc.document['spw'], _pc.document['timerange'], _pc.document['uvrange'], _pc.document['antenna'], _pc.document['scan'], _pc.document['observation'], _pc.document['intent'], _pc.document['datacolumn'], _pc.document['imagename'], _pc.document['imsize'], _pc.document['cell'], _pc.document['phasecenter'], _pc.document['stokes'], _pc.document['projection'], _pc.document['startmodel'], _pc.document['specmode'], _pc.document['reffreq'], _pc.document['nchan'], _pc.document['start'], _pc.document['width'], _pc.document['outframe'], _pc.document['veltype'], _pc.document['restfreq'], _pc.document['interpolation'], _pc.document['perchanweightdensity'], _pc.document['gridder'], _pc.document['facets'], _pc.document['psfphasecenter'], _pc.document['wprojplanes'], _pc.document['vptable'], _pc.document['mosweight'], _pc.document['aterm'], _pc.document['psterm'], _pc.document['wbawp'], _pc.document['conjbeams'], _pc.document['cfcache'], _pc.document['usepointing'], _pc.document['computepastep'], _pc.document['rotatepastep'], _pc.document['pointingoffsetsigdev'], _pc.document['pblimit'], _pc.document['normtype'], _pc.document['deconvolver'], _pc.document['scales'], _pc.document['nterms'], _pc.document['smallscalebias'], _pc.document['fusedthreshold'], _pc.document['largestscale'], _pc.document['restoration'], _pc.document['restoringbeam'], _pc.document['pbcor'], _pc.document['outlierfile'], _pc.document['weighting'], _pc.document['robust'], _pc.document['noise'], _pc.document['npixels'], _pc.document['uvtaper'], _pc.document['niter'], _pc.document['gain'], _pc.document['threshold'], _pc.document['nsigma'], _pc.document['cycleniter'], _pc.document['cyclefactor'], _pc.document['minpsffraction'], _pc.document['maxpsffraction'], _pc.document['interactive'], _pc.document['nmajor'], _pc.document['fullsummary'], _pc.document['usemask'], _pc.document['mask'], _pc.document['pbmask'], _pc.document['sidelobethreshold'], _pc.document['noisethreshold'], _pc.document['lownoisethreshold'], _pc.document['negativethreshold'], _pc.document['smoothfactor'], _pc.document['minbeamfrac'], _pc.document['cutthreshold'], _pc.document['growiterations'], _pc.document['dogrowprune'], _pc.document['minpercentchange'], _pc.document['verbose'], _pc.document['fastnoise'], _pc.document['restart'], _pc.document['savemodel'], _pc.document['calcres'], _pc.document['calcpsf'], _pc.document['psfcutoff'], _pc.document['parallel'] ) 

1861 except Exception as exc: 

1862 _except_log('tclean', exc) 

1863 raise 

1864 finally: 

1865 task_result = _end_log( _logging_state_, 'tclean', task_result ) 

1866 return task_result 

1867 

1868tclean = _tclean( ) 

1869