Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatools/imager.py: 57%

131 statements  

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

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

2##################### 2aa9396ff96d93f62460a4d6aac96ece ############################## 

3from __future__ import absolute_import 

4from .__casac__.imager import imager as _imager 

5 

6from .errors import create_error_string 

7from .typecheck import CasaValidator as _validator 

8_pc = _validator( ) 

9from .coercetype import coerce as _coerce 

10 

11 

12class imager: 

13 _info_group_ = """imager""" 

14 _info_desc_ = """tool for synthesis imaging""" 

15 ### self 

16 def __init__(self, *args, **kwargs): 

17 """This is used to construct {tt imager} tools associated 

18 with a MeasurementSet. The {tt imager} tool may then be 

19 used to generate various types of images. Note that 

20 a new executable is started every time the constructor 

21 is called. 

22  

23 This returns a Glish variable containing the tool functions of 

24 imager in an alternate universe that you have to tunnel to with a wormhole 

25 """ 

26 self._swigobj = kwargs.get('swig_object',None) 

27 if self._swigobj is None: 

28 self._swigobj = _imager() 

29 

30 def advise(self, takeadvice=True, amplitudeloss=float(0.05), fieldofview=[ ]): 

31 """Advise on recommended values of certain parameters. Return these 

32 values and optionally use them in Imager. 

33  

34 The calculations are performed as following: 

35  

36 begin{description} 

37 item[cell] The maximum uv distance in wavelength is found and then half of the 

38 inverse is taken as the maximum cellsize allowed. 

39 item[pixels] The field of view is converted to a number of pixels 

40 using the calculated cell size. 

41 item[facets] The number of facets on an axis is calculated in two 

42 different ways. The first method simply requires that the peeling of 

43 facets away from the celestial sphere should not cause an amplitude 

44 drop of more than the argument {tt amplitudeloss}. The positions may 

45 be incorrect, but all the sources will be removed correctly. The 

46 second method requires that the source positions be accurate to the 

47 same fraction of the beam specified by {tt amplitudeloss}. The 

48 second calculates the second moment in w and in uv distance and 

49 chooses the number of facets correspondingly. The first method does 

50 the same but after fitting a plane to the sampling: $w = a u + b v$. 

51 For an approximately coplanar array, the positions may be wrong but 

52 the removal of sidelobes will be accurate. The number of facets 

53 returned is the second, usually smaller, number. The formula used 

54 is: 

55 begin{equation} 

56 N_{facets} = N_{pixels} sqrt{{{Delta theta}over{sqrt{8 delta A}}}{w_{rms}}over{uv_{rms}}} 

57 end{equation} 

58 where $Delta theta$ is the cellsize in radians, and $delta A$ is 

59 the amplitude loss. This formula can be derived from (a) the peeling 

60 of facets from the celestial sphere, and (b) a quadratic approximation 

61 for the beam size both in the plane of the sky and along the $w$ axis. 

62 end{description} 

63 """ 

64 return self._swigobj.advise(takeadvice, amplitudeloss, fieldofview) 

65 

66 def advisechansel(self, freqstart=float(1.0e6), freqend=float(1.1e6), freqstep=float(100.0), freqframe='LSRK', msname='', fieldid=int(0), getfreqrange=False, spwselection=''): 

67 """Basically tells you what channels of which spectral window need to be 

68 selected for your image spectral parameters. The freqstep is used to 

69 calulate the extra padding needed for data selection at the begining 

70 and end of the range. The freqframe parameter is the frame in which 

71 the frequency range is being given. It will be converted to the frame 

72 of the data with time to locate which channel match. 

73 A record will be returned with an element for each ms used in selectvis. 

74 Each element of the record will have the spwids and channel start and nchan for each spwid. 

75 if the parameter msname is used then the MSs associated associated with 

76 this tool (that have been either 'open'ed or 'selectvis'ed) are ignored 

77 In this mode it is a helper function to the general world ...no need to 

78 open or selectvis. You need to specify the field_id for which this calculation is 

79 being done for in the helper mode. 

80 If you have already set MS's and selected data and msname="" then 

81 the calulation is done for the field(s) selected in selectvis. 

82  

83 If the parameter {tt getfreqrange=True} then the reverse is requested. You set {tt spwselection} to be the range of data selection you want to use and you'll get the range of frequency covered in the frame you set. 

84 """ 

85 return self._swigobj.advisechansel(freqstart, freqend, freqstep, freqframe, msname, fieldid, getfreqrange, spwselection) 

86 

87 def approximatepsf(self, psf=''): 

88 """Calculate the approximate point spread function. 

89 {em Note that the model visibilities are updated}. 

90  

91 Some types of imaging do not yield a well-defined point spread 

92 function. For example, mosaicing or single dish imaging both yield 

93 point spread functions that are position dependent. Nevertheless, one 

94 can still usefully define an {em approximate} PSF that is of some 

95 utility. This is calculated by doing the following calculation: a 

96 point source is located at the center of the specified coordinate 

97 system and the model data predicted. The approximate PSF is then formed from 

98 those model data using the full sky equation. For regular sampling in 

99 the image plane, this approximate PSF is actually quite good. It can 

100 be used in a deconvolution. For a mosaic with similar uv sampling per 

101 pointing, the approximate PSF is roughly the PSF per pointing 

102 multiplied by the primary beam. For a single dish image, it is roughly 

103 the telescope primary beam convolved with itself (if the 

104 gridfunction='pb' was selected). 

105 """ 

106 return self._swigobj.approximatepsf(psf) 

107 

108 def boxmask(self, mask='', blc=[ int(0),int(0),int(0),int(0) ], trc=[ ], value=float(1.0)): 

109 """A mask image is an image with the same shape as the other images but 

110 with values between 0.0 and 1.0 as a pixel value. Mask images are used in 

111 imager to control the region selected in a deconvolution. 

112  

113 In the Clark CLEAN, the mask image can usefully have any value between 

114 0.0 and 1.0. Intermediate value discourage but do not rule out 

115 selection of clean components in that region. This is accomplished by 

116 multiplying the residual image by the mask prior to entering the minor 

117 cycle. Note that if you do use a mask for the Clark or Hogbom Clean, 

118 it must cover only a quarter of the image. boxmask does not enforce 

119 this requirement. 

120 """ 

121 return self._swigobj.boxmask(mask, blc, trc, value) 

122 

123 def calcuvw(self, fields=[ int(-1) ], refcode='', reuse=True): 

124 """This calculates (u, v, w) positions for the visibilities using the antenna 

125 and feed positions and offsets, the time, and the phase tracking center(s). 

126  

127 """ 

128 return self._swigobj.calcuvw(fields, refcode, reuse) 

129 

130 def clean(self, algorithm='clark', niter=int(1000), gain=float(0.1), threshold=[ ], displayprogress=False, model=[ ], keepfixed=[ bool(False) ], complist='', mask=[ ], image=[ ], residual=[ ], psfimage=[ ], interactive=False, npercycle=int(100), masktemplate=''): 

