Coverage for /wheeldirectory/casa-6.7.0-11-py3.10.el8/lib/py/lib/python3.10/site-packages/casatools/__casac__/regionmanager.py: 41%

138 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-23 15:54 +0000

1# This file was automatically generated by SWIG (http://www.swig.org). 

2# Version 3.0.12 

3# 

4# Do not make changes to this file unless you know what you are doing--modify 

5# the SWIG interface file instead. 

6 

7from sys import version_info as _swig_python_version_info 

8if _swig_python_version_info >= (2, 7, 0): 

9 def swig_import_helper(): 

10 import importlib 

11 pkg = __name__.rpartition('.')[0] 

12 mname = '.'.join((pkg, '_regionmanager')).lstrip('.') 

13 try: 

14 return importlib.import_module(mname) 

15 except ImportError: 

16 return importlib.import_module('_regionmanager') 

17 _regionmanager = swig_import_helper() 

18 del swig_import_helper 

19elif _swig_python_version_info >= (2, 6, 0): 

20 def swig_import_helper(): 

21 from os.path import dirname 

22 import imp 

23 fp = None 

24 try: 

25 fp, pathname, description = imp.find_module('_regionmanager', [dirname(__file__)]) 

26 except ImportError: 

27 import _regionmanager 

28 return _regionmanager 

29 try: 

30 _mod = imp.load_module('_regionmanager', fp, pathname, description) 

31 finally: 

32 if fp is not None: 

33 fp.close() 

34 return _mod 

35 _regionmanager = swig_import_helper() 

36 del swig_import_helper 

37else: 

38 import _regionmanager 

39del _swig_python_version_info 

40 

41try: 

42 _swig_property = property 

43except NameError: 

44 pass # Python < 2.2 doesn't have 'property'. 

45 

46try: 

47 import builtins as __builtin__ 

48except ImportError: 

49 import __builtin__ 

50 

51def _swig_setattr_nondynamic(self, class_type, name, value, static=1): 

52 if (name == "thisown"): 

53 return self.this.own(value) 

54 if (name == "this"): 

55 if type(value).__name__ == 'SwigPyObject': 

56 self.__dict__[name] = value 

57 return 

58 method = class_type.__swig_setmethods__.get(name, None) 

59 if method: 

60 return method(self, value) 

61 if (not static): 

62 if _newclass: 

63 object.__setattr__(self, name, value) 

64 else: 

65 self.__dict__[name] = value 

66 else: 

67 raise AttributeError("You cannot add attributes to %s" % self) 

68 

69 

70def _swig_setattr(self, class_type, name, value): 

71 return _swig_setattr_nondynamic(self, class_type, name, value, 0) 

72 

73 

74def _swig_getattr(self, class_type, name): 

75 if (name == "thisown"): 

76 return self.this.own() 

77 method = class_type.__swig_getmethods__.get(name, None) 

78 if method: 

79 return method(self) 

80 raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name)) 

81 

82 

83def _swig_repr(self): 

84 try: 

85 strthis = "proxy of " + self.this.__repr__() 

86 except __builtin__.Exception: 

87 strthis = "" 

88 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 

89 

90try: 

91 _object = object 

92 _newclass = 1 

93except __builtin__.Exception: 

94 class _object: 

95 pass 

96 _newclass = 0 

97 

98class regionmanager(_object): 

99 """Proxy of C++ casac::regionmanager class.""" 

100 

101 __swig_setmethods__ = {} 

102 __setattr__ = lambda self, name, value: _swig_setattr(self, regionmanager, name, value) 

103 __swig_getmethods__ = {} 

104 __getattr__ = lambda self, name: _swig_getattr(self, regionmanager, name) 

105 __repr__ = _swig_repr 

106 

107 def __init__(self): 

108 """__init__(self) -> regionmanager""" 

109 this = _regionmanager.new_regionmanager() 

110 try: 

111 self.this.append(this) 

112 except __builtin__.Exception: 

113 self.this = this 

114 

115 def absreltype(self, *args, **kwargs): 

116 """ 

117 absreltype(self, _absrelvalue) -> string 

118 

119 

120 

121 Summary: 

122 Convert region type value to a string 

123 

124 Description: 

125 

126 

127 

128 This function is not intended for general user use. 

129 

130 Regions may be specified with coordinates which are absolute or 

131 relative. This function converts the integer code defining the 

132 absolute/relative type of the coordinates (which is stored in the 

133 region) into a string (maybe for printing purposes). 

134 

135 The different types are 

136 

137 

138 Integer String Description 

139 1 abs Absolute coordinate 

140 2 relref Relative reference pixel 

141 3 relcen Relative to center of image 

142 4 reldir Relative to some direction 

143 

144 

145 

146 Input Parameters: 

147 absrelvalue Region type value 

148 

149 Example: 

150 

151 - r = rg.box(blc=[3,40], trc=[80,90]) # Create region 

152 - v = r.get('arblc') # Get absrel value vector for blc 

153 - for i in range( len(v) ): 

154 + print rg.absreltype(v[i]) # Print string conversion for each axis 

155 - 

156 

157 -------------------------------------------------------------------------------- 

158 

159 """ 

160 return _regionmanager.regionmanager_absreltype(self, *args, **kwargs) 

161 

162 

163 def box(self, *args, **kwargs): 

