          *DEPRECATED* Parse a region for use by the routines in the region library

r = regParse(region)

The interfaces described in this help file have been deprecated. CIAO 4.10 includes a new object based interface which should be used instead of these routines. This document is provided for legacy support.

Before a region can be used by the other routines in the region library - e.g. to calculate the area or to find out if a point lies inside or outside the region - it must be parsed. The regParse() routine does this parsing and returns an object which represents this region and should be used when calling the other routines. An error is thrown if the region is not valid; for instance due to a syntax error or using a shape that is not understood by the CIAO region library.

The region module is not available by default; see "ahelp region" for information on loading the module.

The input variable to regParse() should be a valid CIAO region string, such as circle(100.23,50.54,23.421) or region(ds9.reg) See 'ahelp dmregions' for a description of the CIAO region syntax.

>>> from region import *
>>> circle_var = regParse("circle(10,10,4)")
>>> print(regRegionString(circle_var))
Circle(10,10,4)

In this example we have just parsed the region string circle(10,10,4) and stored the result in the variable circle_var. This variable can then be used with other functions from the region library, as will be shown in the following examples.

>>> r1 = regParse("circle(50,35,22)-rect(20,10,40,12)")
>>> r2 = regParse("region(src.reg)")

See 'ahelp dmregions' for a description of the syntax of CIAO regions.

>>> area = regArea(r1)
>>> print("The region area is {0:.2f}".format(area))
The region area is 1520.53

In this example we used the regArea() call to calculate the area of the first region from the previous example.

See the bugs page for the region library on the CIAO website for an up-to-date listing of known bugs.

February 2018