131 """Makes a clean image using either the Hogbom, Clark, multi-scale or multi-field 

132 algorithms. The Clark algorithm is the default. The clean is performed 

133 on the residual image calculated from the visibility data currently 

134 selected. Hence the first step performed in clean is to transform the 

135 current model or models (optionally including a componentlist) to fill 

136 in the MODEL_DATA column, and then inverse transform the residual 

137 visibilities to get a residual image. This residual image is then 

138 cleaned using the corresponding point spread function. This means that 

139 the initial model is used as the starting point for the 

140 deconvolution. Thus if you want to restart a clean, simply set the 

141 model to the model that was previously produced by clean. 

142  

143 Rather than explicit CLEAN boxes, mask images are used to constrain 

144 the region that is to be deconvolved. To make mask images, 

145 use either boxmask (to define a mask 

146 via the corner locations blc and trc) or 

147 mask (to define a mask via 

148 thresholding an existing image) or regionmask (to make masks via regions using the regionmanager or interactively through the viewer) . The default mask is the inner quarter 

149 of the image. 

150  

151 The CLEAN deconvolution is joint in whatever Stokes parameters are 

152 present. Thus it searchs for peaks in either $I$ or $I+|V|$ or 

153 $I+sqrt{Q^2+U^2+V^2}$, the rationale for the latter two forms being 

154 to be biased towards finding strongly polarized pixels first (these 

155 forms are also the maximum eigenvalue of the coherency matrix). The 

156 PSF is constrained to be the same in all polarizations (a feature of 

157 this implementation, not of the Hamaker-Bregman-Sault formalism). But the option of 

158 searching peaks in the stokes planes independently is available via 

159 the {tt clarkstokes} parameter 

160  

161  

162  

163 The clean algorithms possible are: 

164 begin{description} 

165 item[Hogbom] The classic algorithm: points are found iteratively 

166 by searching for the peak. Each point is subtracted from the 

167 full residual image using the shifted and scaled point spread 

168 function. 

169 item[Multiscale] An experimental multi-scale clean algorithm is invoked. 

170 The algorithm is fully described in 

171 deconvolver. 

172 item[Clark] The faster algorithm: the cleaning is split into 

173 minor and major cycles. In the minor cycles only the brightest 

174 points are cleaned, using a subset of the point spread function. 

175 In the major cycle, the points thus found are subtracted correctly 

176 by using an FFT-based convolution. 

177 item[Multi-field] Cleaning is split into minor and major 

178 cycles. For each field, a Clark-style minor cycle is performed. 

179 In the major cycle, the points thus found are subtracted 

180 either from the original visibilities (for multiple fields) 

181 or using a convolution (for only one field). The latter is 

182 much faster. Multi-field imaging has been implemented for 

183 Clark, Hogbom, and Multi-scale deconvolution algorithms. 

184 item[Cotton-Schwab] Cleaning is split into minor and major 

185 cycles. For each field, a Clark-style minor cycle is performed. 

186 In the major cycle, the points thus found are subtracted 

187 from the original visibilities. A fast variant does a convolution 

188 using a FFT. This will be faster for large numbers of 

189 visibilities. Double the image size from that used for Cotton-Schwab 

190 and set a mask to clean only the inner quarter. 

191 item[Wide-field] The user will need to use a wide-field algorithm to 

192 deconvolve if the array is not coplanar over the field of view being 

193 imaged . The technique used is to break the field being imaged into 

194 smaller pieces (facets), over each of which the array appear 

195 planar. We implement a rectangular facetting scheme. If the number of 

196 facets specified in defineimage is 

197 greater than one, Either wfhogbom or wfclark algorithm has to be 

198 selected here to perform a wide-field decovolution. The function 

199 advise can be used to calculate or 

200 check if you need to use a wide-field deconvolution. Note that 

201 aliasing can be reduced by using the {tt padding} argument in 

202 setoptions. In practice the 

203 previous sentence means that if you notice the clean to diverge at the 

204 edges of the facets then you need to use a larger amount of padding 

205 for the FT; the default being 1.2. Wide-field imaging has been 

206 implemented for Clark and Hogbom algorithms. 

207 end{description} 

208  

209 The multi-field clean should be used if either of two conditions 

210 hold: 

211 begin{enumerate} 

212 item Multiple fields are to be cleaned simultaneously {bf OR} 

213 item Primary beam correction is enabled. In this case, a 

214 mosaiced clean is performed. 

215 end{enumerate} 

216  

217 Note that for the single pointing algorithms, only a quarter of the 

218 image may be cleaned. If no mask is set, then the cleaned region 

219 defaults to the inner quarter. If a mask larger than a quarter of the 

220 image is set, then only the inner quarter part of that mask is used. 

221 However, for the wide-field and multi-field imaging (including the 

222 Cotton-Schwab algorithm), the entire field may be imaged because the 

223 major cycles either do an exact subtraction from the visibilities or 

224 because PSF extent is more than twice the extent of the primary beam 

225 support. 

226  

227 Before {tt clean} can be run, you must run {tt selectvis} and {tt defineimage}. 

228 Before {tt clean} can be run with a multi-field algorithm (especially for mosaic), you should run 

229 {tt setvp}. You may want to run {tt setmfcontrol} before running {tt clean} 

230 with a multi-field or wide-field algorithm, though the default control values 

231 may be acceptable. Before {tt clean} can be run with a multi-scale algorithm, 

232 {tt setscales} must be run. 

233  

234  

235 Interactive cleaning/masking: If the user wants to see what the clean 

236 image looks like after npercycle iteration and mask or modify the mask 

237 each time, he/she should set {tt interactive=True} and give npercycle to a 

238 fraction of niter. A viewer with the last residual image along with an 

239 overlayed mask appear after every npercycle iteration. The user can 

240 add or delete regions (by clicking on the appropriate button) to the 

241 mask using the region button and drawing regions and double clicking 

242 inside the region. When satisfied and ready to continue cleaning press 'DONE 

243 with masking' (if the user want to terminate the cleaning process use 

244 the 'STOP' button). The button 'No more mask changes' should be used 

245 if the user want clean to proceed without any further interruption. 

246 Even if {tt interactive=False}, and if the parameter 

247 'mask' is non-empty, it is still used in limiting the search area for 

248 clean components. If the parameter 'masktemplate' is not empty this 

249 means that the user want to use an apriori image to make the mask the 

250 first time (e.g a previously cleaned image) 

251  

252 This function returns a record containing convergence, iterations used and threshold reached. 

253 """ 

254 return self._swigobj.clean(algorithm, niter, gain, threshold, displayprogress, model, keepfixed, complist, mask, image, residual, psfimage, interactive, npercycle, masktemplate) 

255 

256 def clipimage(self, image='', threshold=[ ]): 

257 """All pixels in the image with Stokes I less than some threshold 

258 are set to zero. This is useful prior to self-calibration where one 

259 oftens wishes to remove negative pixels from the model. Note that 

260 if the image has polarization information, then the polarized 

261 part of a pixel is also set to zero if Stokes I is less than the 

262 threshold. 

263 """ 

264 return self._swigobj.clipimage(image, threshold) 

265 

266 def clipvis(self, threshold=[ ]): 

267 """All visibilities where the residual exceeds some threshold 

268 are flagged. This provides a simple way of flagging bad 

269 data. 

270 """ 

271 return self._swigobj.clipvis(threshold) 

272 

273 def close(self): 

274 """This is used to close {tt imager} tools. Note that the 

275 data is written to disk. The {tt imager} process keeps running 

276 until a done tool function call is performed. 

277 """ 

278 return self._swigobj.close() 

279 

280 def defineimage(self, nx=int(128), ny=int(-1), cellx=[ ], celly=[ ], stokes='I', phasecenter=[ ], mode='mfs', nchan=int(-1), start=[ ], step=[ ], spw=[ int(0) ], restfreq=[ ], outframe='LSRK', veltype='radio', facets=int(1), movingsource=[ ], distance=[ ], projection='SIN'): 

281 """Define the default image parameters. If an image is to be 

282 made, then these parameters are used in the construction 

283 of the image. Thus, for example, the tool function make 

284 makes an (empty) image using these parameters. 

285  

286 Note that some parameters can be specified either in canonical units 

287 or via measures. To establish default values, the ids for the default 

288 spectral window and default field id must be given. 

289  

290 The parameter {tt mode} can be one of the following: 

291 begin{itemize} 

292 item mfs 

293 item channel 

294 item velocity or opticalvelocity 

295 item frequency 

296 end{itemize} 

297  

298 {tt imager} can perform multi-frequency synthesis over several 

299 spectral windows (mode='mfs'). To achieve this, you should set spwid 

300 to an array of the required spectral windows ({em e.g.} {tt 

301 spwid=[0,1]}). WARNING: For multifrequency synthesis, 'mfs', it is 

302 important that the spwid's selected in selectvis be the SAME 

303 as the one selected in {tt defineimage}. Otherwise the frequency at which 

304 the image is made is not going to be the same as to the one as the one 

305 used in gridding the visibility and can lead to image artifacts. For 

306 {tt mode='velocity'} and {tt mode='frequency'} the {tt step} 

307 parameter has to be a measure/quantity of velocity or frequency, 

308 otherwise for {tt mode='channel'} step is the number of data 

309 channels to be averaged to make one image channel( see examples 

310 below). 

311  

312  

313 The phase center of the image defaults to that of the specified 

314 phasecenter (the first fieldid in the ms is taken if none is 

315 specified), this parameter can be a fieldid or a measure string or the 

316 record output from the direction function of the measures tool( direction ). 

317 This is important if you have multiple pointings in the data. The user 

318 would have used selectvis to select which pointings would be used in imaging. If the 

319 conversion from the observed direction requires frame information then 

320 this is taken as follows: begin{itemize} item Direction information, 

321 including the coordinate system, is taken from the relevant entry in 

322 the Field table of the MeasurementSet. item The epoch is taken from 

323 the time of observation of each visibility. item A position is 

324 specified via the {tt imager} tool function setoptions 

325 end{itemize} 

326  

327 If the specified number of facets is greater than unity then the image 

328 is split into facets (this number along the x and y axes) and 

329 processed. This is necessary when using wide-field algorithm for 

330 deconvolving the image, in cases of non-coplanar arrays (e.g the VLA 

331 at low frequencies but can be safely left at 1 for the ATCA or WSRT). 

332 This is now recommended only when memory or image size is of a problem, 

333 otherwise for widefield issues, wprojection (ftmachine parameter in setoptions) is recommended with a single 

334 facet. 

335  

336 For spectral imaging {tt defineimage} and {tt selectvis} defines the 

337 spectral channels that are imaged. Examples are given in the selectvis section. 

338 The parameter {tt restfreq} can be used to define what rest frequency 

339 to use in the resulting images. If none is specified imager will try 

340 to use the one that is defined in the ms. It will use the first one 

341 defined in the first spectral window selected. 

342  

343 For wide-field or 3D imaging see setoptions 

344 section for some examples. 

345  

346 If the telescope is observing moving source (e.g planet or moon) over 

347 a period of time. One may wish to image in a frame where the source is 

348 fixed. The parameter {tt movingsource} is for that. Setting it to a 

349 source that {tt measures} is aware of will force the imaging to 

350 realign (shift in SD imaging or phase rotation in interferometry 

351 imaging) the data so that the source appears fixed in the 

352 image. Obviously in doing so the background sources will be 

353 blurred. The coordinate system used to fix the source on is the one where 

354 the source is at the first time observed in the selected data. 

355 """ 