164 """ 

165 box(self, _blc, _trc, _inc, _absrel, _frac, _comment) -> record * 

166 

167 

168 

169 Summary: 

170 Create a pixel box region 

171 

172 Description: 

173 

174 

175 

176 This function creates a multi-dimensional pixel box region. The box is 

177 specified by a bottom-left corner, and top-right corner and an increment 

178 (or stride). Pixel coordinates are considered to run from 1 at the 

179 bottom left corner of the image to the image shape at the top-right 

180 corner of the image. 

181 

182 You can specify whether the coordinates are given as pixel coordinates 

183 ({stfaf frac=F}) or fractions of the image shape ({stfaf frac=T}). 

184 Absolute fractions are in the range [0,1]. 

185 

186 You can also specify whether the coordinates are given as absolute 

187 coordinates ({stfaf absrel='abs'}) or relative to the reference pixel 

188 ({stfaf absrel='relref'}) or relative to the center of the image 

189 ({stfaf absrel='relcen'}). 

190 

191 Input Parameters: 

192 blc blc of the box 

193 trc trc of the box 

194 inc increment 

195 absrel Absolute or relative coordinates 

196 frac Pixel or fractional coordinates 

197 comment A comment stored with the region 

198 

199 Example: 

200 

201 ia.open('myimage') 

202 ia.shape() 

203 [155 178 256] 

204 

205 r = rg.box() # create region 

206 - 

207 - ia.boundingbox(r) 

208 [blc=[1 1 1] , trc=[155 178 256] , inc=[1 1 1] , bbShape=[155 178 256] , 

209 regionShape=[155 178 256] , imageShape=[155 178 256] ] 

210 

211 

212 This region, on application to an image, selects the entire image. 

213 

214 

215 

216 - ia.open('myimage') 

217 - ia.shape() 

218 [155 178 256] 

219 - 

220 - r=rg.box(blc=[5,10]) 

221 - ia.boundingbox(r) 

222 [blc=[5 10 1] , trc=[155 178 256] , inc=[1 1 1] , bbShape=[151 169 256] , 

223 regionShape=[151 169 256] , imageShape=[155 178 256] ] 

224 

225 

226 This region is only specified for the first two axes of the blc. 

227 Automatic extension rules apply for the other axis and the trc 

228 (defaults to the shape). 

229 

230 

231 

232 - ia.open('myimage') 

233 - ia.shape() 

234 [155 178 256] 

235 - 

236 - r = rg.box(blc=[10, 10, 10], trc=[20, 20, 20], inc=[2, 2, 2]) 

237 - ia.boundingbox(r) 

238 [blc=[10 10 10] , trc=[20 20 20] , inc=[2 2 2] , bbShape=[11 11 11] , 

239 regionShape=[6 6 6] , imageShape=[155 178 256] ] 

240 - 

241 stats=ia.statistics(region=r, list=False); 

242 stats['npts'][0] 

243 216 

244 

245 

246 This region picks out every other pixel in the 3D box. The 

247 ``regionShape'' field of the bounding box record does reflect the 

248 increment whereas ``bbShape'' does not. You can see that the number of 

249 points used in determining the statistics (216) reflects the increment 

250 as well. 

251 

252 

253 

254 THIS EXAMPLE IS NOT VALID YET 

255 

256 - ia.open('myimage') 

257 - ia.shape() 

258 [64 128] 

259 - 

260 - rmd = rg.dflt() 

261 - r = rg.box([-5,-10], [rmd,20], absrel='relcen') 

262 - 

263 - ia.boundingbox(r) 

264 [blc=[28 55] , trc=[64 85] , inc=[1 1] , bbShape=[37 31] , 

265 regionShape=[37 31] , imageShape=[64 128] ] 

266 

267 

268 The region is specified in pixels relative to the center of the image. 

269 Note the use of the default value ({cf rg.dflt()}) to default the first 

270 axis of the trc argument to the image shape without having to know the 

271 image shape. 

272 

273 

274 

275 - ia.open('myimage') 

276 - ia.shape() 

277 [155 178 256] 

278 - 

279 - summ=ia.summary(list=False) 

280 - summ['header']['refpix'] 

281 [90 90 1] 

282 - 

283 - r = rg.box([-0.25,-0.3], [0.25, 0.5], frac=True, absrel='relref') 

284 - ia.boundingbox(r) 

285 [blc=[39 37 1] , trc=[116 178 256] , inc=[1 1 1] , bbShape=[78 142 256] , 

286 regionShape=[78 142 256] , imageShape=[155 178 256] ] 

287 

288 

289 This example shows selection by relative to reference pixel fractional 

290 coordinates plus auto extension to unspecified axes. 

291 

292 -------------------------------------------------------------------------------- 

293 

294 """ 

295 return _regionmanager.regionmanager_box(self, *args, **kwargs) 

296 

297 

298 def frombcs(self, *args, **kwargs): 

299 """ 

300 frombcs(self, _csys, _shape, _box, _chans, _stokes, _stokescontrol, _region) -> record * 

301 

302 

303 

304 Summary: 

305 Create a world coordinate region based on box-chan-stokes input 

306 

307 Description: 

308 

309 

310 

311 This function creates a multi-dimensional world coordinate region based 

312 on box, chans, stokes inputs familiar from image analysis tasks. It is 

313 being introduced as a temporary means of refactoring some python level 

314 task code into C++. However, if users find it to have value, its existence 

315 can be permanent. 

316 

317 Input Parameters: 

318 csys Coordinate system record. Must be specified. 

319 shape shape of the image. Necessary for boundedness checks. Must have the same number of dimensions as the associated coordinate system. Default = [] 

320 box Direction plane box specification as normally provided in image analysis tasks. '' means use entire directional plane as specified in shape. Default ''. 

321 chans Channel spec as normally provided to image analysis tasks. '' means use all channels, Default ''. 

322 stokes Stokes spec as normally provided to image analysis tasks. '' means use stokescontrol for setting stokes. Default ''. 

323 stokescontrol Polarization set to use if stokes parameter is not specified. Choices are 'a' (use all stokes) and 'f' (use first stokes). Default 'a'. 

324 region Named region in the form imagename:regionname or region dictionary. Used only if box, chans, stokes not specified. Default ''. 

325 

326 -------------------------------------------------------------------------------- 

327 

328 """ 

329 return _regionmanager.regionmanager_frombcs(self, *args, **kwargs) 

330 

331 

332 def complement(self, *args, **kwargs): 

333 """ 

334 complement(self, _region, _comment) -> record * 

335 

336 

337 

338 Summary: 

339 Create the complement of a world region 

340 

341 Description: 

342 

343 

344 This function (short-hand name {tt comp}) creates the complement of 

345 a world region(s). 

346 

347 The region parameter can be a single region record defining a simple 

348 or complex region or it can contain several region records in a 

349 Python dictionary. If multiple regions are given then the union of 

350 this set of regions is taken first, and the complement is found from 

351 the union. 

352 

353 NOTE: ia.statistics() is UNABLE to handle complement regions in CASA yet. 

354 

355 Input Parameters: 

356 region The world region 

357 comment A comment stored with the region 

358 

359 Example: 

360 

361 - ia.open('hcn') 

362 - csys = ia.coordsys() 

363 - ia.shape() 

364 [155 178] 

365 - 

366 - blc = '17:42:29.303 -28.59.18.600' 

367 - trc = '17:42:28.303 -28.59.10.600' 

368 - r2 = rg.wbox(blc,trc,[1,2],csys.torecord()) 

369 - r3 = rg.complement(r2); 

370 - 

371 - ia.statistics(region=r2) # Some output discarded 

372 Selected bounding box [90, 90] to [103, 98] 

373 No pts = 126 

374 - 

375 - ia.statistics(region=r3) 

376 Selected bounding box [1, 1] to [155, 178] # Some output discarded 

377 No pts = 27464 

378 

379 

380 As expected, the number of pixels in the complement 

381 is $(155*178)-126=27464$ 

382 

383 -------------------------------------------------------------------------------- 

384 

385 """ 

386 return _regionmanager.regionmanager_complement(self, *args, **kwargs) 

387 

388 

389 def concatenation(self, *args, **kwargs): 

