Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2013

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.9


Context: region


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


r = regParse(region)


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.

Input format

The input variable to regParse() should be a valid CIAO region string, such as




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

Example 1

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

In this example we have just parsed the region string


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.

Example 2

>>> 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.

Example 3

>>> 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.

Refer to the CIAO bug pages for an up-to-date listing of known issues.

See Also

regarea, regextent, reginsideregion, region, regparse, regprintregion, regregionstring

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.