Last modified: February 2018

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/regparse.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.15

regParse

Context: region

Synopsis

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

Syntax

r = regParse(region)

Description

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.

Input format

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.


Examples

Example 1

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

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.


Bugs

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

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