390 """ 

391 concatenation(self, _box, _regions, _comment) -> record * 

392 

393 

394 

395 Summary: 

396 Concatenate world regions along a new axis 

397 

398 Description: 

399 

400 

401 This function (short-hand name {tt concat}) creates a region which is 

402 the concatenation along a new axis of the given world regions. 

403 

404 This function is similar to the 

405 extension function. The 

406 {stfaf concatenation} function allows you to take many world regions, 

407 and concatenate them along one axis (rather than take one region and 

408 extend it along many axes which is what function {stff extension} 

409 does). 

410 

411 For example, you may have generated a different polygonal region for 

412 each spectral pixel of a spectral-line cube and you wish to concatenate them 

413 together to form the overall region for use in a deconvolution 

414 application. 

415 

416 The axis to concatenate along is specified as a 1-dimensional world box. 

417 The shape of the 1D box must contain as many pixels (although you 

418 don't have to specify it in pixels) as there are regions 

419 to concatenate. 

420 

421 Because this function is most likely to be used in a script, the 

422 interface takes a record containing {stff region} records, Python 

423 dictionaries, as there might be a lot of them. 

424 

425 Input Parameters: 

426 box The axis to concatenate along 

427 regions World regions 

428 comment A comment stored with the region 

429 

430 Example: 

431 

432 - ia.open('cube') 

433 - csys = ia.coordsys() 

434 - rg.setcoordinates(csys.torecord(), verbose=False) # Don't tell us each time 

435 # private coordinates used 

436 - box = rg.wbox(blc='20pix', trc='25pix', pixelaxes=[2]) 

437 - bb = ia.boundingbox(box) 

438 - 

439 - regs = {}; 

440 - local x, y; 

441 - for i in bb.blc[3]:bb.trc[3]: 

442 + # Some code in function `mypolygon' generates the 

443 + # x and y vectors for this spectral pixel, perhaps interactively 

444 + 

445 + mypolygon(x,y); 

446 + regs['reg'+str(j)] = rg.wpolygon(x,y,[0,1]) 

447 - rc = rg.concatenation(box, regs) 

448 - 

449 - ia.statistics(region=rc, axes=[1,2]) 

450 Plane Freq Npts Sum Mean Rms Sigma Minimum Maximum 

451 20 1.413724e+09 25 -4.778154e+00 -1.911262e-01 2.578399e-01 1.766359e-01 -4.252437e-01 1.820721e-01 

452 21 1.413744e+09 40 -7.476902e+00 -2.990761e-01 3.692736e-01 2.210687e-01 -6.073643e-01 1.634156e-01 

453 22 1.413763e+09 32 -2.696485e+00 -1.078594e-01 1.916686e-01 1.617070e-01 -3.295788e-01 1.422531e-01 

454 23 1.413783e+09 77 4.889158e-01 1.955663e-02 3.148451e-02 2.518293e-02 -3.671944e-02 6.521463e-02 

455 24 1.413803e+09 25 -1.337832e+00 -5.351327e-02 6.296221e-02 3.385893e-02 -1.232493e-01 1.014871e-02 

456 25 1.413823e+09 15 1.091297e+00 4.365189e-02 7.252339e-02 5.910932e-02 -6.364560e-02 1.630955e-01 

457 

458 

459 

460 In this example, we create a 1D box and use it to concatenate 2D xy 

461 polygons along the z axis. We then ask for the statistics of each plane 

462 in the region. There is a differerent number of pixels per plane 

463 as each polygon is different. 

464 

465 -------------------------------------------------------------------------------- 

466 

467 """ 

468 return _regionmanager.regionmanager_concatenation(self, *args, **kwargs) 

469 

470 

471 def deletefromtable(self, *args, **kwargs): 

472 """ 

473 deletefromtable(self, _tablename, _regionname) -> bool 

474 

475 

476 

477 Summary: 

478 Delete regions from a Table 

479 

480 Description: 

481 

482 

483 

484 

485 This function deletes a region stored in an casa Table. 

486 

487 For the {stfaf tablename} argument, 

488 

489 you have to give the name of an existing 

490 CASA table on disk (any kind of table). 

491 

492 You specify the name of the region with the {stfaf regionname} 

493 arguments. If you set {stfaf regionname=''} then nothing is done. The names of all the regions stored in a Table can be found 

494 with the function 

495 namesintable. 

496 

497 Input Parameters: 

498 tablename The table 

499 regionname Name(s) of the region(s) to delete 

500 

501 Example: 

502 

503 - names = rg.namesintable(hcn) 

504 - rg.deletefromtable(img, names[0]) 

505 

506 

507 In this example, we delete the first region that is reported to be in the Table {tt 'hcn'}. 

508 

509 -------------------------------------------------------------------------------- 

510 

511 """ 

512 return _regionmanager.regionmanager_deletefromtable(self, *args, **kwargs) 

513 

514 

515 def difference(self, *args, **kwargs): 

516 """ 

517 difference(self, _region1, _region2, _comment) -> record * 

518 

519 

520 

521 Summary: 

522 Create the difference of two world regions 

523 

524 Description: 

525 

526 

527 This function (short-hand name {stff diff}) creates 

528 a region which is the difference of two world regions. The order 

529 of the regions is important. 

530 

531 The difference consists of all pixels masked-on in the first 

532 region and not masked-on in the second region. 

533 

534 Input Parameters: 

535 region1 The first world region 

536 region2 The second world region 

537 comment A comment stored with the region 

538 

539 Example: 

540 

541 - ia.open('hcn') 

542 - csys = ia.coordsys() 

543 - rg.setcoordinates(csys.torecord()) 

544 - 

545 - blc = '10pix 10pix' 

546 - trc = '60pix 60pix' 

547 - r1 = rg.wbox(blc,trc,[0,1]) 

548 - 

549 - blc = '50pix 50pix' 

550 - trc = '80pix 80pix' 

551 - r2 = rg.wbox(blc, trc, [0,1]) 

552 - 

553 - r3 = rg.difference(r1, r2) # r1 - r2 

554 - 

555 - ia.statistics(region=r1) # Some output discarded 

556 Selected bounding box [10, 10] to [60, 60] 

557 No pts = 2601 

558 - 

559 - ia.statistics(region=r3) # Some output discarded 

560 Selected bounding box [10, 10] to [60, 60] 

561 No pts = 2480 

562 - 

563 - 

564 - r4 = rg.difference(r2, r1) # r2 - r1 

565 - 

566 - ia.statistics(region=r2) # Some output discarded 

567 Selected bounding box [50, 50] to [80, 80] 

568 No pts = 961 

569 - 

570 - ia.statistics(region=r4) # Some output discarded 

571 Selected bounding box [50, 50, 1] to [80, 80, 64] 

572 No pts = 840 

573 

574 

575 We use pixel units and boxes in this example to make it clear what is 

576 happening. The two regions overlap in the top right corner area of 

577 region {stf r1} by an area of $11times11=121$~pixels. Therefore, the 

578 difference region {stf r3} has $2601-121=2480$~pixels in it. For 

579 difference region {stf r4}, the region of overlap is the bottom left 

580 corner area of region {stf r2} and still contains 121~pixels. We expect 

581 $961-121=840$~pixels in the differnce region. 

582 

583 -------------------------------------------------------------------------------- 

584 

585 """ 

586 return _regionmanager.regionmanager_difference(self, *args, **kwargs) 

587 

588 

589 def done(self): 

590 """ 

591 done(self) -> bool 

592 

593 

594 

595 Summary: 

596 Destroy this regionmanager 

597 

598 Description: 

599 

600 

601 

602 This function destroys the contents of the {stf regionmanager} tool 

603 (including its GUI). The tool still exists as a Glish variable, but 

604 it is no longer a Regionmanager ! You are unlikely to need this 

605 function. 

606 

607 

608 -------------------------------------------------------------------------------- 

609 

610 """ 

611 return _regionmanager.regionmanager_done(self) 

612 

613 

614 def selectedchannels(self, *args, **kwargs): 

