Table Of Contents

Previous topic

pixtosky: Coordinate transformation to sky coordinates

Next topic


This Page

skytopix: Coordinate transformation from sky coordinates

This task allows a user to perform coordinate transformations with the full WCS and distortion model on source positions from sky coordinates to the WCS defined by an image. This task serves as a replacement for the IRAF.STSDAS task ‘rd2xy’, albeit with the added capability of understanding the full distortion model provided in the headers of images updated for use with astrodrizzle and tweakreg.

skytopix - A module to perform coordinate transformation from sky to pixel coordinates.



input : str
full filename with path of input image, an extension name [‘sci’,1] should be provided if input is a multi-extension FITS file

Optional Parameters

ra : string, optional
RA from input image
dec : string, optional
Dec from input image
coordfile : str, optional
full filename with path of file with sky coordinates
colnames : str, optional
comma separated list of column names from ‘coordfile’ files containing x,y coordinates, respectively. Will default to first two columns if None are specified. Column names for ASCII files will use ‘c1’,’c2’,... convention.
separator : str, optional
non-blank separator used as the column delimiter in the coords file
precision : int, optional
Number of floating-point digits in output values
output : str, optional
Name of output file with results, if desired
verbose : bool
Print out full list of transformation results (default: False)


x : float
X position of pixel. If more than 1 input value, then it will be a numpy array.
y : float
Y position of pixel. If more than 1 input value, then it will be a numpy array.


This module performs a full distortion-corrected coordinate transformation based on all WCS keywords and any recognized distortion keywords from the input image header.


It can be called from within Python using the syntax:

>>> from drizzlepac import skytopix
>>> x,y = skytopix.rd2xy("input_flt.fits[sci,1]","00:22:36.79","-72:4:9.0")


  1. The following command will transform the position 00:22:36.79 -72:4:9.0 into a

    position on the image ‘input_flt.fits[sci,1]’ using:

    >>> from drizzlepac import skytopix
    >>> x,y = skytopix.rd2xy("input_file_flt.fits[sci,1]", "00:22:36.79","-72:4:9.0")
  2. The set of sky positions from ‘input_flt.fits[sci,1]’ stored as

    the 3rd and 4th columns from the ASCII file ‘radec_sci1.dat’ will be transformed and written out to ‘xy_sci1.dat’ using:

    >>> from drizzlepac import skytopix
    >>> x,y = skytopix.rd2xy("input_flt.fits[sci,1]", coordfile='radec_sci1.dat',
        colnames=['c3','c4'], output="xy_sci1.dat")
drizzlepac.skytopix.rd2xy(input, ra=None, dec=None, coordfile=None, colnames=None, precision=6, output=None, verbose=True)

Primary interface to perform coordinate transformations from pixel to sky coordinates using STWCS and full distortion models read from the input image header.