356 return self._swigobj.defineimage(nx, ny, cellx, celly, stokes, phasecenter, mode, nchan, start, step, spw, restfreq, outframe, veltype, facets, movingsource, distance, projection) 

357 

358 def done(self): 

359 """This is used to totally stop the {tt imager} process. It is a good idea 

360 to conserve memory use on your machine by stopping the process once 

361 you no longer need it. 

362 """ 

363 return self._swigobj.done() 

364 

365 def drawmask(self, image='', mask='', niter=int(0), npercycle=int(0), threshold='0 mJy'): 

366 """A mask image is an image with the same shape as the other images but 

367 with values between 0.0 and 1.0 as a pixel value. Mask images are used in 

368 imager to control the region selected in a deconvolution. 

369  

370 drawmask is used to interactively draw regions over a template image which you want to allow deconvolution to occur. 

371 """ 

372 return self._swigobj.drawmask(image, mask, niter, npercycle, threshold) 

373 

374 def exprmask(self, mask='', expr=float(1.0)): 

375 """A mask image is an image with the same shape as the other images but 

376 with values between 0.0 and 1.0 as a pixel value. Mask images are used in 

377 imager to control the region selected in a deconvolution. 

378  

379 In the Clark CLEAN, the mask image can usefully have any value between 

380 0.0 and 1.0. Intermediate value discourage but do not rule out 

381 selection of clean components in that region. This is accomplished by 

382 multiplying the residual image by the mask prior to entering the minor 

383 cycle. Note that if you do use a mask for the Clark or Hogbom Clean, 

384 it must cover only a quarter of the image. boxmask does not enforce 

385 this requirement. 

386  

387 This function allows Lattice Express Language (LEL) expressions to 

388 be used in defining a mask. See the documentation on 

389 imagecalc for more details. 

390 """ 

391 return self._swigobj.exprmask(mask, expr) 

392 

393 def feather(self, image='', highres='', lowres='', lowpsf='', effdishdiam=float(-1.0), lowpassfiltersd=False): 

394 """Basically the "imerg" algorithm of AIPS and SDE, or the "feather" 

395 algorithm of MIRIAD, we regrid the total power (or low resolution) 

396 image onto the interferometer (or high resolution) image, Fourier 

397 transform both the interferometer and single dish images, down weight 

398 the Fourier transform of the interferometer image by 1.0 - FT(low res psf), 

399 add the weighted interferometer Fourier plane to the single dish Fourier 

400 plane, and transform back into the image plane. 

401  

402 The tapering is by the transform of a point spread function. If lowpsf 

403 is specified, that image is used, otherwise the appropriate telescope 

404 beam is used. The point spread function for a single dish image may be 

405 calculated using makeimage. 

406  

407 {tt Advice:} Note that if you are feathering large images, you'd be advised to have 

408 the number of pixels along the X and Y axes to be composite numbers 

409 and definitely not prime numbers. In general FFTs work much faster on even 

410 and composite numbers. You may use subimage function of image 

411 tool to trim the number of pixels to something desirable. 

412 """ 

413 return self._swigobj.feather(image, highres, lowres, lowpsf, effdishdiam, lowpassfiltersd) 

414 

415 def filter(self, type='gaussian', bmaj=[ ], bmin=[ ], bpa=[ ]): 

416 """Apply visibility tapering to emphasize certain scale structures. The 

417 imaging tapers are applied to a Table column called IMAGING_WEIGHT, 

418 which may be plotted using 

419 tb and pl. 

420 plotweights. 

421 In addition, this column 

422 may be accessed directly using either the table 

423 or ms modules. Note that the taper is multiplicative and 

424 so the weights must be calculated first using 

425 weight. The points are not flagged! 

426  

427 Note that the scale size to be emphasized is given in the image plane 

428 as the parameters of the corresponding Gaussian. Note also use of this 

429 function provides an optimum detection for the given scale size, which 

430 is not the same as requiring that the resulting dirty beam have the 

431 specified Gaussian fit. The resultant fitted beam size will {em very 

432 roughly} be the quadratic sum of the original beam and the specified 

433 beam. If you wish to obtain a specified beam, then the best approach 

434 is to perform this calculation and check the value obtained using 

435 imager.fitpsf. 

436 """ 

437 return self._swigobj.filter(type, bmaj, bmin, bpa) 

438 

439 def fitpsf(self, psf): 

440 """This fits an elliptical Gaussian to the point spread function 

441 and returns the fitted beam parameters. If psf image is not specified 

442 then a psf is made and used. The values for the beam fit 

443 are saved internally and used whenever needed (for example in the functions restore or smooth) until invalidated. The values 

444 are invalidated by selectvis, defineimage or any tool function that changes 

445 the weights. Use the function summary to check if there is a valid fitted psf stored internally. 

446  

447 """ 

448 return self._swigobj.fitpsf(psf) 

449 

450 def fixvis(self, fields=[ int(-1) ], phasedirs=[ ], refcode='', distances=[ float(0.0) ], datacolumn='all'): 

451 """Corrects UVW coordinates and optionally the visibilities for various 

452 effects that can be calculated without fitting a model to the data. 

453  

454 The effects include: 

455 begin{itemize} 

456 item changing the phase tracking center(s), 

457 item correcting for differential aberration, (Not yet implemented) 

458 item changing the equinox (i.e. B1950_VLA to J2000 or APP, etc.) of the UVW coordinates, 

459 item changing the projection, as in (-)NCP to SIN. (Not yet implemented), 

460 item refocusing. 

461 end{itemize} 

462  

463 """ 

464 return self._swigobj.fixvis(fields, phasedirs, refcode, distances, datacolumn) 

465 

466 def ft(self, model=[ ], complist='', incremental=False, phasecentertime=float(-1.0)): 

467 """Fourier transform the specified model (and optionally componentlist) 

468 and insert into the MODEL_DATA column. The current contents of 

469 the MODEL_DATA column are replaced unless incremental is set to 

470 T (in which case the results are added to the column). 

471 phasecentertime is optional useful for field which is have time varying phasecenters (polynomials or ephemerides phasecenters). The default is to calculate the phasecenter at each time in the data but the time provided here can be used to calculate phasecenters. 

472 If the function setvp is run prior to running ft with a componentlist, then the spectral variation of each component in the componentlist will include the multiplicative term of the beam value for each channel frequency. So a flat spectrum component will show the frequency variation of the beam in the predicted visibilities.. 

473 """ 

474 return self._swigobj.ft(model, complist, incremental, phasecentertime) 

475 

476 def getweightgrid(self, type='imaging', wgtimages=[ ]): 

477 """This is a utility function when running multi imager processes in parallel on subsection of an ms/data independently 

478 One would wish to weight the dirty image before averaging or set the imaging weight density (when using unform or 

479 Brigg's style weighting) to account for all the data being used. This is {bf NOT} for the general user but for people who 

480 are parallelizing at the scripting level. 

481  

482 {bf imaging}: will return a the weight griddensity  

483  

484 {bf ftweight}: will put the FT-machine weight images in the names given in wgtimage parameters..these may be needed to average residual images from different processes running seperately on different section of the data. 

485 """ 

486 return self._swigobj.getweightgrid(type, wgtimages) 

487 

488 def linearmosaic(self, images=[ ], mosaic='', fluxscale='', sensitivity='', fieldids=[ int(0) ], usedefaultvp=True, vptable=''): 

489 """Make a linear mosaic of several images. 

490 Currently, the pointing center is not specified in the image, so 

491 we specify the pointing center in terms of the row numbers of the FIELD subtable. 

492 """ 

493 return self._swigobj.linearmosaic(images, mosaic, fluxscale, sensitivity, fieldids, usedefaultvp, vptable) 

494 

495 def make(self, image=''): 

496 """Make an empty image using the current image parameters. Often this is 

497 unnecessary, but you will typically need to use this if you wish to 

498 deconvolve a set of images. The steps are to make the empty images 

499 that you require to be deconvolved, and then pass them into clean as a 

500 vector of strings. 

501 """ 

502 return self._swigobj.make(image) 

503 

504 def predictcomp(self, objname='', standard='', epoch=[ ], freqs=[ float(1.0e11) ], pfx='predictcomp'): 

505 """Make a component list for an object recognized by standard, one of setjy's 

506 flux density standards. 

507 """ 

508 return self._swigobj.predictcomp(objname, standard, epoch, freqs, pfx) 

509 

510 def makeimage(self, type='observed', image='', compleximage='', verbose=True): 