615 """ 

616 selectedchannels(self, _specification, _shape) -> std::vector< long > 

617 

618 

619 

620 Summary: 

621 Get an array of zero-based selected channel numbers from an input string specificaiton. 

622 

623 Description: 

624 

625 

626 This method returns all the selected zero-based channel numbers from the specified string within the image. 

627 

628 

629 

630 

631 

632 Input Parameters: 

633 specification Valid channel specification. See help par.chans for examples. 

634 shape Image shape. Used to determine if the specificaiton lies outside the image. 

635 

636 Example: 

637 

638 ia.fromshape('',[20,20,20]) 

639 rg.setcoordinates(ia.coordsys().torecord()) 

640 selected_channels = rg.selectedchannels(specification='range=[40km/s,50km/s]', shape=ia.shape()) 

641 ia.done() 

642 

643 -------------------------------------------------------------------------------- 

644 

645 """ 

646 return _regionmanager.regionmanager_selectedchannels(self, *args, **kwargs) 

647 

648 

649 def fromtextfile(self, *args, **kwargs): 

650 """ 

651 fromtextfile(self, _filename, _shape, _csys) -> record * 

652 

653 

654 

655 Summary: 

656 Create a region dictionary from a region text file. 

657 

658 Description: 

659 

660 

661 This function reads a text file containing region descriptions and 

662 converts it to a python dictionary. 

663 

664 

665 

666 Input Parameters: 

667 filename List of text file containing the region description 

668 shape Image shape. 

669 csys Coordinate system record. Defaults to coordinate system used in rg.setcoordinates() 

670 

671 -------------------------------------------------------------------------------- 

672 

673 """ 

674 return _regionmanager.regionmanager_fromtextfile(self, *args, **kwargs) 

675 

676 

677 def fromtext(self, *args, **kwargs): 

678 """ 

679 fromtext(self, _text, _shape, _csys) -> record * 

680 

681 

682 

683 Summary: 

684 Create a region dictionary from a region text string. 

685 

686 Description: 

687 

688 

689 This function reads a region region text descriptions and 

690 converts it to a python region dictionary. 

691 

692 

693 

694 Input Parameters: 

695 text region description 

696 shape Image shape, only used if first region is a difference. 

697 csys Coordinate system record. Defaults to coordinate system used in rg.setcoordinates() 

698 

699 Example: 

700 

701 ia.open('test.image') 

702 csys=ia.coordsys() 

703 rg.setcoordinates(csys.torecord()) 

704 a=rg.fromtext('ellipse [[04h31m38.44139, 18d13m57.0861], [1.0arcsec, 1.0arcsec], 0.00000000deg]', shape=[1500, 1500, 1, 1]) 

705 ia.done() 

706 

707 In this example, we create a circular region of 1 arcsec radius centered on J2000 04h31m38.44139 18d13m57.0861 

708 

709 -------------------------------------------------------------------------------- 

710 

711 """ 

712 return _regionmanager.regionmanager_fromtext(self, *args, **kwargs) 

713 

714 

715 def fromfiletorecord(self, *args, **kwargs): 

716 """ 

717 fromfiletorecord(self, _filename, _verbose, _regionname) -> record * 

718 

719 

720 

721 Summary: 

722 Create a region record(s) from a file(s). 

723 

724 Description: 

725 

726 

727 This function reads files containing ImageRegion objects and turns them 

728 into Region Records. 

729 

730 The intended use for this method is to read the file saved by the casa 

731 viewer and turn the files contents into regions that are usabla by the 

732 image analysis tool. 

733 

734 Input Parameters: 

735 filename List of files containing the Image Regions 

736 verbose Report successful saves 

737 regionname Name(s) of the region(s) when saved in the table 

738 

739 Example: 

740 

741 - img = ia.open('hcn') 

742 - rg.fromfiletorecord(T, 'x1 x2', 'file1, file2', r1, r2) 

743 - ia.statistics( region=r1, verbose=True ) 

744 - ia.statistics( region=r2, verbose=True ) 

745 

746 

747 In this example, we create two regions called {stf r1} and {stf r2} 

748 from the files ??? 

749 The regions are renamed to `x1' and `x2' as they are stored. 

750 

751 

752 e 

753 - img = ia.open('hcn') 

754 - r1 = rg.box()f 

755 - r2 = rg.quarter() 

756 - rg.fromglobaltotable(img, T, F, '', r1, r2) 

757 - rg.namesintable(img) 

758 x1 x2 

759 

760 

761 In this example, we save two regions called {stf r1} and {stf r2} to 

762 the table (previously containing no regions) referred to by the image 

763 tool {stf im}. The names for regions are made up for us as we don't 

764 specify them. Note that because the regions are specified by the 

765 special glish `...' argument (it has no actual argument name), we 

766 must give the {stfaf regionname} argument explcitly as an empty vector 

767 of strings (else glish will take the empty string as a region). 

768 

769 -------------------------------------------------------------------------------- 

770 

771 """ 

772 return _regionmanager.regionmanager_fromfiletorecord(self, *args, **kwargs) 

773 

774 

775 def tofile(self, *args, **kwargs): 

776 """ 

777 tofile(self, _filename, _region) -> bool 

778 

779 

780 

781 Summary: 

782 Create a region record file that can be read by from filetorecord. 

783 

784 Description: 

785 

786 

787 This function is to store a region created by the regionmanager in a disk file for future use 

788 

789 Input Parameters: 

790 filename List of files containing the Image Regions 

791 region region record/dict to store in the file 

792 

793 Example: 

794 

795 - img = ia.open('hcn') 

796 - imcs=ia.coordsys() 

797 - blc = ['16:28:25.50', '+040.49.05.61'] 

798 - trc = ['16:24:28.67', '+041.45.28.43'] 

799 - r1 = rg.wbox(blc=blc,trc=trc,pixelaxes=[0,1],csys=imcs.torecord()) 

800 - rg.tofile('myboxregion', r1) 

801 - r1readback=rg.fromfiletorecord('myboxregion') 

802 

803 

804 In this example we create a box region using world coordinates for blc and trc. We save that on disk in a file called {tt 'myboxregion'}. 

805 Then we read it back using the function rg.fromfiletorecord and store it in a variable {tt r1readback}. {tt r1} and {tt r1readback} should be 

806 identical. 

807 

808 -------------------------------------------------------------------------------- 

809 

810 """ 

811 return _regionmanager.regionmanager_tofile(self, *args, **kwargs) 

812 

813 

814 def fromrecordtotable(self, *args, **kwargs): 

