About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/reginsideregion.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 regInsideRegion Context: region

Synopsis

Is a point (or set of points) inside a region?

Syntax

Short_Type regInsideRegion( Region_Type Region, Double_Type X,
Double_Type Y )
Array_Type regInsideRegion( Region_Type Region, Array_Type Xarr,
Array_Type Yarr )

Description

The regInsideRegion routine queries a region to find out if a point (or an array of points) is inside the region or not. 1 is returned for yes, and 0 if no. The input values are a CIAO region variable (as returned from regParse), and the positions to query which can be either a single X, Y position or two arrays of positions, Xarray and Yarray.

Example 1

chips> region("region")
chips> reg = regParse("circle(10,10,4)")
chips> flag = regInsideRegion( reg, 12, 11 )
chips> print(flag)
1

Here we use the regInsideRegion() routine to find out whether the point at (12,11) is inside the circle centered at (10,10) with a radius of 4 pixels. The answer is 1, since it is.

Example 2

chips> xc = [ 10, 16, 12 ]
chips> yc = [ 11, -4, 8 ]
chips> flag = regInsideRegion( reg, xc, yc )
chips> writeascii( stdout, xc, yc, flag )
10 11 1
16 -4 0
12 8 1
chips> i = where( flag )
chips> xx = xc[i]
chips> yy = yc[i]
chips> writeascii( stdout, xx, yy )
10 11
12 8

Here we have found that the points (10,11) and (12,8) are inside the region, but that (16,-4) is not. The where() routine is then used to show how you can extract from the arrays only those points that lie inside the region. If the where() finction had been written

where( flag == 0 )

then it would have selected those points that lie outside the region.

Bugs

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

Hardcopy (PDF): A4 | Letter
Last modified: December 2006



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