NRAO Home > CASA > CASA Toolkit Reference Manual
regionmanager.wpolygon - Function

1.1.2 Create a world polygon region with quantities

Description

This function (short-hand name wpoly) creates a 2D world polygon region. The polygon is specified by an x and a 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, qa.quantity([1,2,3],’rad’) (a quantity of a vector) is different from 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 x and y vectors pertain to with the 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 x and y vector coordinates are given as absolute coordinates (absrel=’abs’) or relative to the reference pixel (absrel=’relref’) or relative to the center of the image (absrel=’relcen’). This argument applies to both the axes of the polygon.

You must also specify the Coordinate System with the csys argument. The Coordinate System is encapsulated in a coordinates tool 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 pixelaxes and csys is hidden from you when using the gui interface of the Regionmanager.

Arguments

 Inputs x The x vector; a vector of quantities allowed: any Default: variant y The y vector; vector of quantities allowed: any Default: variant Quantity vector pixelaxes which pixel axes; vector of integers ..default -1 means [0,1] allowed: intArray Default: -1 [1,2] csys Coordinate System allowed: record Default: Private Coordinate System absrel Absolute or relative coordinates; possibilities are ’abs’, ’rel’, ’relcen’ allowed: string Default: abs ’abs’ comment A comment stored with the region allowed: string Default:
Returns
record

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.

__________________________________________________________________