815 """ 

816 fromrecordtotable(self, _tablename, _regionname, _regionrec, _asmask, _verbose) -> string 

817 

818 

819 

820 Summary: 

821 Save regions stored in a record into a Table 

822 

823 Description: 

824 

825 

826 

827 

828 This function saves regions into an casa Table 

829 For the {stfaf tablename} argument the user should be the name of an existing 

830 aipspp Table on disk (any kind of table). 

831 

832 If the parameter {tt asmask} is {tt True} then the table has to be an image table. 

833 A mask makes sense with an image only. 

834 

835 

836 You can specify the name the region will have ({stfaf 

837 regionname}) when it is saved in the Table. If you don't specify this, 

838 a digit based name is assigned to it or if specify a name that already 

839 exists a new one will be generated which is close but different. The 

840 function returns you the name the region is assigned 

841 

842 Input Parameters: 

843 tablename The table 

844 regionname Name(s) of the region(s) when saved in the table 

845 regionrec Region(s) to save 

846 asmask save region as a mask rather than region 

847 verbose Report successful saves 

848 

849 Example: 

850 

851 - ia.open('hcn') 

852 - cs=ia.coordsys() 

853 - blc = '16:28:25.50 +040.49.05.61' 

854 - trc = '16:24:28.67 +041.45.28.43' 

855 - r1 = rg.wbox(blc='10pix 20pix',trc='30pix 40pix',pixelaxes=[0,1],csys=cs.torecord()) 

856 - r2 = rg.wbox(blc=blc,trc=trc,pixelaxes=[0,1],csys=cs.torecord()) 

857 - rg.fromrecordtotable('hcn', 'x', r1) 

858 x 

859 - rg.fromrecordtotable('hcn', 'x', r2) 

860 x0 

861 - rg.namesintable('hcn') 

862 x x0 

863 

864 

865 

866 

867 

868 2 CASA image files on disk 'hcn1' 'hcn2' 

869 

870 - names = rg.namesintable('hcn1') 

871 - r = rg.fromtabletorecord('hcn1', names[0]) 

872 - rg.namesintable('hcn2') 

873 - rg.fromrecordtotable('hcn2', names[0], r) 

874 

875 

876 In this example, we recover a region into a record 

877 from one image, and then copy them to another. 

878 

879 

880 

881 ####In this example a region is saved as a mask 

882 ia.open('myfancy.image') 

883 csys=ia.coordsys() 

884 ia.done() 

885 ##Lets make a world-box region 

886 wbox=rg.wbox(['10pix', '10pix', '0pix', '0pix'], ['20pix', '20pix', '0pix', '0pix'], csys=csys.torecord()) 

887 ###save that into the image as a mask rather than just a region and assign it the name 

888 ###mask1 

889 rg.fromrecordtotable('myfancy.image', 'mask1', wbox, asmask=True) 

890 ###now let us set that as default mask 

891 ia.open('myfancy.image') 

892 ia.maskhandler('set', 'mask1') 

893 ia.done() 

894 ###and now let us view that image 

895 viewer('myfancy.image') 

896 

897 -------------------------------------------------------------------------------- 

898 

899 """ 

900 return _regionmanager.regionmanager_fromrecordtotable(self, *args, **kwargs) 

901 

902 

903 def fromtabletorecord(self, *args, **kwargs): 

904 """ 

905 fromtabletorecord(self, _tablename, _regionname, _verbose) -> record * 

906 

907 

908 

909 Summary: 

910 Restore regions from a Table to a record 

911 

912 Description: 

913 

914 

915 

916 This function restores a region from an aipspp Table 

917 to the global name space. 

918 

919 For the {stfaf tablename} argument, you can specify an 

920 image tool, a table tool, 

921 or a string. If you give a string, it should be the name of an existing 

922 aipspp table on disk (any kind of table). 

923 

924 If {stfaf numberfields} is F, then the field names of the 

925 record are the same as they are in the Table. Otherwise, 

926 the regions are put into numbered fields (the field 

927 names could be anything). 

928 

929 You can use the function 

930 namesintable to find out the 

931 names of the regions in the Table. 

932 

933 Input Parameters: 

934 tablename The table 

935 regionname Name of the region(s) to restore 

936 verbose Report successful restores 

937 

938 Example: 

939 

940 - img = ia.open('hcn') 

941 - rec = rg.fromtabletorecord(img, numberfields=True) 

942 - print is_region(rec[0]) 

943 

944 

945 The record fields are numbered, not named. 

946 

947 -------------------------------------------------------------------------------- 

948 

949 """ 

950 return _regionmanager.regionmanager_fromtabletorecord(self, *args, **kwargs) 

951 

952 

953 def intersection(self, *args, **kwargs): 

954 """ 

955 intersection(self, _regions, _comment) -> record * 

956 

957 

958 

959 Summary: 

960 Create the intersection of some world regions 

961 

962 Description: 

963 

964 

965 This function (short-hand name {stff int}) creates a region which is 

966 the intersection of the given world regions. The input regions can 

967 themselves be compound regions (such as the union or intersection etc). 

968 The input regions must be provided as a Python dictionary of regions 

969 (see examples). 

970 

971 Input Parameters: 

972 regions World regions and comment 

973 comment A comment stored with the region 

974 

975 Example: 

976 

977 - ia.open('hcn') 

978 - csys = ia.coordsys() 

979 - rg.setcoordinates(csys.torecord()) 

980 - 

981 - blc = '10pix 10pix 1pix' 

982 - trc = '60pix 60pix 1pix' 

983 - r1 = rg.wbox(blc=blc, trc=trc, pixelaxes=[0,1,2]) 

984 - 

985 - x = qa.quantity([50,55,58,65,58,53,50], 'pix') 

986 - y = qa.quantity([50,53,69,70,63,58,55], 'pix') 

987 - r2 = rg.wpolygon(x=x, y=y, pixelaxes=[0,1]) 

988 - 

989 - regions= {'region1':r1, 'region2':r2} 

990 - r3 = rg.intersection(regions, 'This is the comment') 

991 - 

992 - ia.boundingbox(r1) 

993 [blc=[10 10 1] , trc=[60 60 256] , regionShape=[51 51 256] , imageShape=[155 178 256] ] 

994 - ia.boundingbox(r2) 

995 [blc=[50 50 1] , trc=[65 70 256] , regionShape=[16 21 256] , imageShape=[155 178 256] ] 

996 - ia.boundingbox(r3) 

997 [blc=[50 50 1] , trc=[60 60 256] , regionShape=[11 11 256] , imageShape=[155 178 256] ] 

998 - 

999 - ia.statistics(region=r3) # Some output discarded 

1000 NORMAL: Selected bounding box [50, 50, 1] to [60, 60, 1] 

1001 Number points = 51 

1002 

1003 

1004 

1005 In this example, we use pixel coordinates so that it is clear what is 

1006 happening. You can see that the number of pixels in the intersection 

1007 (51) is less than the number in the bounding box of the intersection 

1008 (121) because the intersection is actually polygonal and does not fill 

1009 the bounding box. 

1010 

1011 

1012 

1013 - ia.open('onno') 

1014 - csys = ia.coordsys() 

1015 - x = qa.quantity([3,6,9,6,5,5,3],'pix') 

1016 - y = qa.quantity([3,4,7,9,7,5,5],'pix') 

1017 - 

1018 - regions = {}; 

1019 - regions['poly'] = rg.wpoly(x,y,[1,2],csys.torecord()) 

1020 - 

1021 - blc = '17:42:29.303 -28.59.18.600' 

1022 - trc = '17:42:28.303 -28.59.10.600' 

1023 - regions['box'] = rg.wbox(blc,trc,[0,1],csys.torecord()) 

1024 - 

1025 - r3 = rg.intersection(regions,'The mysteries of CASA') 

1026 

1027 

1028 This example is the same as the prevoius one, except the regions are 

1029 provided to the intersection function in a record, rather than directly in the 

1030 call sequence. 

1031 

1032 -------------------------------------------------------------------------------- 

1033 

1034 """ 