511 """This tool function actually does gridding (and Fourier inversion if 

512 needed) of visibility data to make an image. It allows calculation of 

513 various types of image: 

514 begin{description} 

515 item[observed] Make the dirty image from the DATA column ({em default}) 

516 item[model] Make the dirty image from the MODEL_DATA column 

517 item[corrected] Make the dirty image from the CORRECTED_DATA column 

518 item[residual] Make the dirty image from the difference of the 

519 CORRECTED_DATA and MODEL_DATA columns 

520 item[psf] Make the point spread function 

521 item[singledish] Make a single dish image 

522 item[coverage] Make a single dish coverage image 

523 item[holography] Make a complex holography image 

524 item[pb] Make the primary beam as defined by setvp 

525 end{description} 

526  

527 Note the full {tt imager} equation is not used and so, for example, the 

528 primary beam correction is not performed. Use 

529 restore to get a residual image 

530 using the full {tt imager} equation where primary beam correction is 

531 performed. 

532  

533 A position shift can be applied when specifying the image parameters 

534 with defineimage. If a shift is specified then 

535 the uvw coordinates are reprojected prior to gridding, and a phase 

536 rotation is applied. If the image is a PSF then no phase shift is 

537 applied but the uvw are recomputed. To see the effects of the uvw 

538 reprojected, you can use the 

539 plotuv function. 

540  

541 If desired, the full complex image (before conversion to stokes 

542 I,Q,U,V) may be retained. Note that the image 

543 tool cannot load a complex image directly. Instead, use the 

544 imagecalc constructor 

545 to take {em e.g.} the real and imaginary parts of the image. 

546  

547 For making single dish and holography images, the data are convolved onto the 

548 grid using a one of a number of options: 

549 begin{description} 

550 item[gridfunction='SF'] Circularly symmetric prolate spheroidal wavefunction. 

551 This is always the same function in pixels. To get this to match to 

552 the antenna primary beam, the optimum cellsize to use in constructing 

553 the image is the antenna primary beam half-width-half-maximum times 

554 1.20192. 

555 item[gridfunction='BOX'] Nearest neighbor gridding. 

556 item[gridfunction='PB'] The telescope primary beam is used as the 

557 convolution function. This function is the same in arcseconds, 

558 independent of the cellsize. This choice is optimum in the least 

559 squares sense. To override the default choice of telescope primary beam 

560 for a given telescope, use the function 

561 setvp. Usually the default will be acceptable. 

562 end{description} 

563  

564 To make a reasonable approximation to the sky, one should divide 

565 the type='singledish' image by the type='coverage' image, thresholding 

566 at some level. For example: 

567  

568 begin{verbatim} 

569  

570 ia.open('scanweight'); 

571 ia.statistics(s); 

572 threshold = s.max / 10.0; 

573 # 

574 ia.imagecalc('sdimage', 

575 pixels=spaste('scanimage[scanweight>', threshold, 

576 ']/scanweight[scanweight>', threshold, ']')) 

577 ###ia.view(raster=True, axislabels=True); 

578 end{verbatim} 

579 """ 

580 return self._swigobj.makeimage(type, image, compleximage, verbose) 

581 

582 def makemodelfromsd(self, sdimage='', modelimage='', sdpsf='', maskimage=''): 

583 """This functions use an image from a single dish and make a model 

584 (clean component) image out of it. This allows one to use this as the 

585 starting model in a deconvoltion function e.g 

586 clean or mem 

587 This provides an alternative to 

588 feather. 

589 The difference between the two is that in {tt feather} the 

590 interferometer image is deconvolved first and the single dish image is 

591 put in at the end. Whereas if one starts with a model from the single 

592 dish image it will give a different starting point for the deconvolving 

593 algorithm to interpolate the missing short baseline. 

594  

595 The function setsdoptions may be used to set 

596 a factor by which to scale the SD image, if necessary. 

597  

598 The {tt sdpsf} parameter (optional) should be used if an external PSF image of the 

599 single dish is needed to calculate the beam parameters of the primary 

600 beam of the dish. This is usually needed if the dish image is from a 

601 non standard telescope or the beam is not in the {tt CASA} system. 

602  

603 The {tt mask} is a mask image that may be needed to be used for 

604 clean. This is usually the case when the dish image does not fully 

605 cover the field defined by defineimage. 

606 """ 

607 return self._swigobj.makemodelfromsd(sdimage, modelimage, sdpsf, maskimage) 

608 

609 def mask(self, image='', mask='', threshold=[ ]): 

610 """A mask image is an image with the same shape as the other images but 

611 with values between 0.0 and 1.0 as a pixel value. Mask images are used 

612 in {tt imager} to control the region selected in a deconvolution. 

613 One makes a mask image by clipping the I part of the restored image 

614 (this function) or via the boxmask, 

615 regionmask, and 

616 exprmask functions. In this 

617 function, all points greater than the threshold are set to unity. The 

618 mask is the same in I,Q,U, and V. Note that 

619 exprmask is the most powerful 

620 method for making mask images. 

621  

622 In the Clark CLEAN, the mask image can usefully have any value between 

623 0.0 and 1.0. Intermediate value discourage but do not rule out 

624 selection of clean components in that region. This is accomplished by 

625 multiplying the residual image by the mask prior to entering the minor 

626 cycle. 

627  

628 Note that if you do use a mask for the Clark or Hogbom Clean, it must 

629 cover only a quarter of the image. It is particularly important to 

630 check this when creating an image using a threshold. If it extends 

631 further, the easiest fix is to use 

632 getchunk and 

633 getchunk to set parts of it to zero. 

634 """ 

635 return self._swigobj.mask(image, mask, threshold) 

636 

637 def mem(self, algorithm='entropy', niter=int(20), sigma=[ ], targetflux=[ ], constrainflux=False, displayprogress=False, model=[ ], keepfixed=[ bool(False) ], complist='', prior=[ ], mask=[ ], image=[ ], residual=[ ]): 

638 """Makes a mem image using either the Cornwell-Evans maximum entropy or 

639 maximum emptiness algorithms, using the single field or multi-field 

640 contexts. The maximum entropy algorithm is the default. The mem is performed 

641 on the residual image calculated from the visibility data currently 

642 selected. Hence the first step performed in mem is to transform the 

643 current model or models (optionally including a componentlist) to fill 

644 in the MODEL_DATA column, and then inverse transform the residual 

645 visibilities to get a residual image. This residual image is then 

646 deconvolved using the corresponding point spread function. This means that 

647 the initial model is used as the starting point for the 

648 deconvolution. Thus if you want to restart a mem, simply set the 

649 model to the model that was previously produced by clean. 

650  

651 Mask images are used to constrain the region that is to be 

652 deconvolved. To make mask images, use either 

653 boxmask (to define a mask via the 

654 corner locations blc and trc) or mask (to 

655 define a mask via thresholding an existing image). The default mask is 

656 the inner quarter of the image. 

657  

658 The MEM deconvolution only operates on one Stokes parameter at a time. 

659 Joint MEM deconvolution for multiple Stokes parameters will be 

660 implemented in the future. 

661  

662 Some reference regarding MEM : 

663 Cornwell and Evans, 

664 Astronomy and Astrophysics (ISSN 0004-6361), vol. 143, no. 1, Feb. 1985, 

665 p. 77-83. 

666  

667 Narayan and Nityananda, 

668 Annual review of astronomy and astrophysics. Volume 24 (A87-26730 

669 10-90). Palo Alto, CA, Annual Reviews, Inc., 1986, p. 127-170. 

670  

671 The mem algorithms possible are: 

672 begin{description} 

673 item[Cornwell-Evans Maximum Entropy (entropy)] The classic "vm" or "vtess" 

674 deconvolution algorithm. 

675 item[Cornwell-Evans Maximum Emptiness (emptiness)] The historic, but 

676 largely undocumented, modification to the Cornwell-Evans algorithm 

677 which seeks a model image which is consistent with the data and 

678 simultaneously minimizes the number of pixels with no emission 

679 (meaning "with pixel values below the noise level"). 

680 item[Multi-field Maximum Entropy (mfentropy)] Deconvolution is split 

681 into minor and major cycles. For each field, the MEM analog of a Clark 

682 Clean minor cycle is performed. In the major cycle, the emission thus 

683 modelled is subtracted either from the original visibilities (for 

684 multiple fields) or using a convolution (for only one field). The 

685 latter is much faster. 

686 item[Multi-field Maximum Emptiness (mfemptiness)] Just like {tt mfentropy}, 

687 but with emptiness. 

688 end{description} 

689  

690 The multi-field mem ({tt mfentropy} or {tt mfemptiness}) should be 

691 used if either of two conditions hold: 

692 begin{enumerate} 

693 item Multiple fields are to be deconvolved simultaneously {bf OR} 

694 item Primary beam correction is enabled. In this case, a 

695 mosaiced mem is performed. 

696 end{enumerate} 

697  

698 Note that for the single pointing algorithms, only a quarter of the 

699 image may be deconvolved. If no mask is set, then the deconvolved 

700 region defaults to the inner quarter. If a mask larger than a quarter 

701 of the image is set, then only the quarter starting at the bottom left 

702 corner is used. However, for the multi-field imaging, the entire 

703 field may be imaged because the major cycles either do an exact 

704 subtraction from the visibilities or because PSF extent is more than 

705 twice the extent of the primary beam support. 

706  

707 Before {tt mem} can be run, you must run {tt selectvis} and {tt defineimage}. 

708 Before {tt mem} can be run with a multi-field algorithm, you should run 

709 {tt setvp}. You may want to run {tt setmfcontrol} before running {tt mem} 

710 with a multi-field algorithm, though the default control values 

711 may be acceptable. 

712 """ 

713 return self._swigobj.mem(algorithm, niter, sigma, targetflux, constrainflux, displayprogress, model, keepfixed, complist, prior, mask, image, residual) 

