Convert between the different coordinate systems of an image.
tr = SimpleCoordTransform(input) (xout, yout) = tr.convert(fromsys, tosys, xin, yin)
The SimpleCoordTransform class allows you to easily convert between the different coordinate systems of a CIAO-produced image (it may work on some non-CIAO data).
Loading the routine
The routine can be loaded into a Python session by saying:
from crates_contrib.utils import *
An object is created using the SimpleCoordTransform constructor, which takes a single argument: the name of an image file or an image crate. The object has a single method - convert - which can then be used to convert between one of three coordinate systems: world, physical, or logical.
The fromsys and tosys arguments define the input and output coordinate systems respectivelty and can be one of:
The fromsys and tosys arguments
|"world" or "eqpos"||The WCS coordinate systems supported by CIAO|
|"physical" or "sky"||The physical coordinate system|
|"logical" or "image"||The logical coordinate system|
The xin and yin arguments can be of a single point or multiple points.
>>> tr = SimpleCoordTransform("img.fits") >>> (r0, d0) = tr.convert("sky", "world", 4096.5, 4096.5)
Here the sky coordinate (4096.5, 4096.5) is converted into Ra and Dec coordinates (assuming the "world" system represents an equatorial coordinate system).
>>> tcr = read_file('sources.fits[cols ra,dec]') >>> ra = tcr.get_column('ra').values >>> dec = tcr.get_column('dec').values >>> icr = read_file('img.fits') >>> tr = SimpleCoordTransform('img.fits') >>> (x, y) = tr.convert('world', 'image', ra, dec)
Here Ra and Dec coordiantes from the file "sources.fits" are converted into image (a.k.a. logical) coordinates of the image stored in img.fits.
The points can then be overlaid on the iage using the following Matplotlib code:
>>> import matplotlib.pyplot as plt >>> plt.imshow(icr.get_image().values, origin='lower') >>> plt.scatter(x, y, color='orange')
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.6.4 (April 2014) release
The error where SimpleCoordTransform would fail, claiming that it was "Unable to find the world system", has been fixed.
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.