Last modified: April 2013

AHELP for CIAO 4.11


Context: contrib


Read in the contours from a ds9 *.con file with optional coordinate conversion.


(xs, ys) = read_ds9_contours(filename [, coords=None, fromsys=None,


This routine reads in the contours from a DS9 *.con file and returns the x and y coordinates of each component as a separate numpy array. If the coords, fromsys and tosys arguments are given then they are used to convert the values to a different coordinate system (e.g. if the values were written out in WCS but you wish to use the sky system).

The add_ds9_contours routine from the chips_contrib.utils module can be used to display a DS9 contour file in ChIPS.

Loading the routine

The routine can be loaded into a ChIPS or Sherpa session by saying:

from crates_contrib.utils import *

Coordinate conversion

To convert the coordinate values form the file then coords should be either the name of an image file or a crate containing an image and the fromsys and tosys arguments determine what systems to use:

The fromsys and tosys arguments

Value Description
"world" or "eqpos" The WCS coordinate systems supported by CIAO
"physical" or "sky" The physical coordinate system
"logical" or "image" The logical coordinate system


Example 1

(xs, ys) = read_ds9_contours("ds9.con")
for i in range(0, len(xs))
    add_line(xs[i], ys[i], ["color", "green"])

Here we read in the contours stored in the file ds9.con and then add them onto a ChIPS image as green lines. See the add_ds9_contours() routine from chips_contrib.utils for a way to automate this.

Example 2

chips> (xs, ys) = read_ds9_contours("ds9.con", "img.fits", "world",

Here the contour coordinates are read in and then converted from WCS to SKY coordinates using the coordinate axes in the image file img.fits.


Coordinate-system support

The coordinate-transform code has been written and tested for use with images created by CIAO tools. Please let the CXC HelpDesk know if it does not work for your image file(s).

Changes in the scripts 4.5.2 (April 2013) release

The routine now works when asked to convert between coordinate systems (this removes the "Input must be a 2D array" error message introduced with CIAO 4.5).


See the bug pages 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