714 

715 def nnls(self, model=[ ], keepfixed=[ bool(False) ], complist='', niter=int(0), tolerance=float(1e-06), fluxmask=[ ], datamask=[ ], image=[ ], residual=[ ]): 

716 """Solve for the model brightness using the Briggs' Non-Negative Least 

717 Squares algorithm. Since NNLS works only on the $I$ image, the $I$ 

718 pixels in the current image is set to zero where the fluxmask is $> 0.0$, 

719 then NNLS is used to estimate the $I$-pixels for that region. 

720 The deconvolution is performed on the residual image calculated from 

721 the visibility data currently selected. Hence the first step performed 

722 in clean is to transform the current model to fill in the MODEL_DATA 

723 column, and then inverse transform the residual visibilities to get a 

724 residual image. This residual image is then deconvolved using the 

725 corresponding point spread function. 

726  

727 Some other points to remember are that rather than explicit boxes, 

728 mask images are used to constrain the region that is to be 

729 deconvolved. For NNLS, there are two masks, the fluxmask specifying 

730 the region within which flux is allowed, and the datamask specifying 

731 the region of the dirty image to be used as constraints. Typically the 

732 datamask will be somewhat larger than the fluxmask. On a large 

733 machine, a practical limit to both will be about 5000-6000 

734 pixels. Hence NNLS is only useful for compact tools. (For more 

735 details, see the htmladdnormallink{Briggs thesis}{briggsURL}). To 

736 make mask images, use either boxmask (to 

737 define a mask via the corner locations blc and trc) or 

738 mask (to define a mask via 

739 thresholding an existing image). 

740  

741 On the canonical aipspp machine with 64MBytes of physical memory, 

742 you should try to keep the product of the pixels in the fluxmask 

743 and the datamask below about 5-10 million. Otherwise the 

744 solution phase will swap badly. 

745 """ 

746 return self._swigobj.nnls(model, keepfixed, complist, niter, tolerance, fluxmask, datamask, image, residual) 

747 

748 def open(self, thems='', compress=False, usescratch=False): 

749 """Close the current MeasurementSet and open a new MeasurementSet 

750 instead. The current state of {tt imager} is retained, except for 

751 the data selection. 

752 """ 

753 return self._swigobj.open(thems, compress, usescratch) 

754 

755 def pb(self, inimage='', outimage='', incomps='', outcomps='', operation='apply', pointingcenter=[ ], parangle=[ ], pborvp='pb'): 

756 """Multiply ({tt operation='apply'}) or divide ({tt operation='correct'}) 

757 by the primary beam function. The primary beam can be applied to images and/or 

758 Componentlists. 

759  

760 If {tt pointingcenter==false} then you must specify {tt inimage} 

761 and the pointing center is taken from its reference direction. 

762 Otherwise, {tt pointingcenter} must be a Direction measure. 

763 It cannot take on the value {tt True}. 

764  

765 The applied primary beam function is deterimed as follows. If you used 

766 function Imager.setvp to set an external 

767 voltage pattern table, then this is where the applied primary beam will 

768 come from (regardless of whether you set {tt inimage} or not). If you 

769 did not run this function, then you must supply argument {tt inimage}. 

770 The telescope name embedded in its Coordinate System will be used to 

771 determine the primary beam function. 

772 """ 

773 return self._swigobj.pb(inimage, outimage, incomps, outcomps, operation, pointingcenter, parangle, pborvp) 

774 

775 def plotsummary(self): 

776 """Performs a simple plot of the field and spectral window IDs 

777 versus time (after sorting). 

778 """ 

779 return self._swigobj.plotsummary() 

780 

781 def plotuv(self, rotate=False): 

782 """Performs a simple plot of the uv coverage of all selected data. 

783  

784 Optionally, plotuv will rotate the uvw coordinates to the 

785 specified phase center (set via defineimage). 

786 """ 

787 return self._swigobj.plotuv(rotate) 

788 

789 def plotvis(self, type='all', increment=int(1)): 

790 """Performs a simple plot of the visibility amplitudes of all selected data. 

791 """ 

792 return self._swigobj.plotvis(type, increment) 

793 

794 def plotweights(self, gridded=False, increment=int(1)): 

795 """Performs a plot of the visibility weights of all selected data (stored in 

796 the IMAGING_WEIGHT column of the MeasurementSet). 

797 The plot can be of the gridded weights (type='gridded') or 

798 ungridded. 

799  

800  

801 """ 

802 return self._swigobj.plotweights(gridded, increment) 

803 

804 def regionmask(self, mask='', region={ }, boxes=[ ], circles=[ ], value=float(1.0)): 

805 """A mask image is an image with the same shape as the other images but 

806 with values between 0.0 and 1.0 as a pixel value. Mask images are used in 

807 imager to control the region selected in a deconvolution. 

808  

809 In the Clark CLEAN, the mask image can usefully have any value between 

810 0.0 and 1.0. Intermediate value is discouraged but do not rule out 

811 selection of clean components in that region. This is accomplished by 

812 multiplying the residual image by the mask prior to entering the minor 

813 cycle. Note that if you do use a mask for the Clark or Hogbom Clean, 

814 it must cover only a quarter of the image. {tt regionmask} does not enforce 

815 this requirement. 

816  

817 The function regionmask also allows multiple regions to be used. A record of the regions can be made as in the example below. 

818  

819 Regions can be made in many different ways using the 

820 regionmanager functions. An example 

821 using wbox function is given 

822 below. The default regionmanager tool 'rg' can be used for cases the user want to have flexibility in manipulating regions. The {tt region} parameter takes a record that comes from the regionmanager output. 

823 The parameter boxes allow the user to sent in a list of 4 elements numbers representing blc's and trc's 

824  

825 If both the parameters, {tt regions} and {tt boxes} are used the a union is done with the two sets of region thus defined. 

826  

827  

828  

829  

830 """ 

831 return self._swigobj.regionmask(mask, region, boxes, circles, value) 

832 

833 def regiontoimagemask(self, mask='', region={ }, boxes=[ ], circles=[ ], value=float(1.0)): 

834 """This function is very similar to regionmask function 

835 except that the mask image has to be existant already and this is an 

836 independent helper function (i.e does not care about the state of the imager tool... e.g does not need imager to have an 

837 attached ms). 

838  

839  

840  

841  

842 """ 

843 return self._swigobj.regiontoimagemask(mask, region, boxes, circles, value) 

844 

845 def residual(self, model=[ ], complist='', image=[ ]): 

846 """Calculate the residuals corresponding to the model and 

847 componentlist. {em Note that the model visibilities are updated}. 

848 """ 

849 return self._swigobj.residual(model, complist, image) 

850 

851 def restore(self, model=[ ], complist='', image=[ ], residual=[ ]): 

852 """Restore the residuals to a smoothed version of the model. The model 

853 images are convolved with the specified Gaussian beam and then the 

854 residual images are added. {em Note that the model visibilities are 

855 updated and thus reflect the model and componentlist that was 

856 used.}. Use setbeam to set the beam 

857 parameters. 

858 """ 

859 return self._swigobj.restore(model, complist, image, residual) 

860 

861 def updateresidual(self, model=[ ], complist='', image=[ ], residual=[ ]): 

862 """This function is for efficiency and speed purpose only. Same as restore 

863 It is to be used after you have used clean or mem ...but you wish to tweak the model image, say by clipping unwanted components and it will avoid unnecessary recalculating of psf but will do a proper prediction of the new model visibilities and recalculate residual and restored images. 

864 """ 

865 return self._swigobj.updateresidual(model, complist, image, residual) 

866 

867 def sensitivity(self): 

868 """NB: The implementation in this function will be removed for CASA v4.5. 

869 We now recommend that the im.apparentsens() function be used instead 

870 of this one, especially if their weights are initialized and 

871 calibrated. 

872  

873 Calculate the point source sensitivity for the selected data, both 

874 absolutely and relatively (to that for natural weighting). 

875  

876 To do the calculation, we use the imaging weights (in the 

877 column called IMAGING_WEIGHT) as calculated from the WEIGHT column, 

878 and an estimate of the effective net bandwidth and integration time. 

879 The calculation therefore includes all the effects 

880 of weight and 

881 filter. 

882  

883 The output is an array with mixed elements. Counting from zero, the 

884 second element (out[1]) is the net sensitivity, third element is the 

885 ratio of the reduction in sensitivity due to the chosen weighting 

886 scheme. This ratio is 1.0 for Natural weight and greater than one for 

887 all other weighting schemes. (NOTE: Further testing is required of 

888 this value and hence this is kept separate for now). 

889  

890 The sensitivity calculations require Tsys and collecting area of 

891 the antenna. These quantities are not known from the MS. The 

892 sensitivity is therefore returned in units of Jy m^2/K. Multiplying the 

893 second elements with the ration of the Tsys and effective antenna 

894 collecting area will give the sensitivity in Jy/beam units. 

895  

896 The fourth elements of the return value is a record with the following 

897 keys: 'nbaselines', 'effectiveintegration', 'effectivebandwidth', 

898 'sumwt' and 'spwid'. These can be used to get the number of baselines 

899 used, effective integration time (in sec), the effective bandwidth (in 

900 Hz), the sum of weights and the absolute spectral window IDs used. 

901 """ 

