NRAO Home > CASA > CASA Toolkit Reference Manual
##### regionmanager.intersection - Function

1.1.2 Create the intersection of some world regions

Description

This function (short-hand name 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).

Arguments

 Inputs regions World regions and comment allowed: any Default: variant Region tools or record of region tools, and String comment A comment stored with the region allowed: string Default: String
Returns
record

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.

__________________________________________________________________