Synopsis
Utility routines for working with Chandra Coordinates
Syntax
from coords.chandra import cel_to_chandra from coords.chandra import sky_to_chandra cel_to_chandra(keyword_list, ra_vals, dec_vals) sky_to_chandra(keyword_list, x_vals, y_vals)
Description
The coords.chandra module contains two routines to convert coordinates - in SKY or Celestial (Right Ascension, Declination) systems - to the most common Chandra coordinate systems:
- detector (detx, dety),
- mirror spherical (off-axis angles theta and phi),
- or chip coordinates.
See ahelp coords for more information on the Chandra coordinate systema.
Parameter values
The first input to each routine is a dictionary of header keywords. One way to access them is with the following code:
>>> from pycrates import read_file >>> cr = read_file(infile) >>> keywords = {n: cr.get_key_value(n) for n in cr.get_keynames()}
The coordinates can either be given as scalars or lists.
Examples
Example 1
>>> from coords.chandra import sky_to_chandra >>> sky_to_chandra(keywords, 4096.5, 4096.5) {'dety': [4096.5], 'detx': [4096.5], 'phi': [0.0], 'ra': [246.82474880852999], 'chipy': [996.6745464316374], 'chip_id': [3], 'theta': [0.0], 'chipx': [975.2463325198958], 'dec': [-24.573378630717002], 'pixsize': 0.492}
In this example a single set of sky X,Y values is input and a dictionary listing the coordinates in a variety of systems are returned.
Example 2
>>> from coords.chandra import cel_to_chandra >>> from pycrates import read_file >>> srclist = read_file("wavedetect.src") >>> keywords = {n: cr.get_key_value(n) for n in srclist.get_keynames()} >>> ra = srclist.get_column("RA").values >>> dec = srclist.get_column("DEC").values >>> coords = cel_to_chandra(keywords, ra, dec) >>> print(sorted(coords.keys())) ['chip_id', 'chipx', 'chipy', 'detx', 'dety', 'phi', 'pixsize', 'theta', 'x', 'y']
In this longer example the RA and DEC values for each source in a wavdetect source list is read in using pycrates. The Chandra coordinates are computed for all the source positions.
The pixsize value is the only value not returned as a list. It is in units of arcsec/pixel.
The following code will plot up the SKY coordinates using Matplotlib (loading it if necessary):
>>> import matplotlib.pyplot as plt >>> plt.scatter(coords["x"], coords["y"]) >>> plt.xlabel('X') >>> plt.ylabel('Y') >>> plt.show()
Changes in scripts 4.11.4 (August 2019) release
Improvements to the docstrings to identify the required keywords values in the input keyword dictionary. Improved error checking to verify that the keyword list contains valid values for the required keywords.
About Contributed Software
This module is not an official part of the CIAO release but is made available as "contributed" software via the CIAO scripts page. Please see this page for installation instructions.
See Also
- contrib
- coords_format, coords_utils, identify_name