902 return self._swigobj.sensitivity() 

903 

904 def apparentsens(self): 

905 """This function calculates the point source sensitivity for the data 

906 selected by im.selectvis(...), and according to the imaging weighting 

907 parameters specified in im.weight(...) and im.defineimage(...). The 

908 calculation is performed solely using the weight information stored in 

909 the MS WEIGHT column (WEIGHT_SPECTRUM tbd), and as adjusted by the net 

910 imaging weighting function (natural, uniform, robust, taper, etc.). 

911 Therefore, it is assumed that the MS WEIGHTs have been properly 

912 initialized and calibrated along with the visibility data. As long as 

913 the WEIGHTs are in the inverse square units of the visibilities (i.e., 

914 inverse variance weights), the calculation should yield the real 

915 theoretical imaging sensitivity for data at any stage of the 

916 calibration (though data at early and intermediate stages of 

917 calibration may not be sufficiently coherent for imaging at high--or 

918 even modest--fidelity). 

919  

920 Two values are reported in the logger and returned (see example 

921 below). First, the apparent sensitivity (in the units implied by the 

922 WEIGHTs' units), for the specified imaging weighting scheme. Second, 

923 a unitless factor describing the ratio of the apparent sensitivity to 

924 that obtained with pure 'natural' weighting (the nominal peak 

925 sensitivity). When 'natural' weighting is selected, this ratio factor 

926 will be 1.0; all other weighting choices will yield an apparent 

927 sensitivity ratio greater than 1.0. 

928  

929 Currently, this function reports only the continuum sensitivity for 

930 the selected data, and in particular, for the aggregate bandwidth 

931 indicated by the spectral window selection. The calculation further 

932 assumes that the visibility samples are each entirely independent 

933 (i.e., no redundant samples such as would occur for overlapping 

934 spectral windows). 

935  

936 A future version of this function will support reporting a sensitivity 

937 spectrum for the spectral line case (including support for 

938 WEIGHT_SPECTRUM). For now, spectral line sensitivity may be 

939 reasonably estimated by dividing the reported sensitivity by the 

940 square root of the fractional bandwidth of a single image channel, or 

941 by selecting a bandwidth matching the width of a single image channel. 

942 """ 

943 return self._swigobj.apparentsens() 

944 

945 def setbeam(self, bmaj=[ ], bmin=[ ], bpa=[ ]): 

946 """This sets the clean beam that will be used in all restoration 

947 operations. 

948 """ 

949 return self._swigobj.setbeam(bmaj, bmin, bpa) 

950 

951 def selectvis(self, vis='', nchan=[ int(-1) ], start=[ int(0) ], step=[ int(1) ], spw=[ ], field=[ ], baseline=[ ], time=[ ], scan=[ ], intent='', observation=[ ], uvrange=[ ], taql='', usescratch=False, datainmemory=False, writeaccess=True): 

952 """This setup tool function selects which data are to be used 

953 subsequently. After invocation of selectvis, only the selected 

954 data are operated on. Thus, for example, in imaging, only the selected 

955 data are gridded into an image, and in plotting, only the 

956 selected data are plotted. 

957  

958 Data can be selected by field and spectral window ids. Note that 

959 all data thus selected are passed to imaging, and may or 

960 may not be imaged, depending on how the image was constructed 

961 using defineimage. For example, 

962 in mosaicing, use fieldid in defineimage to control what pointing 

963 is used to define the field center, and use fieldid in selectvis 

964 to control what pointings are used in the imaging. 

965  

966 For spectral processing, it is possible to make cubes out 

967 multi-spectral window selections but the selection and combination can 

968 be a bit confusing (any hint at how to make it clearer is welcome). 

969  

970 If the default values are not used, then data to be used can be selected channel wise. The 

971  

972 begin{description} 

973 item[nchan] is the number of data channels selected. It 

974 defaults to -1 (interpreted as all channels). 

975 item[start] is the first channel from input dataset that is to be used. 

976 It defaults to 0 (i.e. first channel). 

977 item[step] gives the increment between selected input channels. It defaults to 1 channel. A value of {tt n} means that {tt n-1} data channels will not not be used. 

978 end{description} 

979  

980  

981  

982 By choosing the parameters for selectvis and defineimage correctly, 

983 one may obtain various mappings of visibility channels to image 

984 channels. For example, to average 512 visibility channels into 64 

985 image channels (producing image channels consisting of 8 

986 visibility channels): 

987  

988  

989 im.defineimage(mode='channel', spw=0, nchan=64, start=1, step=8); 

990 im.selectvis(spw=0, nchan=512, start=1, step=1) 

991 im.clean(.....); 

992  

993  

994 This averages the spectral channels during the gridding process. If 

995 one wanted to only include every 8th channel in the 

996 deconvolution, one would do: 

997  

998  

999 im.selectvis(nchan=64, start=1, step=8) 

1000 im.defineimage(mode='channel', nchan=64, start=1, step=8); 

1001 im.clean(....); 

1002  

1003  

1004 For velocity and opticalvelocity modes, the mstart and mstep 

1005 are the start and step velocities as strings. 

1006  

1007  

1008 im.defineimage(mode='velocity', nchan=64, start='20 km/s', step='-100m/s'); 

1009 im.selectvis(spwid=[-1]); ###selecting all data spectral windows 

1010 im.clean(...); 

1011  

1012  

1013 If the image and data selections differ, then averaging is done during 

1014 the gridding and degridding process in the image deconvolution. 

1015  

1016  

1017 im.defineimage(mode='channel', nchan=64, start=1, step=8); 

1018 im.selectvis(nchan=512, start=1, step=1) 

1019 im.clean() 

1020  

1021  

1022 Note: The channels numbers used in {tt defineimage} 

1023 and {tt selectvis} refers to the same channel. So if a channel is not 

1024 selected in {tt selectvis} but is selected in {tt defineimage}, then 

1025 blank channels image are made. The example below will result in the 

1026 having the first 6 (0-5) channels in the image to be blank. 

1027  

1028  

1029 im.selectvis(nchan=50, start=6, step=1) #selected chan 6-55 

1030 im.defineimage(mode='channel', nchan=50, start=0, step=1); 

1031  

1032 # will try to image channel 1-50. But as previously only channel 6-55 

1033 # was selected only channel 6-50 will have data; images of channels 

1034 # 1-5 are blank 

1035 im.clean(....) 

1036  

1037  

1038 For multi-spectral window cube imaging the selection of the data can 

1039 be done as follows 

1040  

1041  

1042 im.selectvis(nchan=[50,60], start=[0,0], step=[1,1], 

1043 spw=[0,1]) 

1044 im.defineimage(mode='channel', nchan=110, start=0, step=1, spw=[0,1]); 

1045  

1046  

1047  

1048 The above means that you would make a data selection of 50 channels 

1049 (starting from 0 steping 1) from the first spectral window and 60 

1050 channels (starting from 1 steping 1). The defineimage defines the image 

1051 to be a cube of 110 channels. The caveat is the step size in the 

1052 frequency direction is the step size of the first spectral window. If 

1053 the step size of channels of the two spectral windows are different 

1054 then one is better off defining the image cube in velocities (e.g. as below). 

1055  

1056  

1057  

1058 im.selectvis(nchan=[50,60], start=[0,0], step=[1,1], 

1059 spw=[1,2]) 

1060 im.defineimage(mode='velocity', nchan=200, mstart='20km/s', 

1061 mstep='-100m/s'); 

1062  

1063 """ 

1064 return self._swigobj.selectvis(vis, nchan, start, step, spw, field, baseline, time, scan, intent, observation, uvrange, taql, usescratch, datainmemory, writeaccess) 

1065 

1066 def setjy(self, field=[ ], spw=[ ], modimage='', fluxdensity=[ float(0.0),float(0.0),float(0.0),float(0.0) ], standard='SOURCE', scalebychan=False, spix=[ float(0.0) ], reffreq=[ ], polindex=[ float(0.0) ], polangle=[ float(0.0) ], rotmeas=float(0.0), time='', scan='', intent='', observation='', interpolation='nearest'): 

1067 """Compute the model visibility for a specified source flux density, and 

1068 insert into the MODEL_DATA column. The source flux density for 

1069 a set of standard flux density reference sources may optionally 

1070 be pre-computed, by setting the input flux density to -1 (the default). 

1071 At present, these include 3C286, 3C48, 3C147, 3C138, and 1934-638. 

1072 In this case, if the source is not in this set, an unpolarized 

1073 flux density of 1 Jy will be assumed. Users may also specify 

1074 {tt standard='SOURCE'} to use the model(s) in the SOURCE_MODEL column of the 

1075 SOURCE subtable. 

1076  

1077 Users may also specify a model image that will be scaled to the 

1078 specified total flux density (or that computed for reference sources). 

1079 When a model image is specified, setjy will only permit processing 

1080 one field, and will currently only process Stokes I. 

1081 """ 

1082 return self._swigobj.setjy(field, spw, modimage, fluxdensity, standard, scalebychan, spix, reffreq, polindex, polangle, rotmeas, time, scan, intent, observation, interpolation) 

1083 

1084 def ssoflux(self): 