1035 return _regionmanager.regionmanager_intersection(self, *args, **kwargs) 

1036 

1037 

1038 def ispixelregion(self, *args, **kwargs): 

1039 """ 

1040 ispixelregion(self, _region) -> bool 

1041 

1042 

1043 

1044 Summary: 

1045 Is this region a pixel region ? 

1046 

1047 Description: 

1048 

1049 

1050 NOT IMPLEMENTED IN CASA 

1051 

1052 This function returns T if the region is a pixel region. 

1053 For any other glish variable it returns F. 

1054 

1055 Input Parameters: 

1056 region The region 

1057 

1058 Example: 

1059 

1060 - ia.open('hcn') 

1061 - csys = ia.coordsys() 

1062 - r1 = rg.box() # A pixel region 

1063 - r2 = rg.wbox(csys=csys.torecord()) # A world region 

1064 - rg.ispixelregion(r1) 

1065 T 

1066 - rg.ispixelregion(r2) 

1067 F 

1068 - x = [20,30] 

1069 - rg.ispixelregion(x) 

1070 F 

1071 

1072 -------------------------------------------------------------------------------- 

1073 

1074 """ 

1075 return _regionmanager.regionmanager_ispixelregion(self, *args, **kwargs) 

1076 

1077 

1078 def isworldregion(self, *args, **kwargs): 

1079 """ 

1080 isworldregion(self, _region) -> bool 

1081 

1082 

1083 

1084 Summary: 

1085 Is this region a world region ? 

1086 

1087 Description: 

1088 

1089 

1090 NOT IMPLEMENTED IN CASA 

1091 

1092 This function returns T if the region is a world region. 

1093 For any other glish variable it returns F. 

1094 

1095 Input Parameters: 

1096 region The region 

1097 

1098 Example: 

1099 

1100 - ia.open('hcn') 

1101 - csys = ia.coordsys() 

1102 - r1 = rg.box() # A pixel region 

1103 - r2 = rg.wbox(csys=csys.torecord()) # A world region 

1104 - rg.isworldregion(r1) 

1105 F 

1106 - rg.isworldregion(r2) 

1107 T 

1108 - x = [20,30] 

1109 - rg.isworldregion(x) 

1110 F 

1111 

1112 -------------------------------------------------------------------------------- 

1113 

1114 """ 

1115 return _regionmanager.regionmanager_isworldregion(self, *args, **kwargs) 

1116 

1117 

1118 def namesintable(self, *args, **kwargs): 

1119 """ 

1120 namesintable(self, _tablename) -> std::vector< std::string > 

1121 

1122 

1123 

1124 Summary: 

1125 Find the names of the regions stored in a Table 

1126 

1127 Description: 

1128 

1129 

1130 

1131 This function returns the names of regions stored in an CASA Table. 

1132 

1133 For the {stfaf tablename} argument, you can specify a string; it should be the name of an existing 

1134 aipspp table on disk (any kind of table). 

1135 

1136 Input Parameters: 

1137 tablename The table 

1138 

1139 Example: 

1140 

1141 - names=rg.namesintable('hcn') 

1142 - names 

1143 r1 poly2 int0 

1144 

1145 -------------------------------------------------------------------------------- 

1146 

1147 """ 

1148 return _regionmanager.regionmanager_namesintable(self, *args, **kwargs) 

1149 

1150 

1151 def setcoordinates(self, *args, **kwargs): 

1152 """ 

1153 setcoordinates(self, _csys) -> bool 

1154 

1155 

1156 

1157 Summary: 

1158 Set new default Coordinate System 

1159 

1160 Description: 

1161 

1162 

1163 

1164 This function allows you to (re)set the default Coordinate System 

1165 used by the functions that make world regions. If you don't specifiy a 

1166 Coordinate System when you make the world region, the default Coordinate 

1167 System, if there is one, is used. The Coordinate System is 

1168 stored in a {stf coordinates} tool and is created with 

1169 the coordsys toolfunction. 

1170 

1171 Normally, the world region creating functions like 

1172 wbox and 

1173 wpolygon will issue a message 

1174 each time the private Coordinate System is used. However, if you set 

1175 {stfaf verbose=F} then this will not occur. 

1176 

1177 

1178 

1179 Input Parameters: 

1180 csys Default Coordinate System for use in world regions 

1181 

1182 Example: 

1183 

1184 - ia.open('quiqui') 

1185 - csys = ia.coordsys() 

1186 - rg.setcoordinates(csys.torecord()) 

1187 - r1 = rg.wbox() 

1188 Using private CoordinateSystem from image 'quiqui' 

1189 

1190 -------------------------------------------------------------------------------- 

1191 

1192 """ 

1193 return _regionmanager.regionmanager_setcoordinates(self, *args, **kwargs) 

1194 

1195 

1196 def makeunion(self, *args, **kwargs): 

1197 """ 

1198 makeunion(self, _regions, _comment) -> record * 

1199 

1200 

1201 

1202 Summary: 

1203 Create a union of world regions 

1204 

1205 Description: 

1206 

1207 

1208 

1209 This function takes a minimum of two world regions and creates a region which 

1210 is the union of the given regions. The input regions can themselves be 

1211 compound regions (such as the union or intersection etc). The input 

1212 regions must be a Pythion dictionary of at leat two regions 

1213 (see examples). 

1214 

1215 Input Parameters: 

1216 regions World regions and comment 

1217 comment A comment stored with the region 

1218 

1219 Example: 

1220 

1221 - ia.open('onno') 

1222 - csys = ia.coordsys() 

1223 - x = qa.quantity([3,6,9,6,5,5,3],'pix') 

1224 - y = qa.quantity([3,4,7,9,7,5,5],'pix') 

1225 - r1 = rg.wpoly(x,y,[1,2],csys.torecord()) 

1226 - 

1227 - blc = '17:42:29.303 -28.59.18.600' 

1228 - trc = '17:42:28.303 -28.59.10.600' 

1229 - r2 = rg.wbox(blc,trc,[0,1],csys.torecord()) 

1230 - 

1231 - regions= {'region1':r1, 'region2':r2} 

1232 - r3 = rg.makeunion(regions,'The mysteries of CASA') 

1233 - 

1234 - ia.shape() 

1235 [155 178 256] 

1236 - ia.boundingbox(r1) 

1237 [blc=[3 3 1] , trc=[9 9 256] , inc=[1 1 1] , bbShape=[7 7 256] , 

1238 regionShape=[7 7 256] , imageShape=[155 178 256] ] 

1239 - ia.boundingbox(r2) 

1240 [blc=[90 90 1] , trc=[103 98 256] , inc=[1 1 1] , bbShape=[14 9 256] , 

1241 regionShape=[14 9 256] , imageShape=[155 178 256] ] 

1242 - ia.boundingbox(r3) 

1243 [blc=[3 3 1] , trc=[103 98 256] , inc=[1 1 1] , bbShape=[101 96 256] , 

1244 regionShape=[101 96 256] , imageShape=[155 178 256] ] 

1245 - 

1246 - ia.statistics(region=r1) 

1247 Selected bounding box [3, 3, 1] to [9, 9, 256] 

1248 Number points = 6400 

1249 - 

1250 - ia.statistics(region=r2) 

1251 Selected bounding box [90, 90, 1] to [103, 98, 256] 

1252 Number points = 32256 

1253 - 

1254 - ia.statistics(region=r3) 

1255 Selected bounding box [3, 3, 1] to [103, 98, 256] 

1256 Number points = 38656 

1257 

1258 

1259 When the polygon only is applied, it is auto extended along the third 

1260 axis. The {stff statistics} function finds 6400 pixels in the region, 

1261 which is $6400/256=25$ pixels per plane. Likewise, when the box only is 

1262 applied, the {stff statistics} function finds 32256 pixels in the 

1263 region, which is $32256/256=126$ pixels per plane. When the union is 

1264 applied, the {stff statistics} function finds 38656 pixels in the 

1265 region. First it finds the union of the polygon and box (which are 

1266 specified only in the XY plane) and that union is extended. Thus we 

1267 expect $(25+126)*256=38656$ pixels in the region of the union, as found. 

1268 

1269 

1270 

1271 - ia.open('onno') 

1272 - csys = ia.coordsys() 

1273 - x = qa.quantity([3,6,9,6,5,5,3],'pix') 

1274 - y = qa.quantity([3,4,7,9,7,5,5],'pix') 

1275 - 

1276 - regions = {} 

1277 - regions['poly'] = rg.wpoly(x,y,[0,1],csys.torecord()) 

1278 - 

1279 - blc = '17:42:29.303 -28.59.18.600' 

1280 - trc = '17:42:28.303 -28.59.10.600' 

1281 - regions['box'] = rg.wbox(blc,trc,[0,1],csys.torecord()) 

1282 - 

1283 - r3 = rg.union(regions,'The mysteries of CASA') 

1284 

1285 

1286 This example is the same as the prevoius one, except the regions are 

1287 provided to the union function in a record, rather than directly in the 

1288 call sequence. 

1289 

1290 -------------------------------------------------------------------------------- 

1291 

1292 """ 

