Chris Beaumont's IDL Library

Download source code

single page | use frames     summary     class     fields     routine details     file attributes

./

sky2pix.pro

topsky2pix

result = sky2pix(header, coords [, backwards=backwards])

This function translates between 'real' coordinates (eg, ra dec) to pixel coordinates in a fits file. Pixel co-ordinates are given as zero-indexed values (IDL convention) as opposed to 1-indexed (FITS convention). This was designed as a wrapper to / substute for commands like ad2xy, which demand that the input data be 2D. This program processes data cubes as well.

This program is a wrapper to the ad2xy, xy2ad, etc programs. Unlike those procedures, however, sky2pix can handle simple 3D cubes. For this to work, however, the cubes must be "aligned" along the third dimension. That is, the third "sky" axis (e.g. velocity) must correspond directly to the third "data" axis. This is equivalent to saying that, if the header uses the CDX_Y keywords, then CD3_X and CDX_3 must be zero, except for CD3_3. Note that this is almost always the case for normal data cubes.

Return value

result: An array contining the pixel coordinates of the real coordinates given by coords. This array is the same size as coords. result [i,j] contains the coordinate component of the jth data point along the ith pixel dimension.

EXAMPLES: find the pixel location of (ra,dec,vel)=(5,6,7) in header h IDL> result=sky2pix(h,[5,6,7])

find the pixel location of (ra,dec)=(5,6) in a data cube with header h IDL> result=sky2pix(h,[5,6])

Parameters

header in required

A string array containing a fits header (eg, from mrdfits)

coords in required

An n by m array containing the n-dimensional coordinates of m datapoints. These are 'real sky' coordinates, unless the backwards keyword is set.

Keywords

backwards in optional

coords are given in pixel coordinates, and the output is given in sky coordinates

Author information

History:

Written by: Chris Beaumont. July 27 2008 December 17 2008: Cosmetic changes. cnb. November 21 2009: Complete re-write by cnb. Uses the extast3 program, and more directly relies on ad2xy to handle complicated wcs stuff.

File attributes

Modifcation date: Mon Mar 22 16:17:13 2010
Lines: 122