1085 """*This was an experimental clone of setjy while flux calibration with Solar 

1086 System objects was being tested. It has been merged back into setjy.* 

1087 """ 

1088 return self._swigobj.ssoflux() 

1089 

1090 def setmfcontrol(self, cyclefactor=float(1.5), cyclespeedup=float(-1), cyclemaxpsffraction=float(0.8), stoplargenegatives=int(2), stoppointmode=int(-1), minpb=float(0.1), scaletype='NONE', constpb=float(0.4), fluxscale=[ ], flatnoise=True): 

1091 """Control parameters for mosaicing or wide-field imaging which are not 

1092 required in single field deconvolution are set here to streamline the 

1093 user interface. As multifield and widefield imaging is accomplished 

1094 by deconvolution in cycles, many of these parameters control how the 

1095 deconvolution cycles are ended. 

1096  

1097 begin{description} 

1098 item cyclefactor: this parameter helps in lowering or increasing the 

1099 threshold at which the deconvolution cycle will stop and degrid and 

1100 subtract from the visibilities. For very bad PSFs you may want to 

1101 reconcile with the visibilties often, thus a larger number is 

1102 required here...(4 to 5). For very well behaved data you may want to 

1103 deconvolve deep before reconciling: a lower number is used (1.5 to 2.0). 

1104 item cyclespeedup: this is used if the PSF is not well behaved and 

1105 you want clean to raise by 2 the threshold if it has not reached the 

1106 threshold in this number of iteration 

1107 item cyclemaxpsffraction: similar to cyclefactor, but this is an 

1108 explicit fraction of the PSF peak. The final threshold is computed 

1109 using min( cyclemaxpsffraction, cyclefactor * maxPSFsidelobe). 

1110 Valid values are between 0.0 and 1.0. 

1111 item stoplargenegatives: This parameter is exclusively for when using 

1112 multiscale clean. This is used to stop the component 

1113 search when the largest scale has found this number of negative 

1114 components. -1 here means that continue component search even if the 

1115 largest component is negative. 

1116 item stoppointmode: Again exclusively for when using multiscale 

1117 clean. The clean will stop if the smallest scale receives this 

1118 number of consecutive components. 

1119 item minpb: This is to defined up to what level the voltage pattern 

1120 is going to applied when using 

1121 setvp. The default is 0.1 of the 

1122 primary beam or the voltage pattern defined for the antenna. 

1123 item scaletype: This parameter cab be NONE or SAULT. If NONE the 

1124 image is not scaled, if SAULT is used the image is weighted so that 

1125 the noise is kept uniform across the image. The next two parameters 

1126 defines how the SAULT weighting is limited. Obviously then the flux 

1127 scale is not uniform across the image. To get the right flux 

1128 multiply the image with the fluxscale image. 

1129 item constpb: this parameter defines up to what amplitude of the 

1130 Primary beam the noise floor is kept uniform, when using SAULT as scaletype. 

1131 item fluxscale: use this to give a filename to store the factor image 

1132 to apply to the image to get the fluxscale right. 

1133 item flatnoise: (default true) Set to false if you want clean components for mosaic to be searched in the residual image that is effectively multiplied by the $beam^2$. This means when the noise is determined after the antenna, searching in the optimum domain of $signal/(sigma^2)$. For meter wavelengths where noise is determined by the sky, it is no longer optimal. 

1134 end{description} 

1135 """ 

1136 return self._swigobj.setmfcontrol(cyclefactor, cyclespeedup, cyclemaxpsffraction, stoplargenegatives, stoppointmode, minpb, scaletype, constpb, fluxscale, flatnoise) 

1137 

1138 def setoptions(self, ftmachine='ft', cache=int(-1), tile=int(16), gridfunction='SF', location=[ ], padding=float(1.0), freqinterp='nearest', wprojplanes=int(-1), epjtablename='', applypointingoffsets=False, dopbgriddingcorrections=True, cfcachedirname='', rotpastep=float(5.0), pastep=float(360.0), pblimit=float(0.05), imagetilevol=int(0), singleprecisiononly=False, numthreads=int(-1), psterm=True, aterm=True, mterm=True, wbawp=False, conjbeams=True): 

1139 """This function is for setting different gridding and memory options 

1140  

1141 begin{description} 

1142 item[ftmachine] The options for ftmachine are: 

1143 begin{description} 

1144 item[ft] Standard interferometric gridding 

1145 item[sd] Standard single dish gridding 

1146 item[both] ft and sd as appropriate. 

1147 item[wproject] option for using the wproject algorithm for wide-field 

1148 imaging; when this option is used the parameter {tt wprojplanes} 

1149 define the number of convolution functions to be used 

1150 item[mosaic] option to use the gridder that uses the primary beam as 

1151 the convolution function in gridding 

1152  

1153 end{description} 

1154 item[cache] The size of the cache used (in complex pixels) during the 

1155 gridding process. The default is to use half the physical memory of 

1156 the machine as specified by the aipsrc variable system.resources.memory. 

1157 item[tile] The side of the tile (in complex pixels) during the 

1158 gridding process. 

1159 item[gridfunction] The gridding function used. Currently only 

1160 Box-car ('BOX') and Prolate Spheriodal Wave Function ('SF') 

1161 are supported. In the case of Single-Dish imaging the Primary Beam ('PB'), 

1162 Gaussian ('GAUSS'), and Gaussian * Jinc ('GJINC') also can be used. 

1163 item[location] For some unusual types of image, one needs to know the 

1164 location to be used in calculating phase rotations. For example, 

1165 one can specify images to be constructed in azel, in which 

1166 case, an antenna position must be chosen. One can use functions of 

1167 measures: either 

1168 observatory to 

1169 get the position of a named observatory ({em e.g.} 

1170 me.observatory('ATCA')) or 

1171 position to set 

1172 the position ({em e.g.}me.position('wgs84','30deg','40deg','10m')). 

1173 Although this information is available from the MeasurementSet, what 

1174 location is ambiguous in some cases {em e.g.} VLBI. 

1175 item[padding] When gridding and transforming, the array may be 

1176 padded by this factor in the image plane. This reduces aliasing, 

1177 especially in wide-field cleaning. 

1178 item[usemodelcol] if this is false it tells imager to create and use the model 

1179 visibility on the fly and in memory as far as possible...otherwise 

1180 if it is True then imager will use the MODEL_DATA column to do this. 

1181 item[wprojplanes] this parameter is is used only of {tt ftmachine} 

1182 is set to {tt wproject}. This defines how many convolution functions 

1183 is used in the Wprojection gridder (a -1 implies an automatic determination). 

1184 end{description} 

1185 """ 

1186 return self._swigobj.setoptions(ftmachine, cache, tile, gridfunction, location, padding, freqinterp, wprojplanes, epjtablename, applypointingoffsets, dopbgriddingcorrections, cfcachedirname, rotpastep, pastep, pblimit, imagetilevol, singleprecisiononly, numthreads, psterm, aterm, mterm, wbawp, conjbeams) 

1187 

1188 def setscales(self, scalemethod='nscales', nscales=int(5), uservector=[ float(0.0),float(3.0),float(10.0) ]): 

1189 """The multiscale clean algorithm cleans an image on a number of 

1190 different scales, decomposing the image into Gaussians of these scale sizes. 

1191 This function allows the user to set the number 

1192 of scales used (using the nscales method), or to directly control the 

1193 sizes of the scales in pixels (using the uservector method). When using the 

1194 nscales method, the scales are calculated using the following formula: 

1195 begin{equation} 

1196 theta_{minor} 10.0 ^{(i- N_{scales}/2)/2.0} 

1197 end{equation} 

1198 where $theta_{min}$ is the fitted minor axis of the clean beam. The 

1199 first value is zero. 

1200 """ 

1201 return self._swigobj.setscales(scalemethod, nscales, uservector) 

1202 

1203 def setsmallscalebias(self, inbias=float(0.6)): 

1204 """ 

1205 """ 

1206 return self._swigobj.setsmallscalebias(inbias) 

1207 

1208 def settaylorterms(self, ntaylorterms=int(2), reffreq=float(0.0)): 

1209 """The multi-frequency clean algorithm cleans an image by approximating its spectra 

1210 by a Taylor series expansion. This function allows the user to set the number of 

1211 Taylor terms to be used. Options are 1,2,3. 

1212 """ 

1213 return self._swigobj.settaylorterms(ntaylorterms, reffreq) 

1214 

1215 def setsdoptions(self, scale=float(1.0), weight=float(1.0), convsupport=int(-1), pointingcolumntouse='DIRECTION', truncate=[ ], gwidth=[ ], jwidth=[ ], minweight=float(0.), clipminmax=False, enablecache=False, convertfirst='NEVER'): 