1293 return _regionmanager.regionmanager_makeunion(self, *args, **kwargs) 

1294 

1295 

1296 def wbox(self, *args, **kwargs): 

1297 """ 

1298 wbox(self, _blc, _trc, _pixelaxes, _csys, _absrel, _comment) -> record * 

1299 

1300 

1301 

1302 Summary: 

1303 Create a world box region 

1304 

1305 Description: 

1306 

1307 

1308 

1309 This function creates a multi-dimensional world box region; the 

1310 corners of the box are specified in world coordinates. However, the box 

1311 is not a true world volume in that its sides do not follow world 

1312 contours. Its sides are parallel to the pixel axes. If you are in a 

1313 region of high world coordinate contour non-linearity (e.g. near a 

1314 pole), you are probably better off using a world polygon. 

1315 

1316 The box is specified by a bottom-left corner, and a top-right corner. 

1317 The coordinates are given as quantities, and you can give a vector of 

1318 quantities (e.g. {cf blc = qa.quantity('1rad 20deg')} or a 

1319 quantity of a vector (e.g.{cf blc = qa.quantity([10,30], 'rad')}). 

1320 

1321 You can specify whether the coordinates are given as absolute coordinates 

1322 ({stfaf absrel='abs'}) or relative to the reference pixel ({stfaf 

1323 absrel='relref'}) or relative to the center of the image ({stfaf 

1324 absrel='relcen'}). You can specify this for each axis (the same for the 

1325 blc and trc). If you specify less values than the number of 

1326 values in {stfaf blc} or {stfaf trc} then the last value you 

1327 did specify is used as the default for all higher numbered axes 

1328 (e.g. {stfaf absrel='relref'} means {stfaf absrel='relref relref'} 

1329 for two axes). 

1330 

1331 You specify which pixel axes in the image the {stfaf blc} and {stfaf 

1332 trc} vector refer to with the {stfaf pixelaxes} argument. If you 

1333 don't, it defaults to [0,1,2,...]. This specification is an important 

1334 part of world regions. 

1335 

1336 You must also specify the Coordinate System with the {stfaf csys} 

1337 argument. The Coordinate System is encapsulated in a {stfaf coordinates} 

1338 tool and can be recovered from an image with the 

1339 coordsys tool function. You can 

1340 also set a default Coordinate System in the regionmanager with the 

1341 setcoordinates 

1342 function. 

1343 

1344 In the regionmanager we have defined units `pix' and `frac'; these are 

1345 then known to the quanta system. This means 

1346 that you can effectively define a pixel box (except for the stride 

1347 capability) as a world box with most of the advantages of world regions 

1348 (can be used for compound regions). However, it is still not very 

1349 portable to other images because the coordinates are pixel based, 

1350 not world based. 

1351 

1352 Note that the need to deal with the {stfaf pixelaxes} and {stfaf csys} 

1353 is hidden from you when using the gui 

1354 interface of the regionmanager. 

1355 

1356 Input Parameters: 

1357 blc blc of the box ; a vector of quantities 

1358 trc trc of the box; a vector of quantities 

1359 pixelaxes Which pixel axes 

1360 csys Coordinate System 

1361 absrel Absolute or relative coordinates Vector of strings from 'abs', 'relref' and 'relcen' 

1362 comment A comment stored with the region 

1363 

1364 Example: 

1365 

1366 - r = rg.wbox() 

1367 

1368 

1369 This region, on application to an image, will select the entire 

1370 image. 

1371 

1372 

1373 

1374 - ia.open('ada') 

1375 - csys = ia.coordsys() 

1376 - csys.summary() 

1377 

1378 Name Proj Shape Tile Coord value at pixel Coord incr Units 

1379 --------------------------------------------------------------------------- 

1380 Frequency 64 16 1.413350e+09 1.00 1.968717e+04 Hz 

1381 Velocity 1.378053e+02 1.00 -4.174021e+00 km/s 

1382 Declination SIN 178 89 -28.59.18.600 90.00 1.000000e+00 arcsec 

1383 Right Ascension SIN 155 31 17:42:29.303 90.00 -1.000000e+00 arcsec 

1384 - 

1385 - 

1386 - blc = '17:42:29.303 -28.59.18.600' 

1387 - trc = '17:42:28.303 -28.59.10.600' 

1388 - r1 = rg.wbox(blc=blc,trc=trc,pixelaxes=[0,1],csys=csys.torecord()) 

1389 - ia.boundingbox(r1) 

1390 [blc=[1 90 90] , trc=[64 98 103] , regionShape=[64 9 14], imageShape=[64 178 155] ] 

1391 

1392 

1393 We have specified an RA and DEC for the blc and the trc (they should 

1394 be quantities; for blc we do that explicitly, but for the trc 

1395 we just give a vector of strings which is automatically converted 

1396 for us to a vector of quantities). 

1397 

1398 From the {stff summary} listing you can see that RA and DEC correspond 

1399 to pixel axes 3 and 2 respectively (don't be confused by the dual 

1400 listing for the spectral axis) so that is why the {stfaf pixelaxes} 

1401 argument is set to [3,2]. If we had set blc/trc in DEC/RA order then we 

1402 would have put {stfaf pixelaxes=[1,2]}. For the unspecified frequency 

1403 axis, all pixels are selected. 

1404 

1405 

1406 

1407 - ia.open('bork') 

1408 - csys = ia.coordsys() 

1409 - csys.summary() 

1410 

1411 Name Proj Shape Tile Coord value at pixel Coord incr Units 

1412 --------------------------------------------------------------------------- 

1413 Right Ascension SIN 155 31 17:42:29.303 90.00 -1.000000e+00 arcsec 

1414 Declination SIN 178 89 -28.59.18.600 90.00 1.000000e+00 arcsec 

1415 

1416 - rg.setcoordinates(cs) 

1417 T 

1418 - blc = '-10pix -28.59.18.6' 

1419 - trc = '10pix -28.59.1.6' 

1420 - r1 = rg.wbox(blc=blc,trc=trc,absrel='relref abs') # pixelaxes defaults to [0,1] 

1421 Using private CoordinateSystem from image 'bork' 

1422 - ia.boundingbox(r1) 

1423 [blc=[80 90] , trc=[100 107] , regionShape=[21 18] , imageShape=[155 178] ] 

1424 

1425 

1426 In this example, we use pixel coordinates relative to the reference 

1427 pixel for the RA axis and absolute world coordinates for the DEC axis. 

1428 We also set the state of the regionmanager with a Coordinate 

1429 System to use when making world regions. You can see that when the 

1430 region was made, a message was issued reminding you that the internal 

1431 Coordinate System from the image {sff bork} was being used. 

1432 

1433 

1434 

1435 - ia.open('hcn') 

1436 - csys = ia.coordsys() 

1437 - csys.summary() 

1438 

1439 Name Proj Shape Tile Coord value at pixel Coord incr Units 

1440 --------------------------------------------------------------------------- 

1441 Right Ascension SIN 155 31 17:42:29.303 90.00 -1.000000e+00 arcsec 

1442 Declination SIN 178 89 -28.59.18.600 90.00 1.000000e+00 arcsec 

1443 Frequency 64 16 1.413350e+09 1.00 1.968717e+04 Hz 

1444 Velocity 1.378053e+02 1.00 -4.174021e+00 km/s 

1445 T 

1446 - 

1447 - blc = '1.414E9Hz' 

1448 - trc = '1.4145GHz' 

1449 - r = rg.wbox(blc=blc, trc=trc, pixelaxes=[2], csys=cs) 

1450 - ia.boundingbox(r) 

1451 [blc=[1 1 34] , trc=[155 178 59] , regionShape=[155 178 26] , imageShape=[155 178 64] ] 

1452 

1453 

1454 In this example we only specified a region for the frequency axis (note 

1455 we used different units for the blc and trc). Therefore, on 

1456 application, the region selected for the RA and DEC axes is 

1457 automatically the full image. 

1458 

1459 -------------------------------------------------------------------------------- 

1460 

1461 """ 

