Chandra X-Ray Observatory (CXC)
Skip to the navigation links
Last modified: December 2012

URL: http://cxc.harvard.edu/ciao/apply_transform.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.5

apply_transform

Context: transform

Synopsis

Apply a transform to the given data.

Syntax

apply_transform(transform, data)

The apply method of the transform object can also be used.

Description

  • transform - input Transform object
  • data - array of data to be transformed (dimensions depend on the transform type)

The apply_transform command applies the transform to the provided data.

The command assumes that the data is appropriate for the transform definition. That is, if the transform is a simple scale, the data may be a list of scalars. If the transform expects a list of coordinate pairs, the input data must be a list of pairs.

What transformations are defined in a Crate?

For images, the get_axisnames() method of the Crate returns the list of transform names:

chips> cr = read_file('evt2.fits[bin sky=8]')
chips> print(cr.get_axisnames())
['sky', 'EQPOS']

and for tables it can be found by comparing the output of the get_colnames() method when rawonly=True and False:

chips> cr = read_file('evt2.fits[cols time,energy,det,sky]')
chips> print(cr.get_colnames(rawonly=True))
['time', 'energy', 'det(detx, dety)', 'sky(x, y)']
chips> print(cr.get_colnames(rawonly=False))
['time', 'energy', 'det(detx, dety)', 'sky(x, y)', 'MSC(PHI, THETA)',
'EQPOS(RA, DEC)']

or, by taking advantage of the native set support in Python,

chips> n1 = set(cr.get_colnames(rawonly=True))
chips> n2 = set(cr.get_colnames(rawonly=False))
chips> print(n2.difference(n1))
set(['MSC(PHI, THETA)', 'EQPOS(RA, DEC)'])

Example 1

chips> import pycrates as pyc
chips> cr = pyc.read_file("img.fits")
chips> sky = cr.get_transform("sky")
chips> sky.apply([[0.5,0.5]])
array([[ 2008.5, 3148.5]])

Here we find out the SKY coordinates of the bottom-left corner of the image (the logical coordinates 1,1 refer to the center of the first pixel so 0.5,0.5 refers to the bottom-left corner of the pixel).

Example 2

chips> import pycrates as pyc
chips> import pytransform as pyt
chips> cr = pyc.read_file("evt2.fits")
chips> trans = cr.get_transform("MSC")
chips> ivals = [[4000.0, 5000.0],[5500.0,3500.0]]
chips> ovals = apply_transform(trans, ivals)
chips> print(ovals)
[[  9.60964703e+01   1.24180444e-01]
 [  3.36974076e+02   2.08415725e-01]]

The "MSC" transform from the table evt2.fits is applied to the values (4000,5000) and (5500,3500).

Direct access via the object

Note that you can also use the apply method of the transform object - e.g.

chips> ovals = trans.apply(ivals)

as used in the preceeding example.

Bugs

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

transform
copy_transform, get_transform_type

Last modified: December 2012
CXC logo

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-2012. All rights reserved.