SKY2PIX Name
SKY2PIX
Purpose
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.
Calling Sequence
result=sky2pix(header,coords,/backwards) Inputs
header: A string array containing a fits header (eg, from mrdfits)
coords: An n by m array containing the n-dimensional coordinates of
m datapoints. These are 'real sky' coordinates, unless the
backwards keyword is set.
Keyword Parameters
backwards: coords are given in pixel coordinates, and the output is
given in sky coordinates Outputs
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])
Procedure
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.
Modification 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.