1462 return _regionmanager.regionmanager_wbox(self, *args, **kwargs) 

1463 

1464 

1465 def wpolygon(self, *args, **kwargs): 

1466 """ 

1467 wpolygon(self, _x, _y, _pixelaxes, _csys, _absrel, _comment) -> record * 

1468 

1469 

1470 

1471 Summary: 

1472 Create a world polygon region with quantities 

1473 

1474 Description: 

1475 

1476 

1477 

1478 This function (short-hand name {stff wpoly}) creates a 2D world 

1479 polygon region. The polygon is specified by an {stfaf x} and a {stfaf y} 

1480 vector. These must be quantities of a vector (the 

1481 world box function 

1482 allows both 

1483 quantities of vectors and vectors of quantities). This means that the 

1484 units are common to all elements of each vector. Thus, {cf 

1485 qa.quantity([1,2,3],'rad')} (a quantity of a vector) is different from 

1486 {cf qa.quantity('1rad 2rad 3rad')} (a vector of quantities) although 

1487 the information that they specify is the same. 

1488 

1489 You specify which pixel axes in the image the {stfaf x} and {stfaf 

1490 y} vectors pertain to with the {stfaf pixelaxes} argument. If you don't, 

1491 it defaults to [0,1]. This specification is an important part of 

1492 world regions. 

1493 

1494 You can specify whether the {stfaf x} and {stfaf y} vector coordinates are 

1495 given as absolute coordinates ({stfaf absrel='abs'}) or relative to the 

1496 reference pixel ({stfaf absrel='relref'}) or relative to the center of the 

1497 image ({stfaf absrel='relcen'}). This argument applies to both the axes 

1498 of the polygon. 

1499 

1500 You must also specify the Coordinate System with the {stfaf csys} 

1501 argument. The Coordinate System is encapsulated in a {stfaf coordinates} 

1502 tool and can be recovered from an image with the 

1503 coordsys function. You can 

1504 also set a default Coordinate System in the Regionmanager with the 

1505 setcoordinates 

1506 function. 

1507 

1508 In the regionmanager we have defined units `pix' and `frac'; these are 

1509 then known to the quanta system. This means 

1510 that you can effectively define a pixel box (except for the stride 

1511 capability) as a world box with most of the advantages of world regions 

1512 (can be used for compound regions). However, it is still not very 

1513 portable to other images because the coordinates are pixel based, 

1514 not world based. 

1515 

1516 Note that the need to deal with the {stfaf pixelaxes} and {stfaf csys} 

1517 is hidden from you when using the gui 

1518 interface of the regionmanager. 

1519 

1520 Input Parameters: 

1521 x The x vector; a vector of quantities 

1522 y The y vector; vector of quantities 

1523 pixelaxes which pixel axes; vector of integers ..default -1 means [0,1]  

1524 csys Coordinate System 

1525 absrel Absolute or relative coordinates; possibilities are 'abs', 'rel', 'relcen' 

1526 comment A comment stored with the region 

1527 

1528 Example: 

1529 

1530 ia.open('myim.im') 

1531 csys = ia.coordsys() 

1532 x = ['3pix', '6pix', '9pix', '6pix', '5pix','5pix','3pix'] 

1533 y = ['3pix','4pix','7pix','9pix','7pix','5pix','5pix'] 

1534 r1 = rg.wpolygon(x=x, y=y, pixelaxes=[0,1], csys=csys.torecord()) 

1535 stats = ia.statistics(region=r1) 

1536 ia.done() 

1537 

1538 

1539 We applied the 2D polygon, defined in the XY plane with absolute pixel 

1540 coordinates, to a 3D image. Therefore, the third (Z) axis was 

1541 automatically extended to the whole image. 

1542 

1543 -------------------------------------------------------------------------------- 

1544 

1545 """ 

1546 return _regionmanager.regionmanager_wpolygon(self, *args, **kwargs) 

1547 

1548 __swig_destroy__ = _regionmanager.delete_regionmanager 

1549 __del__ = lambda self: None 

1550regionmanager_swigregister = _regionmanager.regionmanager_swigregister 

1551regionmanager_swigregister(regionmanager) 

1552 

1553# This file is compatible with both classic and new-style classes. 

1554 

1555