Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

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

# Version 2.0.4 

# 

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

# the SWIG interface file instead. 

 

 

 

from sys import version_info 

if version_info >= (2,6,0): 

    def swig_import_helper(): 

        from os.path import dirname 

        import imp 

        fp = None 

        try: 

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

        except ImportError: 

            import _regionmanager 

            return _regionmanager 

        if fp is not None: 

            try: 

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

            finally: 

                fp.close() 

            return _mod 

    _regionmanager = swig_import_helper() 

    del swig_import_helper 

else: 

    import _regionmanager 

del version_info 

try: 

    _swig_property = property 

except NameError: 

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

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

    if (name == "thisown"): return self.this.own(value) 

    if (name == "this"): 

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

            self.__dict__[name] = value 

            return 

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

    if method: return method(self,value) 

    if (not static): 

        self.__dict__[name] = value 

    else: 

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

 

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

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

 

def _swig_getattr(self,class_type,name): 

    if (name == "thisown"): return self.this.own() 

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

    if method: return method(self) 

    raise AttributeError(name) 

 

def _swig_repr(self): 

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

    except: strthis = "" 

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

 

try: 

    _object = object 

    _newclass = 1 

except AttributeError: 

    class _object : pass 

    _newclass = 0 

 

 

class regionmanager(_object): 

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

    __swig_setmethods__ = {} 

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

    __swig_getmethods__ = {} 

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

    __repr__ = _swig_repr 

    def __init__(self): 

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

        this = _regionmanager.new_regionmanager() 

        try: self.this.append(this) 

        except: self.this = this 

    __swig_destroy__ = _regionmanager.delete_regionmanager 

    __del__ = lambda self : None; 

    def absreltype(self, absrelvalue = 0): 

        """ 

        absreltype(self, absrelvalue = 0) -> string 

 

        Summary 

                Convert region type value to a string 

 

        Description 

                 

 

        This function is not intended for general user use. 

 

        Regions may be specified with coordinates which are absolute or 

        relative.  This function converts the integer code defining the 

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

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

 

        The different types are 

 

 

        Integer     String      Description 

        1            abs        Absolute coordinate 

        2            relref     Relative reference pixel 

        3            relcen     Relative to center of image 

        4            reldir     Relative to some direction 

 

          

 

 

        Input Parameters: 

                absrelvalue      Region type value 0 Integer - 1, 2, 3, 4  

                 

        Example: 

                 

 

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

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

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

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

        - 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

        return _regionmanager.regionmanager_absreltype(self, absrelvalue) 

 

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

        """ 

        box(self, blc = initialize_vector(1, (double)0), trc = initialize_vector(1, (double)-1),  

            inc = initialize_vector(1, (double)1),  

            absrel = string("abs"),  

            frac = False, comment = string("")) -> record 

 

        Summary 

                Create a pixel box region 

 

        Description 

                 

 

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

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

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

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

        corner of the image.  

 

        You can specify whether the coordinates are given as pixel coordinates 

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

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

 

        You can also specify whether the coordinates are given as absolute 

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

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

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

 

 

 

        Input Parameters: 

                blc              blc of the box 0 Unity  

                trc              trc of the box -1 Shape  

                inc              increment 1  

                absrel           Absolute or relative coordinates relref relcen abs  

                frac             Pixel or fractional coordinates false F  

                comment          A comment stored with the region  

                 

        Example: 

                   

 

        ia.open('myimage') 

        ia.shape() 

        [155 178 256] 

 

        r = rg.box()                 # create region 

        - 

        - ia.boundingbox(r) 

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

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

 

 

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

 

 

        Example: 

                   

 

        - ia.open('myimage') 

        - ia.shape() 

        [155 178 256]   

        - 

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

        - ia.boundingbox(r) 

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

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

 

 

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

        Automatic extension rules apply for the other axis and the trc 

        (defaults to the shape). 

 

 

        Example: 

                   

 

        - ia.open('myimage') 

        - ia.shape() 

        [155 178 256] 

        - 

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

        - ia.boundingbox(r)                                         

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

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

        - 

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

        stats['npts'][0] 

        216 

 

 

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

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

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

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

        as well.  

 

 

        Example: 

                   

 

        THIS EXAMPLE IS NOT VALID YET 

 

        - ia.open('myimage') 

        - ia.shape() 

        [64 128]   

        - 

        - rmd = rg.dflt() 

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

        - 

        - ia.boundingbox(r) 

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

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

 

 

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

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

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

        image shape.  

 

 

        Example: 

                   

 

        - ia.open('myimage') 

        - ia.shape() 

        [155 178 256]  

        - 

        - summ=ia.summary(list=False) 

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

        [90 90 1] 

        - 

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

        - ia.boundingbox(r) 

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

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

 

 

        This example shows selection by relative to reference pixel fractional 

        coordinates plus auto extension to unspecified axes.  

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        frombcs(self, csys = initialize_record(""), shape = initialize_vector(1, (int)0),  

            box = string(""), chans = string(""),  

            stokes = string(""), stokescontrol = string("a"),  

            region = initialize_variant("")) -> record 

 

        Summary 

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

 

        Description 

                 

 

        This function creates a multi-dimensional world coordinate region based 

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

        being introduced as a temporary means of refactoring some python level 

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

        can be permanent. 

 

 

        Input Parameters: 

                csys             Coordinate system record. Must be specified.  

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

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

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

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

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

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

                 

        Example: 

                   

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        complement(self, region = initialize_variant(""), comment = string("")) -> record 

 

        Summary 

                Create the complement of a world region 

 

        Description 

                 

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

        a world region(s).  

 

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

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

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

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

        the union. 

 

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

 

 

 

        Input Parameters: 

                region           The world region Region tool  

                comment          A comment stored with the region String  

                 

        Example: 

                   

 

        - ia.open('hcn') 

        - csys = ia.coordsys() 

        - ia.shape() 

        [155 178] 

        - 

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

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

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

        - r3 = rg.complement(r2); 

        - 

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

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

        No pts   = 126 

        - 

        - ia.statistics(region=r3) 

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

        No pts   = 27464 

 

 

        As expected,  the number of pixels in the complement 

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

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        concatenation(self, box = initialize_variant(""), regions = initialize_variant(""),  

            comment = string("")) -> record 

 

        Summary 

                Concatenate world regions along a new axis 

 

        Description 

                 

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

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

 

        This function is similar to the 

        extension function.  The 

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

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

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

        does). 

 

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

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

        together to form the overall region for use in a deconvolution 

        application.  

 

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

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

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

        to concatenate.    

 

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

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

        dictionaries, as there might be a lot of them. 

 

 

 

        Input Parameters: 

                box              The axis to concatenate along world box region  

                regions          World regions Record containing world regions  

                comment          A comment stored with the region String  

                 

        Example: 

                 

 

        - ia.open('cube') 

        - csys = ia.coordsys() 

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

                                                            # private coordinates used 

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

        - bb = ia.boundingbox(box) 

        - 

        - regs = {}; 

        - local x, y; 

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

        + # Some code in function `mypolygon' generates the  

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

        +     

        +    mypolygon(x,y); 

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

        - rc = rg.concatenation(box, regs) 

        - 

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

        Plane Freq         Npts Sum            Mean           Rms            Sigma          Minimum        Maximum         

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

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

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

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

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

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

 

 

 

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

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

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

        as each polygon is different. 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        deletefromtable(self, tablename = string(""), regionname = string("")) -> bool 

 

        Summary 

                Delete regions from a Table 

 

        Description 

                 

 

 

        This function deletes a region stored in an casa  Table.   

 

        For the {\stfaf tablename} argument,  

 

        you have to give  the name of an existing 

        CASA table on disk (any kind of table). 

 

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

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

        with the function 

        namesintable.  

 

 

 

        Input Parameters: 

                tablename        The table Image tool, table tool or String  

                regionname       Name(s) of the region(s) to delete Vector of strings  

                 

        Example: 

                 

 

        - names = rg.namesintable(hcn) 

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

 

          

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

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        difference(self, region1 = initialize_record(""), region2 = initialize_record(""),  

            comment = string("")) -> record 

 

        Summary 

                Create the difference of two world regions 

 

        Description 

                 

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

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

        of the regions is important. 

 

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

        region and not masked-on in the second region. 

 

 

 

        Input Parameters: 

                region1          The first world region  

                region2          The second world region Region tool  

                comment          A comment stored with the region String  

                 

        Example: 

                   

 

        - ia.open('hcn') 

        - csys = ia.coordsys() 

        - rg.setcoordinates(csys.torecord()) 

        - 

        - blc = '10pix 10pix' 

        - trc = '60pix 60pix' 

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

        - 

        - blc = '50pix 50pix' 

        - trc = '80pix 80pix' 

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

        -  

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

        - 

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

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

        No pts   = 2601 

        - 

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

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

        No pts   = 2480 

        - 

        - 

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

        - 

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

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

        No pts   = 961 

        - 

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

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

        No pts   = 840 

 

 

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

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

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

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

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

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

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

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

    def done(self): 

        """ 

        done(self) -> bool 

 

        Summary 

                Destroy this regionmanager 

 

        Description 

                 

          

        This function destroys the contents of the {\stf regionmanager}         ool(including its GUI).  The    ool\ still exists as a Glish variable, but 

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

        function.  

          

 

        -------------------------------------------------------------------------------- 

                       

        """ 

        return _regionmanager.regionmanager_done(self) 

 

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

        """ 

        selectedchannels(self, specification = string(""), shape = initialize_vector(1, (int)0)) -> std::vector<(int)> 

 

        Summary 

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

 

        Description 

                 

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

 

 

 

             

 

        Input Parameters: 

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

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

                 

        Example: 

                 

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

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

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

                ia.done() 

             

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        fromtextfile(self, filename = string(""), shape = initialize_vector(1, (int)0),  

            csys = initialize_record("")) -> record 

 

        Summary 

                Create a region dictionary from a region text file. 

 

        Description 

                 

        This function reads a text file containing region descriptions and 

        converts it to a python dictionary. 

 

             

 

        Input Parameters: 

                filename         List of text file containing the region description  

                shape            Image shape. 0  

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

                 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        fromtext(self, text = string(""), shape = initialize_vector(1, (int)1),  

            csys = initialize_record("")) -> record 

 

        Summary 

                Create a region dictionary from a region text string. 

 

        Description 

                 

        This function reads a region region text descriptions and 

        converts it to a python region dictionary. 

 

             

 

        Input Parameters: 

                text             region description  

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

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

                 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        fromfiletorecord(self, filename = string(""), verbose = True, regionname = string("")) -> record 

 

        Summary 

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

 

        Description 

                 

        This function reads files containing ImageRegion objects and turns them 

        into Region Records. 

 

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

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

        image analysis tool. 

 

 

 

        Input Parameters: 

                filename         List of files containing the Image Regions File name(s)  

                verbose          Report successful saves true true  

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

                 

        Example: 

                 

 

        - img = ia.open('hcn') 

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

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

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

 

          

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

        from the files ??? 

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

 

 

        Example: 

                 

        e 

        - img = ia.open('hcn') 

        - r1 = rg.box()f 

        - r2 = rg.quarter() 

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

        - rg.namesintable(img) 

        x1 x2 

 

          

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

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

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

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

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

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

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

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        tofile(self, filename = string(""), region = initialize_record("")) -> bool 

 

        Summary 

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

 

        Description 

                 

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

 

 

 

        Input Parameters: 

                filename         List of files containing the Image Regions File name(s)  

                region           region record/dict to store in the file  

                 

        Example: 

                 

 

        - img = ia.open('hcn') 

        - imcs=ia.coordsys() 

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

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

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

        - rg.tofile('myboxregion', r1) 

        - r1readback=rg.fromfiletorecord('myboxregion') 

 

          

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

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

        identical.  

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        fromrecordtotable(self, tablename = string(""), regionname = initialize_variant(""),  

            regionrec = initialize_record(""),  

            asmask = False, verbose = True) -> string 

 

        Summary 

                Save regions stored in a record into a Table 

 

        Description 

                 

 

 

        This function saves regions into an casa Table 

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

        ipspp\ Table on disk (any kind of table). 

 

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

        A mask makes sense with an image only.   

 

 

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

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

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

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

        function returns you the name the region is assigned 

 

 

 

        Input Parameters: 

                tablename        The table Image tool, table tool or String  

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

                regionrec        Region(s) to save Record of region tool(s)  

                asmask           save region as a mask rather than region false false  

                verbose          Report successful saves true True  

                 

        Example: 

                 

 

        - ia.open('hcn') 

        - cs=ia.coordsys() 

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

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

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

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

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

        x 

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

        x0 

        - rg.namesintable('hcn') 

        x x0 

 

 

          

 

 

        Example: 

                 

 

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

 

        - names = rg.namesintable('hcn1') 

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

        - rg.namesintable('hcn2') 

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

 

 

        In this example, we recover a region into a record 

        from one image, and then copy them to another. 

 

 

        Example: 

                 

 

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

        ia.open('myfancy.image') 

        csys=ia.coordsys() 

        ia.done() 

        ##Lets make a world-box  region  

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

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

        ###mask1 

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

        ###now let us set that as default mask 

        ia.open('myfancy.restored') 

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

        ia.done() 

        ###and now let us view that image 

        viewer('try01.0.restored') 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        fromtabletorecord(self, tablename = string(""), regionname = initialize_variant(""),  

            verbose = True) -> record 

 

        Summary 

                Restore regions from a Table to a record 

 

        Description 

                 

 

        This function restores a region from an ipspp\ Table 

        to the global name space. 

 

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

        image   ool, a table    ool, 

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

        ipspp\ table on disk (any kind of table).  

 

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

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

        the regions are put into numbered fields (the field 

        names could be anything). 

 

        You can use the function 

        namesintable to find out the 

        names of the regions in the Table.  

 

 

 

        Input Parameters: 

                tablename        The table Image tool, table tool or String  

                regionname       Name of the region(s) to restore All  

                verbose          Report successful restores true True  

                 

        Example: 

                 

 

        - img = ia.open('hcn') 

        - rec = rg.fromtabletorecord(img, numberfields=T) 

        - print is_region(rec[0]) 

 

 

        The record fields are numbered, not named. 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        intersection(self, regions = initialize_variant(""), comment = string("")) -> record 

 

        Summary 

                Create the intersection of some world regions 

 

        Description 

                 

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

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

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

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

        (see examples). 

 

 

 

 

        Input Parameters: 

                regions          World regions and comment Region tools or record of region tools, and String  

                comment          A comment stored with the region String  

                 

        Example: 

                 

 

        - ia.open('hcn') 

        - csys = ia.coordsys() 

        - rg.setcoordinates(csys.torecord()) 

        - 

        - blc = '10pix 10pix 1pix' 

        - trc = '60pix 60pix 1pix' 

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

        - 

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

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

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

        -  

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

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

        -  

        - ia.boundingbox(r1) 

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

        - ia.boundingbox(r2) 

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

        - ia.boundingbox(r3) 

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

        - 

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

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

        Number points = 51             

 

 

 

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

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

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

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

        the bounding box.  

 

 

        Example: 

                   

 

        - ia.open('onno') 

        - csys = ia.coordsys() 

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

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

        - 

        - regions = {}; 

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

        - 

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

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

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

        - 

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

 

 

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

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

        call sequence. 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        ispixelregion(self, region = initialize_record("")) -> bool 

 

        Summary 

                Is this region a pixel region ? 

 

        Description 

                 

        NOT IMPLEMENTED IN CASA 

 

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

        For any other \glish\ variable it returns F. 

 

 

 

        Input Parameters: 

                region           The region Region tool  

                 

        Example: 

                 

 

        - ia.open('hcn') 

        - csys = ia.coordsys() 

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

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

        - rg.ispixelregion(r1) 

        T 

        - rg.ispixelregion(r2) 

        F 

        - x = [20,30] 

        - rg.ispixelregion(x) 

        F 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        isworldregion(self, region = initialize_record("")) -> bool 

 

        Summary 

                Is this region a world region ? 

 

        Description 

                 

        NOT IMPLEMENTED IN CASA 

 

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

        For any other \glish\ variable it returns F. 

 

 

 

        Input Parameters: 

                region           The region Region tool  

                 

        Example: 

                 

 

        - ia.open('hcn') 

        - csys = ia.coordsys() 

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

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

        - rg.isworldregion(r1) 

        F 

        - rg.isworldregion(r2) 

        T 

        - x = [20,30] 

        - rg.isworldregion(x) 

        F 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        namesintable(self, tablename = string("")) -> std::vector<(std::string)> 

 

        Summary 

                Find the names of the regions stored in a Table 

 

        Description 

                 

 

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

 

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

        ipspp\ table on disk (any kind of table).  

 

 

 

        Input Parameters: 

                tablename        The table Image tool, table tool or String  

                 

        Example: 

                 

 

 

        - names=rg.namesintable('hcn') 

        - names 

        r1 poly2 int0 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        setcoordinates(self, csys = initialize_record("")) -> bool 

 

        Summary 

                Set new default Coordinate System 

 

        Description 

                 

          

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

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

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

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

        stored in a {\stf coordinates}  ool\ and is created with 

        the coordsys    oolfunction. 

 

        Normally, the world region creating functions like 

        wbox and 

        wpolygon will issue a message 

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

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

 

          

 

 

        Input Parameters: 

                csys             Default Coordinate System for use in world regions Coordinate tool  

                 

        Example: 

                 

 

        - ia.open('quiqui') 

        - csys = ia.coordsys() 

        - rg.setcoordinates(csys.torecord()) 

        - r1 = rg.wbox() 

        Using private CoordinateSystem from image 'quiqui' 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        makeunion(self, regions = initialize_variant(""), comment = string("")) -> record 

 

        Summary 

                Create a union of world regions 

 

        Description 

                 

 

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

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

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

        regions must be a Pythion dictionary of at leat two regions 

        (see examples). 

 

 

 

        Input Parameters: 

                regions          World regions and comment Record/dict of regions to be unionized (the key names are immaterial)  

                comment          A comment stored with the region  

                 

        Example: 

                   

 

        - ia.open('onno') 

        - csys = ia.coordsys() 

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

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

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

        - 

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

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

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

        - 

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

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

        -  

        - ia.shape() 

        [155 178 256]   

        - ia.boundingbox(r1) 

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

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

        - ia.boundingbox(r2) 

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

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

        - ia.boundingbox(r3) 

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

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

        - 

        - ia.statistics(region=r1) 

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

        Number points = 6400           

        - 

        - ia.statistics(region=r2) 

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

        Number points = 32256          

        - 

        - ia.statistics(region=r3)  

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

        Number points = 38656          

 

 

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

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

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

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

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

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

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

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

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

 

 

        Example: 

                   

 

        - ia.open('onno') 

        - csys = ia.coordsys() 

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

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

        - 

        - regions = {} 

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

        - 

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

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

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

        - 

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

 

 

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

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

        call sequence. 

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        wbox(self, blc = initialize_variant(""), trc = initialize_variant(""),  

            pixelaxes = initialize_vector(1, (int)-1),  

            csys = initialize_record(""), absrel = string("'abs'"),  

            comment = string("")) -> record 

 

        Summary 

                Create a world box region 

 

        Description 

                 

 

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

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

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

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

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

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

 

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

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

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

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

 

        You can specify whether the coordinates are given as absolute coordinates 

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

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

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

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

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

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

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

        for two axes). 

 

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

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

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

        part of world regions.  

 

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

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

        tool and can be recovered from an image with the 

        coordsys tool function.  You can 

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

        setcoordinates  

        function. 

 

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

        then known to the quanta system.  This means 

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

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

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

        portable to other images because the coordinates are pixel based, 

        not world based.  

 

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

        is hidden from you when using the gui 

        interface of the regionmanager.  

 

 

 

        Input Parameters: 

                blc              blc of the box ; a vector of quantities Unity  

                trc              trc of the box; a vector of quantities Shape  

                pixelaxes        Which pixel axes -1 [0,1,2,...]  

                csys             Coordinate System Private Coordinate System  

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

                comment          A comment stored with the region  

                 

        Example: 

                   

 

        - r = rg.wbox() 

 

 

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

        image. 

 

 

        Example: 

                   

 

        - ia.open('ada') 

        - csys = ia.coordsys() 

        - csys.summary() 

 

        Name             Proj Shape Tile   Coord value at pixel    Coord incr Units 

        ---------------------------------------------------------------------------  

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

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

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

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

        - 

        - 

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

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

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

        - ia.boundingbox(r1) 

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

 

 

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

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

        we just give a vector of strings which is automatically converted 

        for us to a vector of quantities). 

 

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

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

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

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

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

        axis, all pixels are selected.  

 

 

        Example: 

                   

 

        - ia.open('bork') 

        - csys = ia.coordsys() 

        - csys.summary() 

 

        Name             Proj Shape Tile   Coord value at pixel    Coord incr Units 

        ---------------------------------------------------------------------------  

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

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

 

        - rg.setcoordinates(cs) 

        T 

        - blc = '-10pix -28.59.18.6' 

        - trc = '10pix  -28.59.1.6' 

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

        Using private CoordinateSystem from image 'bork' 

        - ia.boundingbox(r1) 

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

 

 

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

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

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

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

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

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

 

 

        Example: 

                   

 

        - ia.open('hcn') 

        - csys = ia.coordsys() 

        - csys.summary() 

 

        Name             Proj Shape Tile   Coord value at pixel    Coord incr Units 

        ---------------------------------------------------------------------------  

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

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

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

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

        T  

        - 

        - blc = '1.414E9Hz' 

        - trc = '1.4145GHz' 

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

        - ia.boundingbox(r) 

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

 

 

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

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

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

        automatically the full image.   

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

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

        """ 

        wpolygon(self, x = initialize_variant(""), y = initialize_variant(""),  

            pixelaxes = initialize_vector(1, (int)-1),  

            csys = initialize_record(""), absrel = string("abs"),  

            comment = string("")) -> record 

 

        Summary 

                Create a world polygon region with quantities 

 

        Description 

                 

 

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

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

        vector.  These must be quantities of a vector (the  

        world box function 

        allows both 

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

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

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

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

        the information that they specify is the same.  

 

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

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

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

        world regions.  

 

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

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

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

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

        of the polygon.  

 

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

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

                ool\ and can be recovered from an image with the 

        coordsys function.  You can 

        also set a default Coordinate System in the Regionmanager with the 

        setcoordinates  

        function. 

 

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

        then known to the quanta system.  This means 

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

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

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

        portable to other images because the coordinates are pixel based, 

        not world based.  

 

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

        is hidden from you when using the gui 

        interface of the regionmanager.  

 

 

 

        Input Parameters: 

                x                The x vector; a vector of quantities  

                y                The y vector; vector of quantities Quantity vector  

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

                csys             Coordinate System Private Coordinate System  

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

                comment          A comment stored with the region  

                 

        Example: 

                   

 

        ia.open('myim.im') 

        csys = ia.coordsys() 

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

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

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

        stats = ia.statistics(region=r1) 

        ia.done() 

 

 

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

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

        automatically extended to the whole image.  

 

 

        -------------------------------------------------------------------------------- 

                       

        """ 

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

 

regionmanager_swigregister = _regionmanager.regionmanager_swigregister 

regionmanager_swigregister(regionmanager) 

 

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