Last modified: December 2022

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/coords_gratings.html
AHELP for CIAO 4.16

coords_gratings

Context: contrib

Synopsis

Object to convert to/from Chandra grating coordinates.

Syntax

from coords.gratings import TGPixlib

Description

This module provides an object, TGPixlib, that can be used to convert between sky coordinates and grating coordinates: dispersion plus cross-dispersion angles and energy. It can also be used to convert from energy to sky coordinates.

See ahelp coords for more information on the Chandra coordinate systems.

Keyword values

The input to the constructor is a dictionary of header keywords. One way to get this is using the following code snipet.

>>> from pycrates import read_file
>>> cr = read_file(infile)
>>> keywords = {n: cr.get_key_value(n) for n in cr.get_keynames()}

Zero Order Location

Most of the routines also require the user supply the zero-order location, in sky coordinates (physical pixels). The easiest way to get this is to look at the "REGION" extension in the Level2 event file. The row with shape="CIRCLE" is the zeroth order location.

>>> from pycrates import read_file
>>> cr = read_file(infile+"[REGION][shape=circle]")
>>> x0 = cr.get_column("x").values[0]
>>> y0 = cr.get_column("y").values[0]
>>> zero_order = (x0, y0)

Examples

Example 1

>>> from coords.gratings import TGPixlib
>>> tg_coords = TGPixlib(keys)
>>> sky = (3976, 4296)
>>> tg_r,tg_d = tg_coords.sky_to_grating_angles(sky, "heg", 1,
zero_order)
>>> tg_r,tg_d
(-0.04148751081946563, -0.0005054652107781537)

This example shows how to convert from sky coordinates (physical pixels) to grating angular coordinates, tg_r and tg_d: the dispersion and cross dispersion angles.

As this is an HETG observations, users can select either "heg" or "meg". If users use "hetg" for the grating arm, "heg" will be used. For LETG observations, either "letg" or "leg" produce the same results.

Example 2

>>> energy = tg_coords.sky_to_grating_energy(sky, "heg", 1, zero_order)

This example builds on the previous one and computes the grating energy; that is what energy photons are dispersed to this sky location for this grating ("heg") and order ("1").


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_chandra, coords_format, coords_utils, identify_name