1216 """Various less-often-used options for single dish processing can be set. 

1217  

1218 begin{description} 

1219 item[scale] The overall scale of the single dish data is multiplied by this 

1220 factor. 

1221 item[weight] The weight given to the single dish data in the imaging 

1222 is multiplied by this factor. 

1223 item[convsupport] This parameter can be used to change the support used in gridding single dish data in imaging. If 'PB' or 'pb' is used as the 'convtype' in 

1224 setoptions this parameter is ignored as the support is defined by the primary beam. The deafult of -1 mans 1 as convsupport is used for 'box' convolution function and 3 is used for 'SF' convolution function. 

1225 item[pointingcolumntouse] This parameter is NOT to be changed under normal circumstances. This is to be used by those who know what they are doing and want to try to use different columns in the POINTING table especially if they believe their dish direction is wrong. And if any of the {tt _OFFSET} columns is used do not expect to be able to use a different frame in the image setup in defineimage. Possible values are {tt DIRECTION, TARGET, ENCODER, POINTING_OFFSET, SOURCE_OFFSET} 

1226 item[truncate] The truncation radius as a quantity or a float value. This parameter is effective only when 'GAUSS' or 'GJINC' is used as the 'convtype' in setoptions. You can use an unit 'pixel' to specify truncation radius as pixel value. If float value is set, or quantity without unit is set, its unit will be 'pixel'. 

1227 item[gwidth] The width of the gaussian beam as a radius of half maximum. This parameter is effective only when 'GAUSS' or 'GJINC' is used as the 'convtype' in setoptions. You can use an unit 'pixel' to specify truncation radius as pixel value. If float value is set, or quantity without unit is set, its unit will be 'pixel'. Note that, when 'GJINC' is used as the 'convtype', gwidth doesn't directry specify width of the convolution function. 

1228 item[jwidth] The witdh of the jinc beam as a parameter c, where jinc = J_1(pi*x/c)/(pi*x/c). This parameter is effective only when 'GJINC' is used as the 'convtype' in setoptions. You can use an unit 'pixel' to specify truncation radius as pixel value. If float value is set, or quantity without unit is set, its unit will be 'pixel'. Note that jwidth doesn't directly specify width of the convolution function. 

1229 end{description} 

1230 """ 

1231 return self._swigobj.setsdoptions(scale, weight, convsupport, pointingcolumntouse, truncate, gwidth, jwidth, minweight, clipminmax, enablecache, convertfirst) 

1232 

1233 def setvp(self, dovp=False, usedefaultvp=True, vptable='', dosquint=False, parangleinc=[ ], skyposthreshold=[ ], telescope='', verbose=True): 

1234 """Set the voltage pattern model (and hence, the primary beam) used for a 

1235 telescope. There are currently two ways to set the voltage pattern: by using 

1236 the extensive list of defaults which the system knows about, or by creating a 

1237 voltage pattern description with the vpmanager. The default voltage patterns 

1238 include both a high and a low frequency VP for the WSRT, a VP for each 

1239 observing band at the AT, several VP's for the VLA, including the appropriate 

1240 beam squint for each observing band, and Gaussian for the BIMA dishes. Due to 

1241 temporary limitations in the internal structure of the visibility buffer, only 

1242 one telescope's voltage pattern can be applied to a particular MeasurementSet. 

1243 This will be corrected shortly. 

1244 """ 

1245 return self._swigobj.setvp(dovp, usedefaultvp, vptable, dosquint, parangleinc, skyposthreshold, telescope, verbose) 

1246 

1247 def setweightgrid(self, weight=[ ], type='imaging'): 

1248 """This is a utility function when running multi imager processes in parallel on subsection of an ms/data independently 

1249 One would wish to weight the dirty image before averaging or set the imaging weight density (when using unform or 

1250 Brigg's style weighting) to account for all the data being used. This is {bf NOT} for the general user but for people who 

1251 are parallelizing at the scripting level. 

1252 """ 

1253 return self._swigobj.setweightgrid(weight, type) 

1254 

1255 def smooth(self, model=[ ], image=[ ], usefit=True, bmaj=[ ], bmin=[ ], bpa=[ ], normalize=True): 

1256 """The model images are convolved with the specified Gaussian beam. By 

1257 default (normalize=T), the beam volume is normalized to unity so that 

1258 the smoothing is flux preserving. The smoothing used in restoration is 

1259 not normalized. 

1260 """ 

1261 return self._swigobj.smooth(model, image, usefit, bmaj, bmin, bpa, normalize) 

1262 

1263 def stop(self): 

1264 """Stop the currently executing function as soon as possible. Note that 

1265 it is not always possible to stop a function. 

1266 """ 

1267 return self._swigobj.stop() 

1268 

1269 def summary(self): 

1270 """Writes a summary of the properties of the imager to the 

1271 default logger. This includes: 

1272 begin{itemize} 

1273 item The name of the MeasurementSet (set in construction or via the 

1274 open function. 

1275 item The parameters of the image (set via defineimage) 

1276 item The current beam (set by fitpsf 

1277 or setbeam. 

1278 item The selection of an ms (set via selectvis) 

1279 item The general processing options (set via setoptions) 

1280 end{itemize} 

1281 """ 

1282 return self._swigobj.summary() 

1283 

1284 def uvrange(self, uvmin=float(0.0), uvmax=float(0.0)): 

1285 """Apply a uvrange so that only points within a given uvrange are selected for further usage. To be noted selectvis if used after uvrange will reset the selected range. So selectvis should be used prior to uvrange or can be used 

1286  

1287 to reset it if one changes one's mind. The points are not flagged! Further point to be noted for spectral line data the uv distance is calculated using the mean of the wavelengths of the different spectral channels selected. 

1288 """ 

1289 return self._swigobj.uvrange(uvmin, uvmax) 

1290 

1291 def weight(self, type='natural', rmode='none', noise=[ ], robust=float(0.0), fieldofview=[ ], npixels=int(0), mosaic=False): 

1292 """Apply visibility weighting to correct for the local density of 

1293 sampling in the uv plane. The imaging weights are calculated on the fly 

1294 when processing the data and can be viewed by 

1295 plotweights. 

1296  

1297 To correct for visibility sampling effects, natural, uniform, radial, and Briggs weighting are supported. These work as 

1298 follows. Then: 

1299 begin{description} 

1300 item[natural]: minimizes the noise in the dirty image. The weight of 

1301 the $i$-th sample is set to the inverse variance: 

1302 begin{equation} 

1303 w_i={1over{sigma_i^2}} 

1304 end{equation} 

1305 where $sigma_i$ is the noise of the $i$'th sample. 

1306 item[radial]: approximately minimizes rms sidelobes for an east-west synthesis 

1307 array. The weight of the $i$-th sample is multiplied 

1308 by the radial distance from the center of the $u,v$ plane: 

1309 begin{equation} 

1310 w_i=w_i sqrt{u_i^2+v_i^2} 

1311 end{equation} 

1312 item[uniform]: For Briggs and uniform weighting, we first grid the inverse 

1313 variance $w_i$ for all selected data onto a grid of size given by the 

1314 argument npixels (default to nx) and u,v cell-size given by 

1315 $2/$fieldofview where fieldofview is the specified field of view 

1316 (defaults to the image field of view). This forms the gridded weights 

1317 $W_k$. The weight of the $i$-th sample is then changed: 

1318 begin{equation} 

1319 w_i={w_iover{W_k}} 

1320 end{equation} 

1321 where $W_k$ is the gridded weight of the relevant cell. 

1322 It may be shown that this minimizes rms sidelobes over 

1323 the field of view. By changing the field of view, one may suppress 

1324 the sidelobes over a region different (usually smaller) than the 

1325 image size. 

1326 item[briggs: rmode='norm']: The weights are changed: 

1327 begin{equation} 

1328 w_i={w_iover{1 + W_k f^2}} 

1329 end{equation} 

1330 where: 

1331 begin{equation} 

1332 f^2={{(5*10^{-R})^2}over{{sum_k W_k^2}over{sum_i w_i}}} 

1333 end{equation} 

1334 and $R$ is the robust parameter. The scaling of $R$ is such that 

1335 $R=0$ gives a good tradeoff between resolution and sensitivity. 

1336 $R$ takes value between -2.0 (close to uniform weighting) to 2.0 

1337 (close to natural). 

1338 item[briggs: rmode='abs']: The weights are changed: 

1339 begin{equation} 

1340 w_i={w_iover{W_k*R^2+2*sigma_R^2}} 

1341 end{equation} 

1342 where $R$ is the robust parameter and $sigma_R$ is the noise 

1343 parameter. 

1344 end{description} 

1345 For more details about Briggs (aka robust) weighting, see the htmladdnormallink{Briggs thesis} 

1346 {briggsURL}. 

1347  

1348 Note that this weighting is {em not} cumulative since the imaging weights are 

1349 calculated from the specified weight (function of noise; usually $1/sigma^2$) per visibility 

1350 (actually stored in the WEIGHT column). 

1351 """ 

1352 return self._swigobj.weight(type, rmode, noise, robust, fieldofview, npixels, mosaic) 

1353 

1354 def mapextent(self, ref='J2000', movingsource='', pointingcolumntouse='DIRECTION'): 

1355 """TODO: description must be filled 

1356 """ 

1357 return self._swigobj.mapextent(ref, movingsource, pointingcolumntouse) 

1358 

1359 def pointingsampling(self, pattern='raster', ref='J2000', movingsource='', pointingcolumntouse='DIRECTION', antenna=''): 

1360 """Calculate sampling interval of an MS. 

1361 """ 

1362 return self._swigobj.pointingsampling(pattern, ref, movingsource, pointingcolumntouse, antenna) 

1363